Changing Line color -XY Line chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
ranyeng
Posts: 13
Joined: Fri May 22, 2009 6:53 am

Changing Line color -XY Line chart

Post by ranyeng » Fri May 22, 2009 7:00 am

Please I need your help...

The following is my line chard part of the code:

final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
final String series1 = xyLabel;
final JFreeChart chart = ChartFactory.createLineChart(
title, // chart title
xLabel, // domain axis label
yLabel, // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips
false // urls
);

chart.setBackgroundPaint(new Color(249, 231, 236));

How can I set the color of the line?


Thanks in advance

regards,
Ranjan Yengkhom

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Changing Line color -XY Line chart

Post by david.gilbert » Fri May 22, 2009 7:39 am

Code: Select all

CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.getRenderer().setSeriesPaint(0, Color.RED);
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

ranyeng
Posts: 13
Joined: Fri May 22, 2009 6:53 am

Re: Changing Line color -XY Line chart

Post by ranyeng » Fri May 22, 2009 8:08 am

Thanks David..

Locked