Home forums Using CanvasJS How can i get access to a canvasJS chart through a DOM-Container

This topic contains 7 replies, has 5 voices, and was last updated by  Indranil Deo 7 months, 3 weeks ago.

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

    Donwey
    Member

    When i render a canvasJS-chart to a div container, how can i get access to the chart object through the div-Container? i dont want to make the chart variable global.

    I want to use it as: var chart=$(“#container”).canvasJS();

    Ayny ideas please.

    #17347

    Sanjoy
    Participant

    @donwey,

    You can get access to the chart object using $("#container").CanvasJS().

    ——-
    Sanjoy Debnath,
    Team CanvasJS

    • This reply was modified 9 months, 2 weeks ago by  Vishwas R.
    #19796

    Meraj Ahmed
    Member

    It is not workin @sanjoy

    #19810

    Indranil Deo
    Member

    @merajahmed,

    $("#container").CanvasJS() will work with jQuery Charts. In case you have some other requirement please create a jsfiddle so that we can understand your requirement better and help you out.

    ___________
    Indranil Deo,
    Team CanvasJS

    #19811

    Meraj Ahmed
    Member

    See this link jsfiddle
    See the console. It says $(…).CanvasJS is not a function

    #19812

    Indranil Deo
    Member

    @merajahmed,

    Please use var c = $("#chartContainer").CanvasJSChart();. Also take a look at this updated jsfiddle.

    And please use the jQuery plugin (https://canvasjs.com/assets/script/jquery.canvasjs.min.js) instead of Javascript.

    ___________
    Indranil Deo,
    Team CanvasJS

    #20451

    vipinrana
    Member

    @indranil Deo,

    I have used your described code but still not not working. Using the same canvasjs.min.js library you provide.

    #20454

    Indranil Deo
    Member

    @vipinrana,

    Since you are using the jQuery selector var c = $("#chartContainer").CanvasJSChart();, please use the jQuery plugin (https://canvasjs.com/assets/script/jquery.canvasjs.min.js) instead of Javascript.

    ___________
    Indranil Deo,
    Team CanvasJS

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

You must be logged in to reply to this topic.