Dear all.
I have question how to add and remove value axes to chart in any order.
I am trying to use following code:
if I am adding dataset number N
setDataset(N,dataset);
setRangeAxis(N,new NumberAxis());
mapDatasetToRangeAxes(N,N);
if I am removing dataset :
setRangeAxis(N,null);
setDataset(N,null);
It works fine until I am deleting dataset with index 0. It throws NullPointerException in drawCrosshair methods.
How to fix it?
Removing Value Axes.
-
- Posts: 19
- Joined: Mon Sep 26, 2011 4:48 pm
- antibot: No, of course not.
-
- Posts: 19
- Joined: Mon Sep 26, 2011 4:48 pm
- antibot: No, of course not.
Re: Removing Value Axes.
Does anyone knows the answer?
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: Removing Value Axes.
Though you haven´t specified the exat location of the error: the API documentation is quite obvious:
In short: make sure tha the primary datase, renderer, and domain/range axes are all non-null.
Whyh do you need to set the axes to null?
The same can also happen when you set these object to null after creation of the plot.public XYPlot(XYDataset dataset,ValueAxis domainAxis,ValueAxis rangeAxis,XYItemRenderer renderer)
Creates a new plot with the specified dataset, axes and renderer. Any of the arguments can be null, but in that case you should take care to specify the value before using the plot (otherwise a NullPointerException may be thrown).
In short: make sure tha the primary datase, renderer, and domain/range axes are all non-null.
Whyh do you need to set the axes to null?
-
- Posts: 19
- Joined: Mon Sep 26, 2011 4:48 pm
- antibot: No, of course not.
Re: Removing Value Axes.
I need to add,remove dynamically graphs to the jfreechart.
If I adding graph I adding new dataset, put new renderer, put new axis.
If i removing graph I make dataset,renderer,axis is null.
However this approach is not working when I removing dataset with index 0.
If I adding graph I adding new dataset, put new renderer, put new axis.
If i removing graph I make dataset,renderer,axis is null.
However this approach is not working when I removing dataset with index 0.