Updating / Modifying Highchart Axis Charts

In my highchart, at some point, I need to update min, max and tickInterval yAxis. I tried 3 ways:

  • I tried the following code, but it says that "object # has no menthod update"

    var extremes = chart.yAxis[i].getExtremes(); chart.yAxis[i].update({ min: extremes.dataMin * 1.1, max: extremes.dataMax * 1.1, tickInterval : SomeValue, }); 
  • I also tried chart.redraw ... using the following code

      chart.yAxis[i].min = extremes.dataMin * 1.1; chart.yAxis[i].max = extremes.dataMax * 1.1; chart.yAxis[i].tickInterval = SomeValue; chart.redraw(); 

    This time it does not show any errors, but the chart also does not update.

  • This time I tried updating the parameters and then creating a new highchart:

     options.yAxis[i].min = extremes.dataMin * 1.1; options.yAxis[i].max = extremes.dataMax * 1.1; options.yAxis[i].tickInterval = SomeValue; chart = new Highcharts.Chart(options); 

It works this time, but I do not want to create a new highchart, I want to update the old one, because I use it in another method as well.

Please let me know how this can work, as well as if I create a new highchart using the third method, is there a way to get the last "chart" variable in another method?

thanks

+4
source share
4 answers

See this APIs:

 setExtremes (Number min, Number max, [Boolean redraw], [Mixed animation]) 

Link: http://api.highcharts.com/highcharts#Axis.setExtremes ()

They also have some jsfiddle examples.

EDIT: to change tickinterval follow these steps:

 chart.yAxis[0].options.tickInterval = markInterval; 

Add this also after the specified line:

 chart.xAxis[0].isDirty = true; 
+6
source

You have only one option:

 $(container).highcharts({ xAxis: { max: 10 //you can set the maximum here } }) 

The maximum value can only be determined once. After that, any other changes do not affect the schedule.

 chart.xAxis[0].options.max = 12; //this statement has no effect 
0
source

you must use another object to run the yAxis update method.

exp:

 var chart = new Highcharts(config); var axes = chart.axes; // this is all Axis object var xAxis = axes[0]; // by array method get axis object var yAxis = axes[1]; // now, object is ok, next trigger update method yAxis.update(<your attribute config>); 

high standard versions: "4.1.9"

0
source

Add the lines below before installing chart.addSeries

 chart.options.series = false; chart = new Highcharts.Chart(chart.options); chart.render(); 
-1
source

Source: https://habr.com/ru/post/1484988/


All Articles