Dynamically draw marker on last point in highcharts

前端 未结 1 666
故里飘歌
故里飘歌 2021-01-06 07:42

I want to draw a marker on the last point. Data source is dynamic. Have a look at following code

$(function() {

    $(\"#btn\").click(function() {
        v         


        
相关标签:
1条回答
  • 2021-01-06 07:46
     $("#btn").click(function() {
        var l = chart.series[0].points.length;
        var p = chart.series[0].points[l - 1];
        p.update({
            marker: {
                symbol: 'square',
                fillColor: "#A0F",
                lineColor: "A0F0",
                radius: 5
            }
        });
        a = 1;
    
    });
    

    solution @ http://jsfiddle.net/jugal/zJZSx/

    Also tidied up your code a little, removed the removal of point before adding one at the end, highcharts supports it inbuilt with the third param to addPoint as true, which denotes shift series, which removes first point and then adds the given point.

    I didn't really understand what the a vv etc were, but well i didn't bother much either. I think this is enough based on what you asked for.

    0 讨论(0)
提交回复
热议问题