Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically change a chart title in highcharts

I have a simple column chart that I update via AJAX, and all is working fine except I cannot change the actual title of the chart when I'm updating the data.

I've tried the obvious -

chart.title="new title";
//and
chart.title.text="New title";

etc. - to no avail, and have had no success finding a solution online.

Any help will be greatly appreciated.

like image 281
acullen72 Avatar asked Oct 26 '11 15:10

acullen72


People also ask

How do I change the y axis title in Highcharts?

yAxis[0]. update({ title:{ text:"My text" } }); alert('Y-axis title changed to "My text" ! '); }); Refer Highcharts 'update' function documentation for further details.

How can I tell if Highcharts are loaded?

To determine that chart is fully loaded you can use load event, because load event is invoked when all elements are drown (API reference https://api.highcharts.com/highcharts/chart.events.load). However when you are using series animation this runs in a timeout, then load event is invoked before animation will finish.

How display no data available message in Highcharts?

Just don't create the highchart and insert text saying "No Data Available". Without any code, this is the most help you're likely to get.


1 Answers

You can use setTitle(titleObj, subTitleObj) for that.

chart.setTitle({text: "New Title"});

See an example: jsfiddle

See the API Ref.

like image 146
Bhesh Gurung Avatar answered Oct 24 '22 00:10

Bhesh Gurung