Skip to content

Commit

Permalink
Merge pull request #79 from marmelab/zoom_center
Browse files Browse the repository at this point in the history
[RFR] Fix zoom center position (fixes #70)
  • Loading branch information
fzaninotto committed Jun 1, 2016
2 parents e7ac586 + db72a2b commit 78a1520
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
sudo: false
language: node_js
node_js:
- "0.10.32"
cache:
directories:
- node_modules
Expand Down
4 changes: 2 additions & 2 deletions lib/drawer/drops.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export default (svg, scales, configuration) => function dropsSelector(data) {
dropLines.each(function dropLineDraw(drop) {
const drops = d3.select(this).selectAll('.drop').data(drop.dates);

drops.attr('cx', d => scales.x(d) + 200);
drops.attr('cx', d => scales.x(d));

const circle = drops.enter()
.append('circle')
.classed('drop', true)
.attr('r', 5)
.attr('cx', d => scales.x(d) + 200)
.attr('cx', d => scales.x(d))
.attr('cy', -5)
.attr('fill', configuration.eventColor);

Expand Down
13 changes: 13 additions & 0 deletions test/karma/drawer/drops.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ describe('Drops drawer', () => {
expect(hoverSpy.calls.any()).toBe(true);
});

it('should set `cx` attribute to given scale `x`', () => {
const data = [{ name: 'foo', dates: [new Date('2014-04-03')] }];

const chart = d3.chart.eventDrops()
.start(new Date('2014-04-02'))
.end(new Date('2014-04-04'));

d3.select(wrapper).datum(data).call(chart);

const drop = d3.select('.drop');
expect(+drop.attr('cx')).toBe(375);
});

afterEach(() => {
document.body.removeChild(wrapper);
});
Expand Down

0 comments on commit 78a1520

Please sign in to comment.