Dynamic changes in dynamic charts?

There is a label on this graph: http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/combo/ label "Total fruit consumption"

After creating the chart, how can I change this sentence dynamically?

PS: I'm trying to set labels and redraw the graphics, but it didn’t work: http://jsfiddle.net/UXDqL/ p>

Any ideas?

+4
source share
3 answers

When using shortcuts, you can use the text renderer () and then use the variable to save the object. If you need to dynamically update this text, you only need to use the attr () function and update.

http://jsfiddle.net/6GKCJ/2/

var title = chart.renderer.text('Total fruits consumption', 100, 90) .css({ fontSize: '12px' }) .add(); $('#btn').click(function(){ title.attr({ text:'newText' }); }); 
+9
source

If you want to change it after drawing a graph, just act on the element itself. Using jquery selectors is as simple as:

 // find me the tspan containing the specified text and change it to... $("tspan:contains('Total fruit consumption')").text("Something New") 
+2
source

Highchart does not provide any way to dynamically update the shortcut title compared to Highcharts 3.0. Although it offers a dynamic update method for the series: http://api.highcharts.com/highstock#Series.update ()

To update the label heading, we need to follow the approach with brute force, for example, to display the chart again after updating the chart settings. The following code should do the trick:

 var mychart = $('#container').highcharts(); mychart.options.labels.items[0].html= "Changed label header"; mychart = new Highcharts.Chart(mychart.options); mychart.render(); 

JsFiddle: http://jsfiddle.net/msjaiswal/ZD4N5/2/

Similar topic: here

+1
source

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


All Articles