Skip to content

TypeError: undefined is not a function (near '...', click).transition().duration(750).att...') #152

@michchan

Description

@michchan

I used PieChart in a component. It works when it first rendered. But I got this error after any state update:
TypeError: undefined is not a function (near '...', click).transition().duration(750).att...')
logCapturedError — react-dom.development.js:16477

image

This is how I used the PieChart:

<PieChart
    size={CHART_SIZE}
     data={[
           { key: 'A', value: 100, color: CHART_RED },
           { key: 'B', value: 200, color: CHART_ORANGE },
          { key: 'C', value: 50, color: CHART_YELLOW },
          { key: 'D', value: 50, color: CHART_GREEN },
           { key: 'E', value: 50, color: CHART_BLUE },
      ]}/>                            

It works when I forked from the repo and comment out the some lines of codes (transition) like this:

    if (n) { // we don't need to do this, but it's fun
      /*
       * Change current slices
       * Transition current slice dimensions
       */
      path
        .attr('fill', getSliceFill)
        .on('mouseover', mouseover)
        .on('mouseout', mouseout)
        .on('mousemove', mousemove)
        .on('click', click)
        // .transition()
        // .duration(750)
        // .attrTween('d', this.tweenSlice);

      /*
       * Add new slices
       */
      path
        .enter()
        .append('path')
        .attr('class', 'pie-chart-slice')
        .attr('fill', getSliceFill)
        .on('mouseover', mouseover)
        .on('mouseout', mouseout)
        .on('mousemove', mousemove)
        .on('click', click)
        .each((d, i) => currentSlices.splice(i, 1, d))
        // .transition()
        // .duration(750)
        // .attrTween('d', this.tweenSlice);
    }

Versions:
react-easy-chart: 1.0.0
react: ^16.6.0
react-dom: ^16.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions