Adding flags to highcharts (not highstock) dynamic

2019-06-08 02:42发布

问题:

I found this jsfiddle and I'd like to implement that after the series had been created. often I let the user update the chart, I do this by sending array of float to the setData function of the series.

for example:

//Build the area values
for (var i = 0; i < area.length; i++)
{
    areaValues.push(parseFloat(area[i]));
}

chart.series[2].setData(areaValues,false);
chart.redraw();

Is there any way to add flags before the redraw without recreating the chart?

回答1:

The problem is in your data format - for flags should be this one:

{
    x: 9,
    title: 'I',
    text: 'Information'
}

Not just a number. You can achieve what you need in a two ways, or by setting new data, or adding new series, see example of both: http://jsfiddle.net/sH777/180/