protected void createXYLineChart(boolean isLineChart) { com.hydro4ge.raphaelgwt.client.Raphael.Set plotBox = chart.new Set(); Point originPoint = new Point(xAxis.getTickPoints().get(0).getX(), yAxis.getTickPoints().get(0).getY()); Shape org = chart.new Circle(originPoint.getX(), originPoint.getY(), .1); plotBox.push(org); chartStack.push(org); chartSet.push(org); double xMax = Double.parseDouble(xAxis.getTickLabel().get(xAxis.getTickLabel().size() - 1)); double yMax = Double.parseDouble(yAxis.getTickLabel().get(xAxis.getTickLabel().size() - 1)); double xRatio = axisWidth / xMax; // dataTable.getxMax(); double yRatio = axisHeight / yMax; // dataTable.getyMax(); if (dataTable.getxMin() < 0) { xRatio = xRatio / 2; } if (dataTable.getyMin() < 0) { yRatio = yRatio / 2; } java.util.Set<String> seriesNames = dataTable.getSeriesNames(); Iterator<String> seriesIt = seriesNames.iterator(); boolean move = true; while (seriesIt.hasNext()) { List<PointData> pData = new ArrayList<XYLineChartFactory.PointData>(); String series = seriesIt.next(); List<Point> points = dataTable.getPointMap().get(series); String color = colorMap.get(series); move = true; PathBuilder linePath = new PathBuilder(); for (Point point : points) { double x = originPoint.getX() + (point.getX() * xRatio); double y = originPoint.getY() - (point.getY() * yRatio); Circle c = chart.new Circle(x, y, POINT_RADIUS); c.attr("fill", color); if (move) { linePath.M(x, y); move = false; } else { linePath.L(x, y); } plotBox.push(c); chartStack.push(c); chartSet.push(c); pData.add(new PointData(point, c)); } Path line = chart.new Path(linePath); line.attr("stroke", color); line.attr("stroke-width", 2); if (!isLineChart) { line.hide(); } plotBox.push(line); chartSet.push(line); pointDataTable.put(series, pData); } this.plotSet = plotBox; }
private void pushAxisToChart() { List<Shape> list = xAxis.getAxisList(); for (Shape s : list) { chartSet.push(s); } list = yAxis.getAxisList(); for (Shape s : list) { chartSet.push(s); } }