问题
I have a highstock chart and will add and remove series one by one as the user selects different checkboxes. Each series has it's own pre-defined color and for each series I will also add a series to the navigator with the same color using code inspired from https://highcharts.uservoice.com/forums/55896-highcharts-javascript-api/suggestions/2361925-allow-navigator-to-have-multiple-data-series.
Only the first navigator series is automatically handled by highstock (the rest I handle programmatically) and I'd like to change its color once it is drawn to be identic to the color of the user-selected series. I tried several things but non of them work: http://jsfiddle.net/ezoeetvf/2/
myChart.addSeries({
name : 'AAPL',
color: "#ff3300",
data : data,
tooltip: {
valueDecimals: 2
}
}, true);
// series 1 is the auto-added navigator
console.log(myChart.series[1].name);
// trying set it's color in various ways
myChart.series[1].color = "#ff3300";
myChart.series[1].options.color = "#ff3300";
myChart.series[1].options.lineColor = "#ff3300";
How can I have the navigator series to be the same color as the first series, which I am adding dynamically?
回答1:
Grzegorz Blachliński comment above did the job. I ended up with
myChart.series[1].update({color:"#55FF00" });
Thanks.
来源:https://stackoverflow.com/questions/39265877/change-color-of-highstock-navigator-to-be-identic-to-first-series