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)
how to get series palette from bar chart?
habeeb1985
hi,
i am using the latest version of birt that is 2.6.2,
i used this code of retrieving series palette of the pie chart and it is working
sd = chart.getSeriesDefinitions().get(0);
sd.getSeriesPalette().getEntries()
but the same code is not working for the bar chart.
Do you have a solution to get the series palette of the bar chart?
Find more posts tagged with
Comments
mwilliams
At first glance, that looks like it should be correct. Do you get an error?
habeeb1985
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="76516" data-time="1304357079" data-date="02 May 2011 - 10:24 AM"><p>
At first glance, that looks like it should be correct. Do you get an error?<br /></p></blockquote>
yes, with bar chart,i got this error:<br />
<br />
TypeError: Cannot find function getSeriesDefinitions in object org.eclipse.birt.chart.model.impl.ChartWithAxesImpl@9437ae (version: <unset>, type: Bar Chart, subType: Stacked, dimension: Two_Dimensional, script: importPackage( Packages.org.eclipse.birt.chart.model.attribute.impl);<br />
<br />
So seems that the function of getSeriesDefinitions() is not found in org.eclipse.birt.chart.model.impl.ChartWithAxesImpl . So what is the solution ? How can we retrieve the series palette for bar charts?
mwilliams
Here's some script that I found that shows how to clear the series palette and add your own list of colors:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
SeriesDefinition sd = SeriesDefinitionImpl.create();
final Fill[] fiaBase = {
ColorDefinitionImpl.ORANGE( ),
GradientImpl.create( ColorDefinitionImpl.create( 225, 225, 255 ),
ColorDefinitionImpl.create( 255, 255, 225 ),
-35,
false ),
ColorDefinitionImpl.CREAM( ),
ColorDefinitionImpl.RED( ),
ColorDefinitionImpl.GREEN( ),
ColorDefinitionImpl.BLUE( ).brighter( ),
ColorDefinitionImpl.CYAN( ).darker( ),
};
sd.getSeriesPalette( ).getEntries( ).clear( );
for ( int i = 0; i < fiaBase.length; i++ )
{
sd.getSeriesPalette( ).getEntries( ).add( fiaBase[i] );
}
</pre>
<br />
Maybe this will help.
habeeb1985
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="76526" data-time="1304365099" data-date="02 May 2011 - 12:38 PM"><p>
Here's some script that I found that shows how to clear the series palette and add your own list of colors:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
SeriesDefinition sd = SeriesDefinitionImpl.create();
final Fill[] fiaBase = {
ColorDefinitionImpl.ORANGE( ),
GradientImpl.create( ColorDefinitionImpl.create( 225, 225, 255 ),
ColorDefinitionImpl.create( 255, 255, 225 ),
-35,
false ),
ColorDefinitionImpl.CREAM( ),
ColorDefinitionImpl.RED( ),
ColorDefinitionImpl.GREEN( ),
ColorDefinitionImpl.BLUE( ).brighter( ),
ColorDefinitionImpl.CYAN( ).darker( ),
};
sd.getSeriesPalette( ).getEntries( ).clear( );
for ( int i = 0; i < fiaBase.length; i++ )
{
sd.getSeriesPalette( ).getEntries( ).add( fiaBase[i] );
}
</pre>
<br />
Maybe this will help.<br /></p></blockquote>
<br />
Hi mwilliams and All,<br />
<br />
After some search , I found that there are three main types of charts in birt:<br />
<br />
1)ChartWithoutAxesImpl that supports pie charts.<br />
2)DialChartImpl that supports meter charts.<br />
3)ChartWithAxesImpl that supports area, bar, bubble, cone, difference, Gantt, line, pyramid, scatter, <br />
stock, and tube charts.<br />
<br />
The ChartWithAxesImpl (that includes bar charts) implements the following features:<br />
<br />
Axes<br />
Wall Fill<br />
Floor Fill<br />
Orientation<br />
Unit Spacing<br />
Rotation<br />
Reverse Category<br />
Study Layout<br />
<br />
and doesn't implement Series Definitions feature.<br />
<br />
And ChartWithoutAxesImpl (that includes pie charts) implements the following features:<br />
<br />
Series Definitions<br />
Min Slice<br />
Min Slice Percent<br />
Min Slice Label<br />
Coverage<br />
<br />
So this is the problem that the bar chart doesn't support to get the series definitions and then to get the series palette.<br />
<br />
Please see the following links of API of ChartWithoutAxesImpl, ChartWithAxesImpl.<br />
<br />
<a class='bbc_url' href='
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.birt.chart.doc.isv/chart/api/org/eclipse/birt/chart/model/impl/ChartWithoutAxesImpl.html'>http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.birt.chart.doc.isv/chart/api/org/eclipse/birt/chart/model/impl/ChartWithAxesImpl.html</a><br
/>
<br />
<a class='bbc_url' href='
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.birt.chart.doc.isv/chart/api/org/eclipse/birt/chart/model/impl/ChartWithAxesImpl.html'>http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.birt.chart.doc.isv/chart/api/org/eclipse/birt/chart/model/impl/ChartWithAxesImpl.html</a><br
/>
<br />
<br />
Please do you have a solution or workaround for this limit on bar charts or ChartWithAxesImpl to make it implement the series definition, so we can retrieve the series definitions and series palette?<br />
<br />
And thanks for your best efforts.
mwilliams
I got this report from a colleague of mine. Take a look in the beforeGeneration method. It shows how to replace the entire palette. There is also some code that is commented out that shows how to just add a couple values.
nairwen
<blockquote class="ipsBlockquote" data-author="mwilliams" data-cid="76676" data-time="1304694822"><div><p>I got this report from a colleague of mine. Take a look in the beforeGeneration method. It shows how to replace the entire palette. There is also some code that is commented out that shows how to just add a couple values.</p></div></blockquote><p>Hi,</p><p> </p><p>I have the same problem, where can I see the code which shows how to replace the palette?</p><p> </p><p>Thanks,</p><p>Nair</p>
mwilliams
<p>Looks like the file got stripped out in one of the recent upgrades. Here it is again. Hope this helps.</p><p> </p><p> </p>