Histogram Overlay

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
dafaro
Posts: 5
Joined: Mon Dec 12, 2016 10:58 pm
antibot: No, of course not.

Histogram Overlay

Post by dafaro » Thu Dec 15, 2016 9:22 pm

There are a number of examples in the demo that have various Overlaid plots. I have not been able to successfully try an overlay of a line chart onto a histogram.

If I am starting with ChartFactory.createHistogram can I add the line chart to the histogram with plot.setDataset(1, addedDataset); like in the demos?

Thanks!

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: Histogram Overlay

Post by John Matthews » Fri Dec 16, 2016 12:25 pm

If I recall correctly, you'll also need a second renderer for the overlaid dataset. As your factory uses an XYBarRenderer, I'd look at an XYItemRenderer.

dafaro
Posts: 5
Joined: Mon Dec 12, 2016 10:58 pm
antibot: No, of course not.

Re: Histogram Overlay

Post by dafaro » Fri Dec 16, 2016 8:06 pm

I am using an XYLineAndShapeRenderer but nothing additional is displaying. The additional dataset is populated in the XYplot, just not displaying... so does that mean it is likely something to do with the renderer?

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: Histogram Overlay

Post by John Matthews » Sat Dec 17, 2016 2:12 am

You should be able to test them separately by commenting out one or the other; then check that the indices are correct.

Locked