I also have a gradient on each bar that can vary by point. Based on help I got on this forum, I defined a "series.getFill" function that looks up the gradient colors from an array and returns them with:
Code: Select all
function getFill(index, f) {
var gr = f ? f.gradient : null; // f is null when called for the legend symbol
if (gr && gr.visible) {
gr.colors = SeriesColors[this.indices[index]];
gr.stops = [0, 1];
}
return null;
}
Code: Select all
function getFill(series, index, f) {
var gr = f ? f.gradient : null;
if (gr && gr.visible) {
gr.colors = SeriesColors[this.indices[index]];
gr.stops = [0, 1];
} else {
if (!f) { // when called to get color for legend symbol; index is 0-3
return SeriesColors[index+1][0];
} else { // for bar color
f.fill = SeriesColors[this.indices[index]][0];
}
}
return null;
}
So my problem is how to control the colors of the bars and the legend text independently.
I've attached an example. I removed the patterns so you don't need any additional files. When you first load the page the legend colors are fine (blue, gray, orange, green), but if you do anything to redraw the legend (resize, mouse over the bars) the text turns red (the color of the last points).
Thanks,
Jim