Hi,
I've create a simple jfreechart XY with a dataset that i create with
...
series1.add(10.0, 1.0);
series1.add(50.0, 3.0);
...
series2.add(1.0, 2.0);
series2.add(50.0, 4.0);
...
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(series1);
dataset.addSeries(series2);
...
JFreeChart chart = ChartFactory.createLineXYChart("Calcul ",
"X", "Y", dataset,
true,
true,
false);
I would like keep in my X axis the values put with series.add...
10,50 ... and not have a auto range for the X axis.
I try with
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxi();
rangeAxis.setAutoRangeIncludesZero(false);
but it does not work !
thans a lot for your help.
how to keep data from Dataset in the X axis ?
Re: how to keep data from Dataset in the X axis ?
I use the term 'range axis' to refer to the Y axis, and 'domain axis' to refer to the X axis.
But the X axis should automatically set a range to match the x values in your data, with a margin of 5% of the overall range added to each end of the axis. Is it just the margins that are the trouble, or is it perhaps the tick labels (which are not directly related to the data points)?
Regards,
Dave Gilbert
But the X axis should automatically set a range to match the x values in your data, with a margin of 5% of the overall range added to each end of the axis. Is it just the margins that are the trouble, or is it perhaps the tick labels (which are not directly related to the data points)?
Regards,
Dave Gilbert
Re: how to keep data from Dataset in the X axis ?
Thanks a lot. I see the use of 'domain axis' ...
But my in my X axis there are displayed
0 25 50 75 100 125 .... 275
instead of my input data point i want
0 1 2 3 ... 10 14 21 28 35 42 56 91 118 119 270
the 21 points that contributes to draw my chart...
so i don't kwon why ?
But my in my X axis there are displayed
0 25 50 75 100 125 .... 275
instead of my input data point i want
0 1 2 3 ... 10 14 21 28 35 42 56 91 118 119 270
the 21 points that contributes to draw my chart...
so i don't kwon why ?
Re: how to keep data from Dataset in the X axis ?
The X axis is just a continuous line, and JFreeChart will put labels at regular intervals to give it a scale...like a ruler.
The axis doesn't attempt to draw labels at each x-value from your dataset, because your x-values may be irregular, clustered, or otherwise unsuitable for generating labels that don't overlap.
But if it is something you really want, you could subclass the axis, and modify the refreshTicks(...) method to generate whatever labels you want.
Regards,
Dave Gilbert
The axis doesn't attempt to draw labels at each x-value from your dataset, because your x-values may be irregular, clustered, or otherwise unsuitable for generating labels that don't overlap.
But if it is something you really want, you could subclass the axis, and modify the refreshTicks(...) method to generate whatever labels you want.
Regards,
Dave Gilbert
x axis labels
i have values in dataset for axis as 1,2,3,4,5,6,7,8,9.......100
i need to plot all the values in LineChart on x-axis
It is plotting correctly , but it is also showing all the values on the x-axis as label ,
but due to less space label are overlapping.
i don't want all the labels on the x-axis i want labels to come as
1, 10, 20,30,40,50...100
by using LineCharts itself.
I have tried a lot .
Can anybody help me , it's very urgent
i need to plot all the values in LineChart on x-axis
It is plotting correctly , but it is also showing all the values on the x-axis as label ,
but due to less space label are overlapping.
i don't want all the labels on the x-axis i want labels to come as
1, 10, 20,30,40,50...100
by using LineCharts itself.
I have tried a lot .
Can anybody help me , it's very urgent

-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
It sounds like you are using a CategoryPlot (and CategoryDataset) for your line chart, so your domain axis displays categories rather than values.
You'd be better to create a line chart based on the XYPlot class (using an XYDataset), then the domain axis is numerical, and the auto-tick selection mechanism will help you out. The createLineXYChart(...) in the ChartFactory class is the one to use, if you are using the ChartFactory class.
Regards,
Dave Gilbert
You'd be better to create a line chart based on the XYPlot class (using an XYDataset), then the domain axis is numerical, and the auto-tick selection mechanism will help you out. The createLineXYChart(...) in the ChartFactory class is the one to use, if you are using the ChartFactory class.
Regards,
Dave Gilbert