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

This topic contains 6 replies, has 5 voices, and was last updated by  vipinrana 5 hours ago.

Viewing 7 posts - 1 through 7 (of 7 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
    Moderator

    @donwey,

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

    ——-
    Sanjoy Debnath,
    Team CanvasJS

    • This reply was modified 1 month, 3 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.

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

You must be logged in to reply to this topic.