change the radius of the selected point in scatter chart - Javascript highcharts

Javascript examples for highcharts:Scatter Chart

Description

change the radius of the selected point in scatter chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
      <style id="compiled-css" type="text/css">

#container {/*www  . ja v  a2s. c  o  m*/
   min-width: 310px;
   height: 400px;
   max-width: 800px;
   margin: 0 auto;
}


      </style> 
      <script type="text/javascript">
$(function () {
    var options = {
        chart: {
            type: 'scatter',
            zoomType: 'xy',
            renderTo: 'container'
        },
        title: {
            text: 'Redrawing changes radius of selected point?'
        },
        plotOptions: {
            scatter: {
                marker: {
                    radius: 5,
                    states: {
                        hover: {
                            enabled: true,
                            lineColor: 'rgb(100,100,100)'
                        },
                        select: {
                            radius: 8,
                            enabled: true,
                            lineColor: 'red',
                            fillColor: 'red'
                        }
                    }
                }
            }
        },
        series: [{
            name: 'Male',
            color: 'rgba(119, 152, 191, .5)',
            data: [
                {'id': 'a', 'x': 185.4, 'y': 66.8},
                {'id': 'b', 'x': 177.8, 'y': 75.5},
                {'id': 'c', 'x': 180.3, 'y': 93.2}
            ]
        }]
    };
    var chart = new Highcharts.Chart(options);
    chart.get('b').select();
    var newData = [
                {'id': 'a', 'x': 175.4, 'y': 76.8},
                {'id': 'b', 'x': 172.8, 'y': 65.5},
                {'id': 'c', 'x': 183.3, 'y': 83.2}
            ];
    $('#clickme').on('click', function() {
      var chartData = chart.series[0].data;
      chartData.forEach(function(point, i) {
            point.update(newData[i]);
        });
      chart.redraw();
    });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <button id="clickme">Click me to redraw</button> 
      <div id="container"></div>  
   </body>
</html>

Related Tutorials