Hello
i have created an JFreeChart object with
JFreeChart LineChartObjectDistSum=ChartFactory.createLineChart
and everythign works fine - but just one smaller thing.
The final chart doesnt start on (0,0) but on (x,0) so the line
is moved to right .
Soo is there a way to move it to the left?
thx
Setting line chart to start with Zero
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: Setting line chart to start with Zero
The signature of the ChartFactory methoda that you are using indicates that you are using a CategoryPlot. With the default line renderer for a CategoryPlot, the line that is connecting the data points will start in the "center" of the category. I do not know a simple way to change that.
Re: Setting line chart to start with Zero
Hello
yes you are right. I am using the following
CategoryPlot plotDistSum= (CategoryPlot) LineChartObjectDistSum.getPlot();
plotDistSum.setBackgroundPaint(Color.white);
plotDistSum.setRangeGridlinePaint(Color.black);
plotDistSum.getRenderer().setSeriesPaint(0, Color.BLACK);
i would like to add a picture but doesnt know how to do here
yes you are right. I am using the following
CategoryPlot plotDistSum= (CategoryPlot) LineChartObjectDistSum.getPlot();
plotDistSum.setBackgroundPaint(Color.white);
plotDistSum.setRangeGridlinePaint(Color.black);
plotDistSum.getRenderer().setSeriesPaint(0, Color.BLACK);
i would like to add a picture but doesnt know how to do here
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: Setting line chart to start with Zero
An image is not needed. As explained above, the line renderer of a CategoryPlot will never start at the left edge of the plot. It will always connect the centers of the categories. Eventually (if you have multiple series and the useSeriesOffset falg is set to true), the line segments are slightly shifted away from the center, but never completely to the start or end of a category.Paul1309 wrote:i would like to add a picture but doesnt know how to do here
Re: Setting line chart to start with Zero
many thanks for you reply.
is there another way how to code it to get what i want?
is there another way how to code it to get what i want?
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: Setting line chart to start with Zero
Only by creating a new renderer.
You could extend org.jfree.chart.renderer.category.LineAndShapeRenderer and override the drawItem method. In your overriden method, replace the occurences of domainAxis.getCategoryMiddle with domainAxis.getCategoryStart.
But your requirement sounds a bit strange to me. I have the impression that you might be better off with an XYPlot. Maybe you can upload an image of your and post a link here.
You could extend org.jfree.chart.renderer.category.LineAndShapeRenderer and override the drawItem method. In your overriden method, replace the occurences of domainAxis.getCategoryMiddle with domainAxis.getCategoryStart.
But your requirement sounds a bit strange to me. I have the impression that you might be better off with an XYPlot. Maybe you can upload an image of your and post a link here.
Re: Setting line chart to start with Zero
ok thanks,
i will try a XYPlot and maybe it will fit my needs
Thanks for your help
i will try a XYPlot and maybe it will fit my needs
Thanks for your help
Re: Setting line chart to start with Zero
If i remember well it might be a way but i cant remember, i am pretty sure i saw it like 3 months ago or so.. i will look up for it
peliculas por mega
Greetings
peliculas por mega
Greetings