ChartPanelShowStatistics(
      String title,
      String timeAxisLabel,
      String valueAxisLabel,
      XYDataset dataset /*, boolean legend, boolean tooltips, boolean urls*/) {
    this();
    // chart = ChartFactory.createTimeSeriesChart(title, timeAxisLabel, valueAxisLabel, dataset);
    chart = ChartFactory.createScatterPlot(title, timeAxisLabel, valueAxisLabel, dataset);
    ChartPanel p = new ChartPanel(chart);
    add(p, BorderLayout.CENTER);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer();

    renderer.setBaseShapesVisible(false);
    //		renderer.setBaseShape(itemShape);	// 好像不管用,必须用setSeriesShape
    renderer.setBaseLinesVisible(true);
    //		renderer.setBasePaint(new Color(0));	// 好像不管用,必须用setSeriesPaint

    itemShape = ShapeUtilities.createDiamond((float) 3);
    renderer.setSeriesShape(0, itemShape);
    renderer.setSeriesPaint(0, new Color(255, 0, 0));

    renderer.setSeriesShape(1, itemShape);
    renderer.setSeriesPaint(1, new Color(0, 255, 0));

    renderer.setBaseToolTipGenerator(
        new StandardXYToolTipGenerator(
            "{0}:({1} , {2})",
            new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), new DecimalFormat("#.00")));
  }
Exemple #2
0
  public static void drawPic(String url, String file) throws FileNotFoundException, IOException {
    //		XYSeries xyseries = getXY(url);
    XYSeries xyseries = getXYseries(url);
    XYSeriesCollection xyseriescollection =
        new XYSeriesCollection(); // 再用XYSeriesCollection添加入XYSeries
    // 对象
    xyseriescollection.addSeries(xyseries);

    // 创建主题样式
    StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
    // 设置标题字体
    standardChartTheme.setExtraLargeFont(new Font("隶书", Font.BOLD, 20));
    // 设置图例的字体
    standardChartTheme.setRegularFont(new Font("宋书", Font.PLAIN, 15));
    // 设置轴向的字体
    standardChartTheme.setLargeFont(new Font("宋书", Font.PLAIN, 15));
    // 应用主题样式
    ChartFactory.setChartTheme(standardChartTheme);
    // JFreeChart chart=ChartFactory.createXYAreaChart("xyPoit", "点的标号",
    // "出现次数", xyseriescollection, PlotOrientation.VERTICAL, true, false,
    // false);
    JFreeChart chart =
        ChartFactory.createScatterPlot(
            "决策图", "点密度", "点距离", xyseriescollection, PlotOrientation.VERTICAL, true, false, false);
    //		String file="d:/decision_chart.png";
    try {
      ChartUtilities.saveChartAsPNG(new File(file), chart, 470, 470);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    System.out.println(new java.util.Date() + ": finished drawing the pic in " + file);
  }
  private static JFreeChart createChart(
      XYDataset dataset,
      String applicationTitle,
      String chartTitle,
      String xlabel,
      String ylabel,
      String name) {
    JFreeChart chart =
        ChartFactory.createScatterPlot(
            chartTitle, xlabel, ylabel, dataset, PlotOrientation.VERTICAL, true, false, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setNoDataMessage("NO DATA");
    plot.setDomainZeroBaselineVisible(true);
    plot.setRangeZeroBaselineVisible(true);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesOutlinePaint(0, Color.black);
    renderer.setUseOutlinePaint(true);
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    domainAxis.setTickMarkInsideLength(2.0f);
    domainAxis.setTickMarkOutsideLength(0.0f);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setTickMarkInsideLength(2.0f);
    rangeAxis.setTickMarkOutsideLength(0.0f);

    return chart;
  }
Exemple #4
0
 /** Checks that the auto-range for the range axis on an XYPlot is working as expected. */
 @Test
 public void testXYAutoRange2() {
   XYSeries series = new XYSeries("Series 1");
   series.add(1.0, 1.0);
   series.add(2.0, 2.0);
   series.add(3.0, 3.0);
   XYSeriesCollection dataset = new XYSeriesCollection();
   dataset.addSeries(series);
   JFreeChart chart = ChartFactory.createScatterPlot("Test", "X", "Y", dataset);
   XYPlot plot = (XYPlot) chart.getPlot();
   NumberAxis axis = (NumberAxis) plot.getRangeAxis();
   axis.setAutoRangeIncludesZero(false);
   assertEquals(0.9, axis.getLowerBound(), EPSILON);
   assertEquals(3.1, axis.getUpperBound(), EPSILON);
 }
  /**
   * A demonstration application showing a scatter plot.
   *
   * @param title the frame title.
   */
  public ScatterPlotDemo4(String title) {

    super(title);
    XYSeries series = new XYSeries("Average Weight");
    series.add(-20.0, 20.0);
    series.add(40.0, 25.0);
    series.add(55.0, 50.0);
    series.add(70.0, 65.0);
    series.add(270.0, 65.0);
    series.add(570.0, 55.0);
    XYDataset data = new XYSeriesCollection(series);
    JFreeChart chart =
        ChartFactory.createScatterPlot(
            "Scatter Plot Demo", "X", "Y", data, PlotOrientation.VERTICAL, true, true, false);
    XYPlot plot = chart.getXYPlot();
    LogElemRenderer render = new LogElemRenderer();
    render.setDotWidth(25);
    render.setDotHeight(25);
    plot.setRenderer(render);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);

    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(800, 470));

    Border border =
        BorderFactory.createCompoundBorder(
            BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createEtchedBorder());
    chartPanel.setBorder(border);
    add(chartPanel);

    JPanel dashboard = new JPanel(new BorderLayout());
    dashboard.setBorder(BorderFactory.createEmptyBorder(0, 4, 4, 4));
    // make the slider units "minutes"
    slider = new JSlider(-200, 200, 0);
    slider.setPaintLabels(true);
    slider.setMajorTickSpacing(50);
    slider.setPaintTicks(true);
    slider.addChangeListener(this);
    dashboard.add(slider);
    add(dashboard, BorderLayout.SOUTH);

    // setContentPane(chartPanel);

  }
  public GenericScatterGraph(XYSeries series, String xAxis, String yAxis) {
    super();

    XYDataset xyDataset = new XYSeriesCollection(series);

    JFreeChart chart =
        ChartFactory.createScatterPlot(
            "", // chart title
            xAxis, // x axis label
            yAxis, // y axis label
            null,
            PlotOrientation.VERTICAL,
            false, // include legend
            true, // tooltips
            false // urls
            );

    chart.setBackgroundPaint(Color.darkGray);
    plot = chart.getXYPlot();
    plot.setDataset(0, xyDataset);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    // Shape cross = ShapeUtilities.createDiamond(0.5f);
    Shape cross = ShapeUtilities.createDiagonalCross(0.5f, 0.5f);
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, new Color(252, 141, 89));
    renderer.setSeriesShape(0, cross);

    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickLabelPaint(Color.white);
    domainAxis.setLabelPaint(Color.white);

    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setTickLabelPaint(Color.white);
    rangeAxis.setLabelPaint(Color.white);

    chartPanel = new ChartPanel(chart);
    chartPanel.setSize(100, 800);

    setLayout(new BorderLayout());
    add(chartPanel, BorderLayout.CENTER);
    setBackground(Color.black);

    chartPanel.revalidate();
    setVisible(true);
  }
Exemple #7
0
  private JFreeChart createScatChart(
      BufferedImage image, PaintScale ps, int plotWidth, int plotHeigh) {
    JFreeChart chart_temp =
        ChartFactory.createScatterPlot(
            null,
            null,
            null,
            new XYSeriesCollection(),
            PlotOrientation.VERTICAL,
            false,
            false,
            false);
    chart_temp.getXYPlot().getRangeAxis().setInverted(true);
    chart_temp.setBackgroundPaint(JFreeChart.DEFAULT_BACKGROUND_PAINT);
    XYDataImageAnnotation ann = new XYDataImageAnnotation(image, 0, 0, plotWidth, plotHeigh, true);
    XYPlot plot = (XYPlot) chart_temp.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    plot.getRenderer().addAnnotation(ann, Layer.BACKGROUND);
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);
    xAxis.setVisible(false);
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);
    yAxis.setVisible(false);

    NumberAxis scaleAxis = new NumberAxis();
    scaleAxis.setAxisLinePaint(Color.black);
    scaleAxis.setTickMarkPaint(Color.black);
    scaleAxis.setRange(ps.getLowerBound(), ps.getUpperBound());
    scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 9));
    PaintScaleLegend legend = new PaintScaleLegend(ps, scaleAxis);
    legend.setAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    legend.setMargin(new RectangleInsets(5, 5, 5, 5));
    legend.setStripWidth(10);
    legend.setPosition(RectangleEdge.RIGHT);
    legend.setBackgroundPaint(chart_temp.getBackgroundPaint());
    chart_temp.addSubtitle(legend);

    return chart_temp;
  }
  ScatterPlotPanel(TopComponent parentDialog, String helpId) {
    super(parentDialog, helpId, CHART_TITLE, false);
    userSettingsMap = new HashMap<>();
    productRemovedListener =
        new ProductManager.Listener() {
          @Override
          public void productAdded(ProductManager.Event event) {}

          @Override
          public void productRemoved(ProductManager.Event event) {
            final UserSettings userSettings = userSettingsMap.remove(event.getProduct());
            if (userSettings != null) {
              userSettings.dispose();
            }
          }
        };

    xAxisRangeControl = new AxisRangeControl("X-Axis");
    yAxisRangeControl = new AxisRangeControl("Y-Axis");
    scatterPlotModel = new ScatterPlotModel();
    bindingContext = new BindingContext(PropertyContainer.createObjectBacked(scatterPlotModel));
    scatterpointsDataset = new XYIntervalSeriesCollection();
    acceptableDeviationDataset = new XYIntervalSeriesCollection();
    regressionDataset = new XYIntervalSeriesCollection();
    r2Annotation = new XYTitleAnnotation(0, 0, new TextTitle(""));
    chart =
        ChartFactory.createScatterPlot(
            CHART_TITLE, "", "", scatterpointsDataset, PlotOrientation.VERTICAL, true, true, false);
    chart.getXYPlot().setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    createDomainAxisChangeListener();
    final PropertyChangeListener userSettingsUpdateListener =
        evt -> {
          if (getRaster() != null) {
            final VectorDataNode pointDataSourceValue = scatterPlotModel.pointDataSource;
            final AttributeDescriptor dataFieldValue = scatterPlotModel.dataField;
            final UserSettings userSettings = getUserSettings(getRaster().getProduct());
            userSettings.set(getRaster().getName(), pointDataSourceValue, dataFieldValue);
          }
        };

    bindingContext.addPropertyChangeListener(PROPERTY_NAME_DATA_FIELD, userSettingsUpdateListener);
    bindingContext.addPropertyChangeListener(
        PROPERTY_NAME_POINT_DATA_SOURCE, userSettingsUpdateListener);
  }
 public static void main(String args[]) {
   SampleXYDataset2 samplexydataset2 = new SampleXYDataset2();
   JFreeChart jfreechart =
       ChartFactory.createScatterPlot(
           "Scatter Plot Demo",
           "X",
           "Y",
           samplexydataset2,
           PlotOrientation.VERTICAL,
           true,
           true,
           false);
   jfreechart.setBackgroundPaint(Color.white);
   XYPlot xyplot = (XYPlot) jfreechart.getPlot();
   NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis();
   numberaxis.setAutoRangeIncludesZero(false);
   try {
     ChartRenderingInfo chartrenderinginfo =
         new ChartRenderingInfo(new StandardEntityCollection());
     File file = new File("scatter100.png");
     ChartUtilities.saveChartAsPNG(file, jfreechart, 600, 400, chartrenderinginfo);
     File file1 = new File("scatter100.html");
     BufferedOutputStream bufferedoutputstream =
         new BufferedOutputStream(new FileOutputStream(file1));
     PrintWriter printwriter = new PrintWriter(bufferedoutputstream);
     printwriter.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"");
     printwriter.println("\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
     printwriter.println(
         "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">");
     printwriter.println("<head><title>JFreeChart Image Map Demo</title></head>");
     printwriter.println("<body><p>");
     ImageMapUtilities.writeImageMap(printwriter, "chart", chartrenderinginfo);
     printwriter.println(
         "<img src=\"scatter100.png\" width=\"600\" height=\"400\" usemap=\"#chart\" alt=\"scatter100.png\"/>");
     printwriter.println("</p></body>");
     printwriter.println("</html>");
     printwriter.close();
   } catch (IOException ioexception) {
     System.out.println(ioexception.toString());
   }
 }
  public static JFreeChartWrapper regressionChart() {

    DefaultTableXYDataset ds = new DefaultTableXYDataset();

    XYSeries series;

    series = new XYSeries("BAR", false, false);
    series.add(1, 1);
    series.add(2, 4);
    series.add(3, 6);
    series.add(4, 9);
    series.add(5, 9);
    series.add(6, 11);
    ds.addSeries(series);

    JFreeChart scatterPlot =
        ChartFactory.createScatterPlot(
            "Regression", "X", "Y", ds, PlotOrientation.HORIZONTAL, true, false, false);

    XYPlot plot = (XYPlot) scatterPlot.getPlot();

    double[] regression = Regression.getOLSRegression(ds, 0);

    // regression line points

    double v1 = regression[0] + regression[1] * 1;
    double v2 = regression[0] + regression[1] * 6;

    DefaultXYDataset ds2 = new DefaultXYDataset();
    ds2.addSeries("regline", new double[][] {new double[] {1, 6}, new double[] {v1, v2}});
    plot.setDataset(1, ds2);
    plot.setRenderer(1, new XYLineAndShapeRenderer(true, false));

    JFreeChart c = new JFreeChart(plot);

    return new JFreeChartWrapper(c);
  }
Exemple #11
0
  protected void createChart(JPanel plotPanel, String xAxisName, String yAxisName) {
    JFreeChart chart =
        ChartFactory.createScatterPlot(
            null, null, null, null, PlotOrientation.VERTICAL, false, true, false);
    chart.setBorderVisible(true);

    chartPanel = new ChartPanel(chart, true, true, true, true, true);
    chartPanel.setAutoscrolls(true);
    chartPanel.setMouseZoomable(false);

    GridBagConstraints gbl_chartPanel = new GridBagConstraints();
    gbl_chartPanel.anchor = GridBagConstraints.CENTER;
    gbl_chartPanel.insets = new Insets(3, 3, 3, 3);
    gbl_chartPanel.weightx = 1.0;
    gbl_chartPanel.weighty = 1.0;
    gbl_chartPanel.fill = GridBagConstraints.BOTH;
    gbl_chartPanel.gridx = 0;
    gbl_chartPanel.gridy = 1;
    plotPanel.add(chartPanel, gbl_chartPanel);

    XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer();
    lineRenderer.setUseFillPaint(true);
    lineRenderer.setBaseToolTipGenerator(
        new StandardXYToolTipGenerator(
            StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
            new DecimalFormat("0.00"),
            new DecimalFormat("0.00")));

    Stroke stroke =
        new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f);
    lineRenderer.setSeriesStroke(0, stroke);
    lineRenderer.setSeriesPaint(0, Color.RED);
    lineRenderer.setSeriesShape(0, ShapeUtilities.createDiamond((float) 2.5));

    lineRenderer.setLegendItemLabelGenerator(
        new StandardXYSeriesLabelGenerator() {
          private static final long serialVersionUID = 7593430826693873496L;

          public String generateLabel(XYDataset dataset, int series) {
            XYSeries xys = ((XYSeriesCollection) dataset).getSeries(series);
            return xys.getDescription();
          }
        });

    NumberAxis xAxis = new NumberAxis(xAxisName);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisName);
    yAxis.setAutoRangeIncludesZero(false);

    XYSeriesCollection lineDataset = new XYSeriesCollection();

    XYPlot plot = chart.getXYPlot();
    plot.setRangePannable(true);
    plot.setDomainPannable(true);
    plot.setDomainGridlinePaint(Color.DARK_GRAY);
    plot.setRangeGridlinePaint(Color.DARK_GRAY);
    plot.setBackgroundPaint(new Color(224, 224, 224));

    plot.setDataset(0, lineDataset);
    plot.setRenderer(0, lineRenderer);
    plot.setDomainAxis(0, xAxis);
    plot.setRangeAxis(0, yAxis);
    plot.mapDatasetToDomainAxis(0, 0);
    plot.mapDatasetToRangeAxis(0, 0);

    LegendTitle legend = new LegendTitle(plot.getRenderer());
    legend.setItemFont(new Font("Arial", 0, 10));
    legend.setPosition(RectangleEdge.TOP);
    chart.addLegend(legend);
  }
Exemple #12
0
  private JFreeChart display(
      String title, int height, int width, String category, List<Report> toolResults) {

    JFrame f = new JFrame(title);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // averages
    ArrayList<Double> averageFalseRates = new ArrayList<Double>();

    ArrayList<Double> averageTrueRates = new ArrayList<Double>();
    double averageFalseRate = 0;
    double averageTrueRate = 0;

    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries series = new XYSeries("Scores");
    for (int i = 0; i < toolResults.size(); i++) {
      Report toolReport = toolResults.get(i);
      OverallResult overallResults = toolReport.getOverallResults().getResults(category);
      series.add(
          overallResults.getFalsePositiveRate() * 100, overallResults.getTruePositiveRate() * 100);
      if (toolReport.isCommercial()) {
        averageFalseRates.add(overallResults.getFalsePositiveRate());

        averageTrueRates.add(overallResults.getTruePositiveRate());
      }
    }

    for (double d : averageFalseRates) {
      averageFalseRate += d;
    }
    averageFalseRate = averageFalseRate / averageFalseRates.size();

    for (double d : averageTrueRates) {
      averageTrueRate += d;
    }
    averageTrueRate = averageTrueRate / averageTrueRates.size();

    series.add(averageFalseRate * 100, averageTrueRate * 100);
    dataset.addSeries(series);
    afr = averageFalseRate;
    atr = averageTrueRate;

    chart =
        ChartFactory.createScatterPlot(
            title,
            "False Positive Rate",
            "True Positive Rate",
            dataset,
            PlotOrientation.VERTICAL,
            true,
            true,
            false);
    String fontName = "Arial";
    DecimalFormat pctFormat = new DecimalFormat("0'%'");

    theme = (StandardChartTheme) org.jfree.chart.StandardChartTheme.createJFreeTheme();
    theme.setExtraLargeFont(new Font(fontName, Font.PLAIN, 24)); // title
    theme.setLargeFont(new Font(fontName, Font.PLAIN, 20)); // axis-title
    theme.setRegularFont(new Font(fontName, Font.PLAIN, 16));
    theme.setSmallFont(new Font(fontName, Font.PLAIN, 12));
    theme.setRangeGridlinePaint(Color.decode("#C0C0C0"));
    theme.setPlotBackgroundPaint(Color.white);
    theme.setChartBackgroundPaint(Color.white);
    theme.setGridBandPaint(Color.red);
    theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0));
    theme.setBarPainter(new StandardBarPainter());
    theme.setAxisLabelPaint(Color.decode("#666666"));
    theme.apply(chart);

    XYPlot xyplot = chart.getXYPlot();
    NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis();
    NumberAxis domainAxis = (NumberAxis) xyplot.getDomainAxis();

    xyplot.setOutlineVisible(true);

    rangeAxis.setRange(-5, 109.99);
    rangeAxis.setNumberFormatOverride(pctFormat);
    rangeAxis.setTickLabelPaint(Color.decode("#666666"));
    rangeAxis.setMinorTickCount(5);
    rangeAxis.setTickUnit(new NumberTickUnit(10));
    rangeAxis.setAxisLineVisible(true);
    rangeAxis.setMinorTickMarksVisible(true);
    rangeAxis.setTickMarksVisible(true);
    rangeAxis.setLowerMargin(10);
    rangeAxis.setUpperMargin(10);
    xyplot.setRangeGridlineStroke(new BasicStroke());
    xyplot.setRangeGridlinePaint(Color.lightGray);
    xyplot.setRangeMinorGridlinePaint(Color.decode("#DDDDDD"));
    xyplot.setRangeMinorGridlinesVisible(true);

    domainAxis.setRange(-5, 105);
    domainAxis.setNumberFormatOverride(pctFormat);
    domainAxis.setTickLabelPaint(Color.decode("#666666"));
    domainAxis.setMinorTickCount(5);
    domainAxis.setTickUnit(new NumberTickUnit(10));
    domainAxis.setAxisLineVisible(true);
    domainAxis.setTickMarksVisible(true);
    domainAxis.setMinorTickMarksVisible(true);
    domainAxis.setLowerMargin(10);
    domainAxis.setUpperMargin(10);
    xyplot.setDomainGridlineStroke(new BasicStroke());
    xyplot.setDomainGridlinePaint(Color.lightGray);
    xyplot.setDomainMinorGridlinePaint(Color.decode("#DDDDDD"));
    xyplot.setDomainMinorGridlinesVisible(true);

    chart.setTextAntiAlias(true);
    chart.setAntiAlias(true);
    chart.removeLegend();
    chart.setPadding(new RectangleInsets(20, 20, 20, 20));
    xyplot.getRenderer().setSeriesPaint(0, Color.decode("#4572a7"));

    //        // setup item labels
    //        XYItemRenderer renderer = xyplot.getRenderer();
    //        Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 7.0f, 7.0f);
    //        for ( int i = 0; i < dataset.getSeriesCount(); i++ ) {
    //            renderer.setSeriesShape(i, circle);
    //            renderer.setSeriesPaint(i, Color.blue);
    //            String label = ""+((String)dataset.getSeries(i).getKey());
    //            int idx = label.indexOf( ':');
    //            label = label.substring( 0, idx );
    //            StandardXYItemLabelGenerator generator = new StandardXYItemLabelGenerator(label);
    //            renderer.setSeriesItemLabelGenerator(i, generator);
    //            renderer.setSeriesItemLabelsVisible(i, true);
    //            ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
    // TextAnchor.BASELINE_CENTER );
    //            renderer.setSeriesPositiveItemLabelPosition(i, position);
    //        }

    makeDataLabels(category, toolResults, xyplot);
    makeLegend(category, toolResults, 57, 48, dataset, xyplot);

    Stroke dashed =
        new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] {6, 3}, 0);
    for (XYDataItem item : (List<XYDataItem>) series.getItems()) {
      double x = item.getX().doubleValue();
      double y = item.getY().doubleValue();
      double z = (x + y) / 2;
      XYLineAnnotation score = new XYLineAnnotation(x, y, z, z, dashed, Color.blue);
      xyplot.addAnnotation(score);
    }

    //        // put legend inside plot
    //        LegendTitle lt = new LegendTitle(xyplot);
    //        lt.setItemFont(theme.getSmallFont());
    //        lt.setPosition(RectangleEdge.RIGHT);
    //        lt.setItemFont(theme.getSmallFont());
    //        XYTitleAnnotation ta = new XYTitleAnnotation(.7, .55, lt, RectangleAnchor.TOP_LEFT);
    //        ta.setMaxWidth(0.48);
    //        xyplot.addAnnotation(ta);

    // draw guessing line
    XYLineAnnotation guessing = new XYLineAnnotation(-5, -5, 105, 105, dashed, Color.red);
    xyplot.addAnnotation(guessing);

    XYPointerAnnotation worse =
        makePointer(75, 5, "Worse than guessing", TextAnchor.TOP_CENTER, 90);
    xyplot.addAnnotation(worse);

    XYPointerAnnotation better =
        makePointer(25, 100, "Better than guessing", TextAnchor.BOTTOM_CENTER, 270);
    xyplot.addAnnotation(better);

    XYTextAnnotation stroketext =
        new XYTextAnnotation("                     Random Guess", 88, 107);
    stroketext.setTextAnchor(TextAnchor.CENTER_RIGHT);
    stroketext.setBackgroundPaint(Color.white);
    stroketext.setPaint(Color.red);
    stroketext.setFont(theme.getRegularFont());
    xyplot.addAnnotation(stroketext);

    XYLineAnnotation strokekey = new XYLineAnnotation(58, 107, 68, 107, dashed, Color.red);
    xyplot.setBackgroundPaint(Color.white);
    xyplot.addAnnotation(strokekey);

    ChartPanel cp =
        new ChartPanel(
            chart, height, width, 400, 400, 1200, 1200, false, false, false, false, false, false);
    f.add(cp);
    f.pack();
    f.setLocationRelativeTo(null);
    //      f.setVisible(true);

    return chart;
  }