Open Akayeshmantha opened 5 years ago
Hi all when am trying to create the timeline chart I get the below error.I imported both d3 and d3-timeline
import * as d3timelines from 'd3-timelines'; import * as d3 from 'd3'; export class DashboardThreadedComponent implements OnInit { private data: any = [ {label: 'person a', times: [ {starting_time: 1355752800000, ending_time: 1355759900000}, {starting_time: 1355767900000, ending_time: 1355774400000}]}, {label: 'person b', times: [ {starting_time: 1355759910000, ending_time: 1355761900000}]}, {label: 'person c', times: [ {starting_time: 1355761910000, ending_time: 1355763910000}]}, ]; private chart: any; constructor( private cookieService: CookieService, private modalService: NgbModal, private bpeService: BPEService, private userService: UserService, private router: Router, private route: ActivatedRoute, public appComponent: AppComponent ) {} ngOnInit() { this.chart = d3timelines.timelines(); d3.select('.timeline').append('svg').attr('width', 500) .datum(this.data).call(this.chart); } } }
But am getting the below error ERROR TypeError: Cannot read property 'getBoundingClientRect' of null
ERROR TypeError: Cannot read property 'getBoundingClientRect' of null
Any one here that can help to fix it .Thanks alot
This is usually because the DOM isn't really ready. Wrapping the d3.select in a setTimeout will resolve it. On a large app of mine, I've had to set the timeout to 100 to guarantee the SVG is ready.
setTimeout
Hi all when am trying to create the timeline chart I get the below error.I imported both d3 and d3-timeline
But am getting the below error
ERROR TypeError: Cannot read property 'getBoundingClientRect' of null
Any one here that can help to fix it .Thanks alot