marmelab / marmelab/EventDrops

Unable to get the zoom object

Open
#168 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted
Dominant language
JavaScript
Stars
1.3k
Forks
233
PR merge metrics
No merged PRs in 30d

Description

Hello everybody!

I'm currently using EventDrops in an Angular 4 application. I need to set the zoom programmatically, so I read the documentation and the example:

```
var eventDropsChart = d3.chart.eventDrops();
var element = d3.select('#chart_placeholder').datum(...);
eventDropsChart.call(eventDropsChart);
var zoom = element[0][0].zoom;
```

I have something similar in my code:

```
var chart = d3.chart.eventDrops()
.date(d => d.date)
.start(minDate)
.end(maxDate)
.mouseover(this.showTooltip)
.mouseout(this.hideTooltip)
.click(this.onEventClick)
.zoomend(this.onZoomEnd)
.eventLineColor((d, i) => colors[i]);

this.timeline = d3.select('#visual')
.datum(data)
.call(chart);

console.log("ZOOM");
console.log(this.timeline[0]); // Ouptut: undefined
```

but then I got undefined, so I'm unable to get the zoom.

I also tried to change the code to:

```
this.timeline = d3.select('#visual')
.datum(data);

chart.call(chart);

console.log("ZOOM");
console.log(this.timeline[0]);
```

But then I got another error:

> Cannot read property 'each' of undefined
> at Function.e (eventDrops.js:1)

Is it a bug or am I doing something wrong?

Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The report centers on eventDrops.js and the documented chart.call and selection snippets; start by comparing those invocation paths and how the zoom object is attached to the rendered selection. Reproduce the Angular 4 case, then verify whether the documented way to access zoom works or needs correction.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, d3js, javascript
Domain
data-visualization, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.