I am using JFreeChart in my java application.
Problem
I want to plot a XYAreaChart whose domain axis (x-axis) should scroll horizontally automatically when we start plotting the data.
I saw the same thing in TimeSeriesCharts but I don't want any timeSeriesChart. I just want the scrolling x-axis.
You'll need to create your own SlidingXYDataset that implements XYDataset in a manner similar to how SlidingCategoryDataset implements CategoryDataset.
Addendum: As noted in a comment, a typical implementation can be found here.
Related
I want to make a bar chart in JFreeChart that has a structure similar to the following:
As you can see, it starts with "Clay", then "Sand", then "Clay" again, and so on.
I did not find in the whole internet a similar chart for JFreeChart. Is there any possibility to do something like this in this tool?
I'm using JFreeChart 1.0.14 in Swing application.
I have chart with multiple Y-Axis and I want to change source Axis for chart grid lines. Now them always base on one axis, even if I hide it.
I know there are few similar questions but they are old and I wonder if solution exists now.
If it doesn't what is the best workaround in this task?
For example:
http://www.jfree.org/phpBB2/viewtopic.php?f=3&t=27885&sid=c4c609f3809d29a46e3e2bbccfac361e
There is still no way to do it natively unfortunately.
I was suggested to override XYPlot's drawRangeGridLines method, but I decided to go another way: to make it works you only need to change axis order because grid lines always depend on 0th axis (and its dataset). Make sure your axis has 0th index in plot axis collection.
NumberAxis axis = new NumberAxis(name);
plot.setRangeAxis(0, axis);
I think it's easiest way at this moment.
Context: Java swing application generating a chart using JFreeChart. The chart is a CombinedDomainXYPlot (using XYBarRenderer) that on the X-axis has a timeline based on PeriodAxis.
Problem: I can't remove the vertical gridlines (not the tickmarks related to the time periods) that separate days.
What I tried is: combinedPlot.setDomainGridlinesVisible(false) which doesn't work (see image below).
Any hint would be more than welcome!
Thx,
Thomas
After some additional research I found the mistake: for CombinedDomainXYPlot the setDomainGridlinesVisible(false) needs to be called on the subplots:
List<XYPlot> subplots = (List<XYPlot>) combinedPlots.getSubplots();
for (XYPlot p:subplots) p.setDomainGridlinesVisible(false);
I would like to be able to drag the plot area to be able to move the x-axis across.
Is this possible?
It certainly is. Check out this Java Web Start demo. The XYPlot (for example) supports the Pannable interface.
I'm using a combined plot composed of 2 graph which share the same X axis (by sharing, I mean, the timeframe is the same for the two graph). The upper graph is a regular timeseries while the lower chart is a barchart. I would like to display a crosshair on the combined chart as a whole... Right now I can display crosshair only on each graph separately even thought I have specify on the combined plot that I wanted to display the crosshair. To be more explicit, I can't synchronise both crosshair... Any idea on how to achieve that ?
thanks
It would appear to work if you use a shared domain axis, as discussed here and as shown in CrosshairDemo2? In addition, an sscce might help clarify your usage.