0

everyone ! I;m working on a Highchart where it appends values to the chart for every 5 seconds time. I'm adding points like this,

series.addPoint([(new Date()).getTime(), xnum(n.PointValue)], true, true);

When adding a point I want to add the point with a different color (RED) based on some other property. Can anyone help me to add the point with a different color ? Thanks

1 Answers1

1

You could pass the color directly while adding a new point. Instead of array try using an object with a property 'color'.

series.addPoint({
y:(new Date()).getTime(), 
x:xnum(n.PointValue), 
color:some_condition?'red': 'blue'},
true, true);

An example pen https://codepen.io/samuellawrentz/pen/XYVBjR?editors=1010

samuellawrentz
  • 1,662
  • 11
  • 23
  • 1
    Beat me to it! Do note that this will only color the actual point red, if you want to color a line red, you need to use zones like explained here: https://stackoverflow.com/questions/47533162/highcharts-change-line-color-between-points/47533303#47533303 – ewolden Jun 19 '18 at 07:42