Home
Analytics
Individually Setting Font Color in Series Labels
kpelzer29
Is there a way I can individually set the font color for series labels in a bar chart? The colors I have to use in the Series 1 Palette are light except the last color displayed is dark. It would be good if I could set the font color to black for all the series labels except make the last series label font color white to make the numbers easier to read.
Find more posts tagged with
Comments
mwilliams
In the beforeDrawDataPoint() function in the chart script, you can do:
fill.set(R,G,B);
Hope this helps.
kpelzer29
mwilliams,<br />
<br />
I tried that and the code modified the color for the bar. Is there a way I can individually set the font color for the number displayed inside the bar? Thank you!<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="73325" data-time="1297722703" data-date="14 February 2011 - 03:31 PM"><p>
In the beforeDrawDataPoint() function in the chart script, you can do:<br />
<br />
fill.set(R,G,B);<br />
<br />
Hope this helps.<br /></p></blockquote>
mwilliams
Oh! My mistake, I totally read that wrong. I thought you had the font colors set how you wanted and the color needed to change to see the font. So, you need to change the last bar's font color to be white and that's it?
kpelzer29
No problem. Correct - I was wondering if there is a way I can have the font color for all the bars black, but change the font color to white on one of the bars that is a dark color.<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="73394" data-time="1297810087" data-date="15 February 2011 - 03:48 PM"><p>
Oh! My mistake, I totally read that wrong. I thought you had the font colors set how you wanted and the color needed to change to see the font. So, you need to change the last bar's font color to be white and that's it?<br /></p></blockquote>
mwilliams
But you don't know what bar is going to be dark? In other words, you're not setting all of the colors manually, so you'd have to be able to figure out if the color was dark or not in script? Is this the case? If so, I'm not sure how easy that will be. I'd have to do some testing. If you wanted to make sure the colors were going to be lighter colors, you could make an array of colors and use it to assign the colors to your chart and legend. Let me know.
kpelzer29
I already know the colors for the Y Series Grouping are going to be: yellow, light blue, red, orange, and dark blue. I plan on setting the colors for the bars in the beforeDrawDataPoint function and the colors for the lengend in the beforeDrawLengendItem function. <br />
<br />
The numbers inside each bar with a black font color are easy to read against the yellow, light blue, red, and orange bars. The problem is the numbers in black are hard to read against the dark blue bars. It would be good if there was a way I could set the numbers to be black against the yellow, light blue, red, and orange bars, but change the numbers to white when displayed on a dark blue bar. <br />
<br />
Since I already know the colors and the order, is there a way I can set the font color on the yellow, light blue, red, and orange bars to be black and the numbers on the dark blue bars to be white?<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="73448" data-time="1297877205" data-date="16 February 2011 - 10:26 AM"><p>
But you don't know what bar is going to be dark? In other words, you're not setting all of the colors manually, so you'd have to be able to figure out if the color was dark or not in script? Is this the case? If so, I'm not sure how easy that will be. I'd have to do some testing. If you wanted to make sure the colors were going to be lighter colors, you could make an array of colors and use it to assign the colors to your chart and legend. Let me know.<br /></p></blockquote>
mwilliams
If you know the order of the colors, you could step through the bars and color the font with the following:
function beforeDrawDataPointLabel( dph, label, icsc )
{
label.getCaption().getColor().set(255,255,255)
}
kpelzer29
I was able to get it to work by knowing what value the bar represents. For example, if the bar I would like to have a font color of white represents the value "Test":<br />
<br />
<br />
function beforeDrawDataPointLabel( dph, label, icsc )<br />
{<br />
if (dph.getSeriesDisplayValue() == "Test")<br />
{<br />
label.getCaption().getColor().set(255,255,255);<br />
}<br />
}<br />
<br />
Thank you so much for your help!<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="73458" data-time="1297886394" data-date="16 February 2011 - 12:59 PM"><p>
If you know the order of the colors, you could step through the bars and color the font with the following:<br />
<br />
function beforeDrawDataPointLabel( dph, label, icsc )<br />
{<br />
label.getCaption().getColor().set(255,255,255)<br />
}<br /></p></blockquote>
mwilliams
Not a problem. Glad to help.