benkeen / d3pie

A configurable pie chart lib and generator built on d3.js
MIT License
370 stars 203 forks source link

I cannot get this to work. #170

Open lstasio5 opened 5 years ago

lstasio5 commented 5 years ago

Hello. I installed the files but I keep getting this error in the console:

d3pie.min.js:8 d3pie error: the first d3pie() param must be a valid DOM element (not jQuery) or a ID string.

Toastgeraet commented 5 years ago

More information about your code would be welcome.

Please instatiate your pie like this:

<div id="myDivId">

var containerId = "myDivId"; // note the missing **hashtag**
var configObject = {
   ...
}
window.pie = new d3pie(containerId, configObject);

if you are passing a jquery object, pass the dom element instead e.g.:

var jqContainer = $('#div');
var domContainer = $('#div')[0];
var domContainerClassic = document.getElementById('myDivId');

If you are using JQuery you should at the very least get familiar with what it does for you. The error message could not have been more clear in this case.