Home Forums Chart Support Can I push Chart Options using JSON in ASP.NET Core Razor Pages App?

Can I push Chart Options using JSON in ASP.NET Core Razor Pages App?

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

    Hello

    I am using Canvasjs in an ASP.NET Core 3.1 Razor Pages Application. I am using JSON Data, via an AJAX Request, to push Data Points to the chart. I would also like to push other Chart Options, e.g. Chart Title – can this be done?

    I’ve shared a sample application on my Google Drive. It is a .NET Core 3.1 Razor Pages App, the idea is that the user enters the Chart Title and clicks the ‘Update’ button, which then calls the AJAX function and returns the JSON data to populate the Canvasjs chart.

    https://drive.google.com/file/d/1I6htJOCMNcKsrTXUrLl-B3uuIF8bra8A/view?usp=sharing

    I have successfully been able to push the Data Points to the chart, but I don’t know how to also push other chart options like the title.

    Could someone please help?

    Thanks in advance.

    #36503

    @tgriffiths,

    You can use the set method to update the chart title with the value from the input field as shown in the code-snippet below,

    $('#load').on('click', function (evt) {
    	evt.preventDefault();
    
    	var title = $('#Title').val();
    	chart.title.set("text", title);
    });

    Kindly take a look at this updated sample project for an example on the same.


    Adithya Menon
    Team CanvasJS

    #36505

    Hi Adithya

    Thank you for your help.

    Tony.

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

You must be logged in to reply to this topic.