Home › forums › Using CanvasJS › set title from other function
Tagged: title cahrt
I’m relatively new, so excuss my simple question:
I know how to set the title of my chart:
text: “Load Displacement Curve”,
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
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.
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()”.
You must be logged in to reply to this topic.