Skip to content

Commit

Permalink
#327 Hide marker if there is not points to select
Browse files Browse the repository at this point in the history
  • Loading branch information
mekiert committed Feb 3, 2020
1 parent 75d7618 commit 4684f19
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ export class LineChartService {
d3Select('.y-axis').transition().call((transition) => this.updateYAxis(transition, yNewScale, this._width));
// Redraw lines and dots
this.addDataLinesToChart(chart, xScale, yScale, data);
// Show marker
this.showMarker();
};

const updateChart = (chart: D3Selection<D3BaseType, {}, D3ContainerElement, {}>, xScale: D3ScaleTime<number, number>, yScale: D3ScaleLinear<number, number>, data: TimeSeries[]) => {
Expand Down Expand Up @@ -857,22 +859,18 @@ export class LineChartService {
})
}

private showMarker() {
d3Select('.marker-line').style('opacity', 1);
d3Select('#marker-tooltip').style('opacity', 1);
};

private hideMarker() {
d3Select('.marker-line').style('opacity', 0);
d3Select('#marker-tooltip').style('opacity', 0);
this.hideOldDotsOnMarker();
};

private prepareMouseEventCatcher = (() => {
const showMarker = () => {
if(this._dotsOnMarker && this._dotsOnMarker.empty()) {
return;
}

d3Select('.marker-line').style('opacity', 1);
d3Select('#marker-tooltip').style('opacity', 1);
};

return (chart: D3Selection<D3BaseType, {}, D3ContainerElement, {}>) => {
if (!chart.select('.chart-content').empty()) {
return;
Expand All @@ -884,7 +882,7 @@ export class LineChartService {
.attr('width', this._width)
.attr('height', this._height)
.attr('fill', 'none')
.on('mouseenter', () => showMarker())
.on('mouseenter', () => this.showMarker())
.on('mouseleave', () => this.hideMarker())
.on("contextmenu", () => d3Event.preventDefault())
.on('mousemove', (_, index, nodes: D3ContainerElement[]) => {
Expand Down

0 comments on commit 4684f19

Please sign in to comment.