Skip to content

Commit

Permalink
fix(packages/core/src/line-chart.ts): Fix tooltips bug #89: Fix impor…
Browse files Browse the repository at this point in the history
…ts and addDataPointEventListene

Bug #89: Tooltips for Stacked Bar & Line show onClick
  • Loading branch information
darsi-an committed Nov 17, 2018
1 parent b298dcf commit 5a63f94
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
22 changes: 2 additions & 20 deletions packages/core/src/line-chart.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// D3 Imports
import { select, selectAll, mouse } from "d3-selection";
import { select, mouse } from "d3-selection";
import { line } from "d3-shape";

import { BaseAxisChart } from "./base-axis-chart";
Expand Down Expand Up @@ -206,12 +206,11 @@ export class LineChart extends BaseAxisChart {
super.resizeChart();
}


addDataPointEventListener() {
const self = this;
const { accessibility } = this.options;

this.svg.selectAll("gLines")
this.svg.selectAll("circle.dot")
.on("click", function(d) {
self.dispatchEvent("line-onClick", d);
})
Expand All @@ -235,23 +234,6 @@ export class LineChart extends BaseAxisChart {
const { strokeWidth, strokeWidthAccessible } = Configuration.lines.points.mouseout;
select(this)
.attr("stroke-width", accessibility ? strokeWidthAccessible : strokeWidth)
.attr("stroke", accessibility ? self.colorScale[d.datasetLabel](d.label) : "none")
.attr("stroke-opacity", Configuration.lines.points.mouseout.strokeOpacity);

self.hideTooltip();
});

this.svg.selectAll("circle.dot")
.on("mouseover", function(d) {
select(this)
.attr("stroke", self.colorScale[d.datasetLabel](d.label))
.attr("stroke-opacity", Configuration.lines.points.mouseover.strokeOpacity);

self.showTooltip(d, this);
self.reduceOpacity(this);
})
.on("mouseout", function(d) {
select(this)
.attr("stroke", self.colorScale[d.datasetLabel](d.label))
.attr("stroke-opacity", Configuration.lines.points.mouseout.strokeOpacity);

Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/stacked-bar-chart.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// D3 Imports
import { select, selectAll, mouse } from "d3-selection";
import { select, mouse } from "d3-selection";
import { stack } from "d3-shape";
import { max } from "d3-array";

Expand Down Expand Up @@ -241,6 +241,5 @@ export class StackedBarChart extends BaseAxisChart {

self.hideTooltip();
});

}
}

0 comments on commit 5a63f94

Please sign in to comment.