Show Indicator at last point on Highchart spline c

2019-02-20 14:15发布

I know how to show marker at last point like this.

When the data is dynamic, don't know how to mark the last point.

plotOptions: {
        column: {
          stacking: 'normal'
        },
        spline: {
          marker: {
            enabled: true
          }
        }
      }

标签: highcharts
1条回答
放荡不羁爱自由
2楼-- · 2019-02-20 14:53

When you are adding new points dynamically you can simultaneously remove the marker from the current last point (Point.update), while adding a new point with marker enabled (Series.addPoint).

For example (JSFiddle):

// get the series
series = $('#container').highcharts().series[0]

// remove marker from last point
series.points[series.points.length-1].update({
    marker: {
        enabled:false
    }
}, false);

// add new point with marker
series.addPoint({
    y: Math.random()*100,
    marker: {
        enabled: true
    }
});

The false parameter for the Point.update is to prevent redrawing, as you are going to redraw after the Series.addPoint anyway, which should save some processing.

查看更多
登录 后发表回答