Skip to content

Commit

Permalink
fix(selection): Correct on data selection (#113)
Browse files Browse the repository at this point in the history
Change to normal function correcting the scope issue

Closed #112
Fixed #113
  • Loading branch information
netil authored and sculove committed Aug 17, 2017
1 parent 604c03a commit eb13350
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions spec/interaction-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/* eslint-disable */
/* global describe, beforeEach, it, expect */
import util from "./assets/util";
import CLASS from "../src/config/classes";

describe("INTERACTION", () => {
let chart;
Expand Down Expand Up @@ -226,5 +227,32 @@ describe("INTERACTION", () => {
});
});
});

describe("check for data.selection", () => {
before(() => {
args = {
data: {
columns: [
["data1", 30, 200, 100, 400, 150, 250]
],
selection: {
enabled: true
}
}
};
});

it("data point circle should be selected and unselected", () => {
const circle = d3.select(".bb-shape-2").node();
const box = circle.getBBox();
const rect = d3.select(".bb-event-rect-2").node();

util.setMouseEvent(chart, "click", box.x, box.y, rect);
expect(d3.select(circle).classed(CLASS.SELECTED)).to.be.true;

util.setMouseEvent(chart, "click", box.x, box.y, rect);
expect(d3.select(circle).classed(CLASS.SELECTED)).to.be.false;
});
});
});
});
2 changes: 1 addition & 1 deletion src/internals/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ extend(ChartInternal.prototype, {

$$.main.selectAll(selecter)
.selectAll(`.${CLASS.shape}`)
.each((d, i) => {
.each(function(d, i) {
const shape = d3Select(this);

if (shape.classed(CLASS.SELECTED)) {
Expand Down

0 comments on commit eb13350

Please sign in to comment.