Home forums Using CanvasJS How to get graph type after chart is rendered

This topic contains 7 replies, has 2 voices, and was last updated by  Akhil H 4 months, 2 weeks ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #11589

    Akhil H
    Member

    Is it possible to get the current type of graph after the graph is created using jquery

    #11590

    Sanjoy
    Moderator

    Yes, to get the chart type of first dataSeries use
    $("#chartContainer").CanvasJSChart().options.data[0].type.

    Source: jQuery Integration Overview

    #11591

    Akhil H
    Member

    Thank you
    I tried this code but it shows an error message ‘undefined is not a function’

    • This reply was modified 4 months, 2 weeks ago by  Akhil H.
    #11592

    Akhil H
    Member

    I used chrome devtools console and came to know that CanvasJSChart() function is not available.

    #11593

    Sanjoy
    Moderator

    Without looking into code it’s hard to guess the issue. Can you please create a jsfiddle?

    #11595

    Akhil H
    Member
    #11596

    Sanjoy
    Moderator

    In canvasjs.min.js or canvasjs.js all chart initialized variables can be reffered using chart.options. So, here you can use chart.options.data[0].type to get assigned chart type of first dataSeries.

    Source: http://canvasjs.com/docs/charts/basics-of-creating-html5-chart/updating-chart-options/

    #11597

    Akhil H
    Member

    Thanks a lot
    It worked fine…..

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

You must be logged in to reply to this topic.