Skip to content

Commit

Permalink
Remove id's from tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
pverscha committed Apr 30, 2021
1 parent 241f94d commit 100f667
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/utilities/TooltipUtilities.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import * as d3 from "d3";

export default class TooltipUtilities {
public static initTooltip(elementId: string): d3.Selection<HTMLDivElement, unknown, HTMLElement, any> {
public static initTooltip(): d3.Selection<HTMLDivElement, unknown, HTMLElement, any> {
return d3.select("body")
.append("div")
.attr("id", elementId + "-tooltip")
.attr("class", "tip")
.style("position", "absolute")
.style("z-index", "10")
Expand Down
3 changes: 1 addition & 2 deletions src/utilities/__tests__/TooltipUtilities.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});
1 change: 0 additions & 1 deletion src/visualizations/heatmap/Heatmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/visualizations/sunburst/Sunburst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/visualizations/treemap/Treemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/visualizations/treeview/Treeview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 100f667

Please sign in to comment.