dynamically assign symbols for scatter - Javascript highcharts

Javascript examples for highcharts:Scatter Chart

Description

dynamically assign symbols for scatter

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Demo</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <div id="container" style="min-width: 310px; height: 400px; max-width: 800px; margin: 0 auto"></div> 
      <script type="text/javascript">
var sampleData = [{/*from   w ww .j  a v  a 2 s  .  com*/
  "x": 0.38,
  "y": 0.55,
  "date": "03-09-2017",
  "num1": 32,
  "num2": 0,
  "symbol_num": 1,
  "symbol": "triangle"
}, {
  "x": 0.52,
  "y": 0.66,
  "date": "03-09-2017",
  "num1": 31,
  "num2": 0,
  "symbol_num": 1,
  "symbol": "triangle"
}, {
  "x": 0.38,
  "y": 0.42,
  "date": "03-09-2017",
  "num1": 33,
  "num2": 0,
  "symbol_num": 1,
  "symbol": "triangle"
}, {
  "x": 0.29,
  "y": 0.39,
  "date": "03-21-2017",
  "num1": 32,
  "num2": 0,
  "symbol_num": 1,
  "symbol": "triangle"
}, {
  "x": 0.5,
  "y": 0.56,
  "date": "03-21-2017",
  "num1": 31,
  "num2": 0,
  "symbol_num": 1,
  "symbol": "triangle"
}, {
  "x": 0.04,
  "y": 0.15,
  "date": "03-21-2017",
  "num1": 33,
  "num2": 0,
  "symbol_num": 1,
  "symbol": "triangle"
}];
Highcharts.chart('container', {
  chart: {
    type: 'scatter',
    events: {
      load: function() {
        var chart = this,
          points = chart.series[0].points;
        points.forEach(function(point, index) {
          point.update({
            marker: {
              symbol: sampleData[index].symbol
            }
          });
        });
      }
    }
  },
  series: [{
    data: [{
      x: 0.38,
      y: 0.55,
    }, {
      x: 0.52,
      y: 0.66,
    }, {
      x: 0.38,
      y: 0.42,
    }, {
      x: 0.29,
      y: 0.39,
    }, {
      x: 0.5,
      y: 0.56,
    }, {
      x: 0.04,
      y: 0.15,
    }]
  }]
});

      </script>  
   </body>
</html>

Related Tutorials