The community of Analytics developers are invited to follow and participate in the developer network.
OpenText technical experts collaborate with supported customers and partners in the Magellan product area.
OpenText technical experts collaborate with supported customers and partners in the Magellan product area.
Pie Chart: Color by Categories
Hi, I'm using a multiple pie charts and the slices are colored based on what the value of the category series is. This is working as intended, but the question I have is can I specify the color based on the value of the category.
For instance, my current slices are 'Agree', 'Disagree' 'Strongly Agree'. Depending on the question, one of these responses may not be in the chart. So a blue slice in Chart A could mean 'Agree', but a blue slice in Chart B could mean 'Disagree', since the slices only look for the category. Is there a way I can specify the coloring to say, if response='Agree' then blue slice, if response='Disagree' then red slice? With multiple charts on a page, users would more than likely get confused seeing the different colors representing the same values.
Thanks,
Bryan
For instance, my current slices are 'Agree', 'Disagree' 'Strongly Agree'. Depending on the question, one of these responses may not be in the chart. So a blue slice in Chart A could mean 'Agree', but a blue slice in Chart B could mean 'Disagree', since the slices only look for the category. Is there a way I can specify the coloring to say, if response='Agree' then blue slice, if response='Disagree' then red slice? With multiple charts on a page, users would more than likely get confused seeing the different colors representing the same values.
Thanks,
Bryan
0
Comments
<br />
Yes. Add this to each of your charts (replace the 'R', 'G', 'B' with the RGB color values)<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>function beforeDrawLegendItem( lerh, bounds, icsc )
{
var seriesValue = lerh.getLabel().getCaption().getValue();
var fill = lerh.getFill();
if( seriesValue == "Agree" )
fill.set( R, G, B, 255 );
if( seriesValue == "Disagree" )
fill.set( R, G, B, 255 );
if( seriesValue == "Strongly Disagree" )
fill.set( R, G, B, 255 );
}
function beforeDrawDataPoint( dph, fill, icsc )
{
if( dph.getBaseDisplayValue() == 'Agree' ){
fill.set( R, G, B, 255 );
if( dph.getBaseDisplayValue() == "Disagree" )
fill.set( R, G, B, 255 );
if( dph.getBaseDisplayValue() == "Strongly Disagree" )
fill.set( R, G, B, 255 );
}</pre>
<br />
Hope that helps,<br />
Rich
Thanks again,
Bryan
Regards,
Michael Williams
eSignLive Evangelism & Community Manager | eSignLive by VASCO
Find me on:
Twitter
Facebook
Blog
LinkedIn
eSignLive Developer Community
Email me:
Google: [email protected]
Bryan
@RichT By any chance can we use hexa codes for colors instead of RGB?
Hi Nayak,
You've responded to a pretty old thread, so you likely won't get a response from the people involved in this discussion.
To answer your question, no you can't use hex codes, but hex codes directly translate to RGB numeric values.
For example, indigo is #2E0854. To convert that to a syntax for the fill.set() command, you'd use parseInt("2E",16) for R, parseInt("08",16) for G, and parseInt("54",16) for B. The 16 is to inform the function that you're converting from base 16
Sr. Technical Support Specialist