Skip to content

Commit 4684f19

Browse files
committed
#327 Hide marker if there is not points to select
1 parent 75d7618 commit 4684f19

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

frontend/src/app/modules/time-series/services/line-chart.service.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ export class LineChartService {
388388
d3Select('.y-axis').transition().call((transition) => this.updateYAxis(transition, yNewScale, this._width));
389389
// Redraw lines and dots
390390
this.addDataLinesToChart(chart, xScale, yScale, data);
391+
// Show marker
392+
this.showMarker();
391393
};
392394

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

862+
private showMarker() {
863+
d3Select('.marker-line').style('opacity', 1);
864+
d3Select('#marker-tooltip').style('opacity', 1);
865+
};
866+
860867
private hideMarker() {
861868
d3Select('.marker-line').style('opacity', 0);
862869
d3Select('#marker-tooltip').style('opacity', 0);
863870
this.hideOldDotsOnMarker();
864871
};
865872

866873
private prepareMouseEventCatcher = (() => {
867-
const showMarker = () => {
868-
if(this._dotsOnMarker && this._dotsOnMarker.empty()) {
869-
return;
870-
}
871-
872-
d3Select('.marker-line').style('opacity', 1);
873-
d3Select('#marker-tooltip').style('opacity', 1);
874-
};
875-
876874
return (chart: D3Selection<D3BaseType, {}, D3ContainerElement, {}>) => {
877875
if (!chart.select('.chart-content').empty()) {
878876
return;
@@ -884,7 +882,7 @@ export class LineChartService {
884882
.attr('width', this._width)
885883
.attr('height', this._height)
886884
.attr('fill', 'none')
887-
.on('mouseenter', () => showMarker())
885+
.on('mouseenter', () => this.showMarker())
888886
.on('mouseleave', () => this.hideMarker())
889887
.on("contextmenu", () => d3Event.preventDefault())
890888
.on('mousemove', (_, index, nodes: D3ContainerElement[]) => {

0 commit comments

Comments
 (0)