From 7e9a5d924bb51554008792dbd898c11840c2914e Mon Sep 17 00:00:00 2001 From: Vincent Hardouin Date: Tue, 23 Apr 2024 08:35:11 +0200 Subject: [PATCH] feat: allow to toggle stop --- src/App.vue | 6 +-- src/Game.js | 16 ++++++++ src/components/Game.vue | 85 ++++++++++++++++++++++++++++------------- src/map.js | 9 ++++- 4 files changed, 86 insertions(+), 30 deletions(-) diff --git a/src/App.vue b/src/App.vue index 38ff555..bbd9f50 100644 --- a/src/App.vue +++ b/src/App.vue @@ -5,9 +5,9 @@ import Game from './components/Game.vue'; diff --git a/src/map.js b/src/map.js index b23ad48..537a9d8 100644 --- a/src/map.js +++ b/src/map.js @@ -88,6 +88,7 @@ class ParisMap { .attr('cx', this.#projection(point)[0]) .attr('cy', this.#projection(point)[1]) .attr('r', 3) + .attr('data-stop-id', station.stop_unique_id) .style('fill', color) .on('mouseover', () => { this.#tooltip.style('visibility', 'visible'); @@ -114,9 +115,15 @@ class ParisMap { .attr('d', d3.line()(adjacentStop.path.map(p => this.#projection(p)))) .attr('stroke', `#${color}`) .attr('stroke-width', 2) - .attr('fill', 'none'); + .attr('fill', 'none') + .attr('data-stop-ids', `${adjacentStop.from_stop_unique_id},${adjacentStop.to_stop_unique_id}`); }); } + + removeStation(stopId) { + this.#stationsNode.selectAll(`[data-stop-id="${stopId}"]`).remove(); + this.#stationsNode.selectAll(`[data-stop-ids*="${stopId}"]`).remove(); + } } export {