Cannot Pass jQuery Object to Chartist
See original GitHub issueMaybe I’m missing something, but any time I try and pass a jQuery object to chartist, it gives me:
Uncaught SyntaxError: Failed to execute 'querySelector' on 'Document': '[object Object]' is not a valid selector.
For example:
var chart = $('.ct-chart');
new Chartist.Pie(chart, data);
Is there any way to pass a jQuery object to Chartist? I’m having to create individual IDs for each chart and then grab those with jQuery in order to put a dynamic amount of charts on the page, which works, but is a bit more time consuming/probably less performant.
I apologize if this has been covered before. Thanks for any help or advice anyone could give! Kickass chart lib.
Issue Analytics
- State:
- Created 9 years ago
- Comments:9
Top Results From Across the Web
jQuery object from html table into two one-dimensional arrays ...
I'm fiddling around with some jQuery code that should extract data from a 2-column HTML table and then spit out two one-dimensional arrays....
Read more >Chartist.js, An Open-Source Library For Responsive Charts
To animate an SVG element, you first need to obtain a wrapper object by passing an SVG node to the Chartist. Svg constructor....
Read more >Chartist.js data from table | Professor von Explaino
First parameter is the object to iterate through. table.getElementsByTagName('th') function gets me all the th elements in the selected table as ...
Read more >Chartist.js Charts With Data from a MongoDB Using Flask and ...
In this video I show you how to create dynamic Chartist.js charts based ... server for the data and jQuery to send requests...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey there. The Chartist guy hates jQuery 😃 He wants the world to be less jQuery and more JavaScript. That’s why Chartist only accepts DOM selector strings or DOM Node Objects as first parameter in the Chart.
If you’re still using jQuery in your project, Chartist is fine with that, but when you initialize a Chart you need to extract the DOM Node object from your jQuery List:
Not a bad solution, I’m calculating the values using JS, so I can’t exactly do it like that, but an awesome example none the less.
Thanks again for the help!