ajkush
ajkush

Reputation: 589

I want to enable display xy coordinates on XYSplineRenderer chart

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);

Upvotes: 1

Views: 2773

Answers (1)

trashgod
trashgod

Reputation: 205785

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);

Upvotes: 1

Related Questions