You must be logged in to post your query.
Home › Forums › Chart Support › set title from other function
Tagged: title cahrt
Hi all,
I’m relatively new, so excuss my simple question: I know how to set the title of my chart:
title:{ text: “Load Displacement Curve”, fontSize: 20 }
but how can I do that from another function? So my chart is in a variable e.g. myChart and I’d like to use this to set the tile:
e.g. myChart.title = “mynewtitle”;
is this possible? Thanks a lot in advance, Best Tschounes
@tschounes,
You can use chart.options.title.text to update the text of the title. Please refer to this documentation page for more information on updating chart options.
chart.options.title.text
—- Manoj Mohan Team CanvasJS
Thanks Manoj! That worked.
Important to note (what probably is clear for the most people but was not for me): if you define the function in the windows.onload function you need to define your chart as global variable (windows.myChart = new ChanvasJs.Chart()” and access it via windows.myChart. Before you see the title change you have to rerender the plot “windows.myChart.render()”.
Cheers, Tschounes
You must be logged in to reply to this topic. Login/Register