denisemauldin / d3-timeline

D3 timeline
BSD 3-Clause "New" or "Revised" License
168 stars 72 forks source link

using webpack got exception: TypeError: gParentItem.node(...).attr is not a function at setHeight #27

Closed bedinsky closed 4 years ago

bedinsky commented 4 years ago

I'm using d3-timelines with vuejs and webpack and I got this exception in setHeight method

TypeError: gParentItem.node(...).attr is not a function at setHeight (webpack-internal:///./node_modules/d3-timelines/build/d3-timelines.js:596:27) at timelines (webpack-internal:///./node_modules/d3-timelines/build/d3-timelines.js:528:5) at Selection.eval [as call] (webpack-internal:///./node_modules/d3-selection/src/selection/call.js:5:12) at VueComponent.renderTimeline (webpack-internal:///./node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/modules/production/components/production-shift-timeline.vue?vue&type=script&lang=js&:204:42) at eval (webpack-internal:///./node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/modules/production/components/production-shift-timeline.vue?vue&type=script&lang=js&:142:10)

As patch, I would suggest to wrap line 596 with a try catch block as I can see in setWidth

                    try {
                        gParentItem.node().attr("height", height);
                    } catch (err) {
                        // console.log( err );
                    }

these are my imports regarding d3

import { timelines } from 'd3-timelines'; import { select } from 'd3-selection'; import { event as currentEvent } from 'd3-selection'; import { timeFormat } from 'd3-time-format'; import { timeHours } from 'd3-time'; const d3 = { select, timeFormat, timeHours };