Sender: |
|
Date: |
Thu, 27 Aug 2009 05:14:48 -0400 |
MIME-version: |
1.0 |
Reply-To: |
|
Content-type: |
text/plain; charset=ISO-8859-1; format=flowed |
Subject: |
|
From: |
|
In-Reply-To: |
|
Content-transfer-encoding: |
7bit |
Comments: |
|
Parts/Attachments: |
|
|
Joerg Hoehne wrote:
> I'd like to set the color of the plotted line which works fine with the code below.
>
> TimeSeriesChartGenerator chart;
> XYSeries series[];
>
> .....
> series[i] = new XYSeries("food source" + (i + 1), false);
> chart.addSeries(series[i], null);
>
> // get the series for the current index
> TimeSeriesAttributes tsa = (TimeSeriesAttributes) chart.getSeriesAttributes(i);
>
> // every series has its own plotter
> XYPlot plot = tsa.getPlot();
> // the first renderer is the one for the line so it is fine
> XYItemRenderer r = plot.getRenderer(0);
> r.setSeriesPaint(i, foodSources[i].getColor());
>
> tsa.buildAttributes();
>
> But the LabelledList (below the "Save as PDF"-button) on the left of the TimeSeriesChartGenerator
> does not reflect the current color choice so I've added the tas.buildAttributes() line in the code.
> Now I see the current color but I the fields are doubled (the fields Series, Color, Width, Dash and
> Stretch). I have first to remove the old items from the list but I find no method for this one.
>
> My question: Is there any way to create the series and add it with a given color set?
I admit, it's not obvious. But instead of manually getting the plot and
renderer etc., how about this:
tsa.setStrokeColor(foodSources[i].getColor());
I'm guessing that should work right. If not, Gabriel should be able to
hack something up for you.
Sean
|
|
|