jakezatecky / d3-funnel

A JavaScript library for rendering funnel charts using the D3.js framework.
http://jakezatecky.github.io/d3-funnel/
MIT License
330 stars 97 forks source link

chart.draw is not a function #104

Closed jaddimachkieh closed 3 years ago

jaddimachkieh commented 5 years ago

Can someone please assist with the following error, "chart.draw is not a function" i think its something simple. Note: i'm using react + d3

Thank you!

jakezatecky commented 5 years ago

Hello @jaddimachkieh can you post a live example? Usually an error like that indicates that one of the dependencies may not be loaded.

jaddimachkieh commented 5 years ago

Hello @jakezatecky, here is the function where im trying to implement the funnel chart as you can see its exactly like the example with the a different type of id.

 updateD3() {
        d3.select(`#${this.id}`).selectAll("*").remove();
        let data = [
            { label: 'Inquiries', value: 5000 },
            { label: 'Applicants', value: 2500 },
            { label: 'Admits', value: 500 },
            { label: 'Deposits', value: 200 },
        ];
        let options = {
            chart: {
                height: 400,
            },
            block: {
                dynamicHeight: true,
                minHeight: 15,
            },
        };

        let chart = d3.select(`#${this.id}`)
        .attr('id', `${this.legAreaID}`)
        new D3Funnel('#funnel');
}

IN THE REACT RENDER:

<svg className="table" id={this.id} ref={svg => this.svg = svg} width={this.props.width-200} height={this.props.height-150}></svg>
jaddimachkieh commented 5 years ago

this is comment i'm getting:

Could not find a declaration file for module 'd3-funnel' Try npm install @types/d3-funnel if it exists or add a new declaration (.d.ts) file containing `declare module 'd3-funnel';

thanks for the help

jakezatecky commented 5 years ago

The above error, @types/d3-funnel, indicates that you might be using TypeScript, though the code you posted is not very TypeScript-y. I have effectively zero experience with TypeScript, though I do think someone could add the declarations to the official @types repository such that you could install them via npm.

I appreciate you posting the code, but it is not quite sufficient to determine the full breadth of the issue. Ideally you could post a live link to a JsFiddle, CodePen, or similar JavaScript sandbox such that I can verify the issue.