1

Want to display XY cordinates at Red circle on image

I want to enable display xy coordinates on XYSplineRenderer chart.

        NumberAxis numberaxis = new NumberAxis("X");
        numberaxis.setAutoRangeIncludesZero(false);
        NumberAxis numberaxis1 = new NumberAxis("Y");
        numberaxis1.setAutoRangeIncludesZero(false);
        XYSplineRenderer xysplinerenderer = new XYSplineRenderer();

        XYPlot xyplot = new XYPlot(data1, numberaxis, numberaxis1,
                xysplinerenderer);
        xyplot.setBackgroundPaint(Color.lightGray);
        xyplot.setDomainGridlinePaint(Color.white);
        xyplot.setRangeGridlinePaint(Color.white);

        xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D));
        JFreeChart jfreechart = new JFreeChart("XYSplineRenderer",
                JFreeChart.DEFAULT_TITLE_FONT, xyplot, true);
        addChart(jfreechart);
ajkush
  • 587
  • 2
  • 11
  • 25

1 Answers1

1

You can use a tooltip generator, as shown here, or use a label generator, as shown here. Either one or both can be added to your renderer.

Addendum: As noted in comments, the following code solved the problem:

StandardXYToolTipGenerator ttG =
    new StandardXYToolTipGenerator("{1},{2}", format, format);
xysplinerenderer.setBaseToolTipGenerator(ttG);
Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • I am trying code :- StandardXYToolTipGenerator ttG = new StandardXYToolTipGenerator( "{1},{2}", format, format); xysplinerenderer.setBaseToolTipGenerator(ttG); but it is also not working. – ajkush Oct 11 '12 at 21:32
  • I know it works for the parent, `XYLineAndShapeRenderer`. Can you adapt, as seen [here](http://www.jfree.org/phpBB2/viewtopic.php?f=3&t=115213), or edit your question to include an [sscce](http://sscce.org/)? – trashgod Oct 11 '12 at 23:44
  • Thanks, It is solved with code. Thanks again for your help. StandardXYToolTipGenerator ttG = new StandardXYToolTipGenerator( "{1},{2}", format, format); xysplinerenderer.setBaseToolTipGenerator(ttG); – ajkush Oct 16 '12 at 21:05
  • what should be the format in this code if the value in y-axis is float and the value in x-axis is SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")? @trashgod – Forrest Mar 15 '17 at 09:31
  • Out of context, I'm not sure; please see [ask] a question that includes your [mcve]. – trashgod Mar 15 '17 at 11:37