Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Consistent colors in line chart
Ricey
Hi<br />
<br />
I have some data sets that don't always return results for the same series. I'd like the colors of the series in a line chart to be consistent.<br />
<br />
I done some searching and found several scripts but most of them seem to have been created for bar charts and don't quite work with line charts. The following script changes the colors in the legend but not the actual lines on the chart:<br />
<br />
<blockquote class='ipsBlockquote' ><p>function beforeDrawLegendItem(lerh,bounds,icsc){label=lerh.getLabel();var labelString=label.getCaption().getValue();var fill=lerh.getFill();<br />
if (labelString=="Blah"){fill.set(8,72,151);}<br />
else if (labelString=="Blah"){fill.set(10,14,43);}<br />
else if (labelString=="Blah"){fill.set(255,102,0);}<br />
else if (labelString=="Blah"){fill.set(135,0,95);}<br />
else if (labelString=="Blah"){fill.set(126,205,255);} <br />
else if (labelString=="Blah"){fill.set(200,20,255);}<br />
else if (labelString=="Blah"){fill.set(200,0,0);}}</p></blockquote>
<br />
Any ideas?
Find more posts tagged with
Comments
Ricey
Think I cracked it..<br />
<br />
<blockquote class='ipsBlockquote' ><p>
function beforeDrawSeries(series,isr,icsc){<br />
importPackage(Packages.org.eclipse.birt.chart.model.component.impl);<br />
importPackage(Packages.org.eclipse.birt.chart.model.attribute);<br />
var seriesID = series.getSeriesIdentifier();<br />
if (seriesID == "Blah") series.getLineAttributes().getColor().set(8,72,151);<br />
else if (seriesID == "Blah") series.getLineAttributes().getColor().set(10,14,43);<br />
else if (seriesID == "Blah") series.getLineAttributes().getColor().set(255,102,0);<br />
else if (seriesID == "Blah") series.getLineAttributes().getColor().set(135,0,95);<br />
else if (seriesID == "Blah") series.getLineAttributes().getColor().set(126,205,255);<br />
else if (seriesID == "Blah") series.getLineAttributes().getColor().set(200,20,255);<br />
else if (seriesID == "Blah") series.getLineAttributes().getColor().set(200,0,0);}</p></blockquote>
<br />
The "Use Series Palette as Line Color" setting also needs to be turned off.
mwilliams
Sorry for the delay in response. Had a 3 day weekend.
Glad you found the solution without too much trouble it seems. Let us know whenever you have questions!