Home Forums Chart Support How to change dataPoints axisY Y value dynamically Reply To: How to change dataPoints axisY Y value dynamically

#39765

@rashedk,

To update the y value of a datapoint using a dropdown menu you need to update the chart options / data based on the options selected from the dropdown list. Please check the code snippet below.

var country = document.getElementById("country");
country.addEventListener( "change",  function(){
  for(var i = 0; i < chart.options.data[0].dataPoints.length; i++) {
    if(country.options[country.selectedIndex].text === chart.options.data[0].dataPoints[i].label)
      chart.options.data[0].dataPoints[i].y = Number(country.options[country.selectedIndex].value);
  }
  chart.render();
});

Please take a look at this JSFiddle for a working example.


Thangaraj Raman
Team CanvasJS