From 100f6675874e83b29a95280f3c583c64a7250c55 Mon Sep 17 00:00:00 2001 From: Pieter Verschaffelt Date: Fri, 30 Apr 2021 11:26:24 +0200 Subject: [PATCH] Remove id's from tooltips --- src/utilities/TooltipUtilities.ts | 3 +-- src/utilities/__tests__/TooltipUtilities.spec.ts | 3 +-- src/visualizations/heatmap/Heatmap.ts | 1 - src/visualizations/sunburst/Sunburst.ts | 2 +- src/visualizations/treemap/Treemap.ts | 2 +- src/visualizations/treeview/Treeview.ts | 2 +- 6 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/utilities/TooltipUtilities.ts b/src/utilities/TooltipUtilities.ts index 78896b2..e17e5a1 100644 --- a/src/utilities/TooltipUtilities.ts +++ b/src/utilities/TooltipUtilities.ts @@ -1,10 +1,9 @@ import * as d3 from "d3"; export default class TooltipUtilities { - public static initTooltip(elementId: string): d3.Selection { + public static initTooltip(): d3.Selection { return d3.select("body") .append("div") - .attr("id", elementId + "-tooltip") .attr("class", "tip") .style("position", "absolute") .style("z-index", "10") diff --git a/src/utilities/__tests__/TooltipUtilities.spec.ts b/src/utilities/__tests__/TooltipUtilities.spec.ts index 44a9c4c..b15dc54 100644 --- a/src/utilities/__tests__/TooltipUtilities.spec.ts +++ b/src/utilities/__tests__/TooltipUtilities.spec.ts @@ -2,9 +2,8 @@ import TooltipUtilities from "./../TooltipUtilities"; describe("TooltipUtilities.initTooltip", () => { it("should produce a tooltip that satisfies the requirements", () => { - const tooltip = TooltipUtilities.initTooltip("unique-identifier"); + const tooltip = TooltipUtilities.initTooltip(); - expect(tooltip.attr("id")).toContain("unique-identifier"); expect(tooltip.attr("class")).toEqual("tip"); }); }); diff --git a/src/visualizations/heatmap/Heatmap.ts b/src/visualizations/heatmap/Heatmap.ts index 2d367c6..ada7115 100644 --- a/src/visualizations/heatmap/Heatmap.ts +++ b/src/visualizations/heatmap/Heatmap.ts @@ -949,7 +949,6 @@ export default class Heatmap { private initTooltip() { return d3.select("body") .append("div") - .attr("id", Math.floor(Math.random() * 2**16) + "-tooltip") .attr("class", "tip") .style("position", "absolute") .style("z-index", "10") diff --git a/src/visualizations/sunburst/Sunburst.ts b/src/visualizations/sunburst/Sunburst.ts index b01e690..64b768a 100644 --- a/src/visualizations/sunburst/Sunburst.ts +++ b/src/visualizations/sunburst/Sunburst.ts @@ -49,7 +49,7 @@ export default class Sunburst { const processedData = preprocessor.preprocessData(data); if (this.settings.enableTooltips) { - this.tooltip = TooltipUtilities.initTooltip(Math.floor(Math.random() * 2**16).toString()); + this.tooltip = TooltipUtilities.initTooltip(); } this.currentMaxLevel = this.settings.levels; diff --git a/src/visualizations/treemap/Treemap.ts b/src/visualizations/treemap/Treemap.ts index 19399bf..5e787f3 100644 --- a/src/visualizations/treemap/Treemap.ts +++ b/src/visualizations/treemap/Treemap.ts @@ -34,7 +34,7 @@ export default class Treemap { this.settings = this.fillOptions(options); if (this.settings.enableTooltips) { - this.tooltip = TooltipUtilities.initTooltip(Math.floor(Math.random() * 2**16).toString()); + this.tooltip = TooltipUtilities.initTooltip(); } this.initCss(); diff --git a/src/visualizations/treeview/Treeview.ts b/src/visualizations/treeview/Treeview.ts index 3ba83f3..cc96eec 100644 --- a/src/visualizations/treeview/Treeview.ts +++ b/src/visualizations/treeview/Treeview.ts @@ -39,7 +39,7 @@ export default class Treeview { this.settings = this.fillOptions(options); if (this.settings.enableTooltips) { - this.tooltip = TooltipUtilities.initTooltip(Math.floor(Math.random() * 2**16).toString()); + this.tooltip = TooltipUtilities.initTooltip(); } const dataProcessor = new TreeviewPreprocessor();