Home Forums Chart Support set title from other function

set title from other function

Viewing 3 posts - 1 through 3 (of 3 total)
  • #28859

    Hi all,

    I’m relatively new, so excuss my simple question:
    I know how to set the title of my chart:

    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



    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.

    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

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.