1
votes

I'm using Amcharts to populate my data.

I have 4 graphs in my chart with valueAxes 0-100.

Is there any way for me to change the valueAxes dynamically to 0-250 after chart is loaded in the view.

I tried this, but it is not working.

I'm using this to change but it is not changing the axis values and graph.

<input class="form-control maxField" type="number" placeholder="Max value">

      $(".maxField").on("keyup", function() {
        var valueAxis = new AmCharts.ValueAxis();
        valueAxis.maximum = this.value;
        chart.addValueAxis(valueAxis);
        chart.validateNow();
      });
1

1 Answers

3
votes

It's better to manipulate existing value axis than to create new one if all you need to do is to change the maximum property dynamically.

Try this:

$( ".maxField" ).on( "keyup", function() {
  chart.valueAxes[0].maximum = this.value;
  chart.validateNow();
} );