From 71be671e6b3f1cd11146e5ec3fc9b7251281c537 Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Mon, 2 Jan 2023 10:49:50 -0500 Subject: [PATCH] No need to re-assign --- .../d3-state-visualizer/src/charts/tree/tree.ts | 13 ++++++------- packages/d3tooltip/src/index.ts | 7 +++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/d3-state-visualizer/src/charts/tree/tree.ts b/packages/d3-state-visualizer/src/charts/tree/tree.ts index adb75f46..4fb96e53 100644 --- a/packages/d3-state-visualizer/src/charts/tree/tree.ts +++ b/packages/d3-state-visualizer/src/charts/tree/tree.ts @@ -164,23 +164,22 @@ export default function (DOMNode: HTMLElement, options: Partial = {}) { const root = d3.select(DOMNode); const zoom = d3.zoom().scaleExtent([0.1, 3]); - let svgElement = root + const svgElement = root .append('svg') .attr('id', id) - .attr('preserveAspectRatio', 'xMinYMin slice'); + .attr('preserveAspectRatio', 'xMinYMin slice') + .style('cursor', '-webkit-grab'); if (!chartStyles.width) { - svgElement = svgElement.attr('width', fullWidth); + svgElement.attr('width', fullWidth); } if (!chartStyles.width || !chartStyles.height) { - svgElement = svgElement.attr('viewBox', `0 0 ${fullWidth} ${fullHeight}`); + svgElement.attr('viewBox', `0 0 ${fullWidth} ${fullHeight}`); } - svgElement = svgElement.style('cursor', '-webkit-grab'); - for (const [key, value] of Object.entries(chartStyles)) { - svgElement = svgElement.style(key, value); + svgElement.style(key, value); } const vis = svgElement diff --git a/packages/d3tooltip/src/index.ts b/packages/d3tooltip/src/index.ts index 954adb5f..8c3c5df0 100644 --- a/packages/d3tooltip/src/index.ts +++ b/packages/d3tooltip/src/index.ts @@ -95,13 +95,12 @@ export function tooltip< .style('position', 'absolute') .style('z-index', 1001) .style('left', `${x}px`) - .style('top', `${y}px`); + .style('top', `${y}px`) + .html(() => text(node)); for (const [key, value] of Object.entries(styles)) { - el = el.style(key, value); + el.style(key, value); } - - el = el.html(() => text(node)); }); selection.on('mousemove.tip', (node) => {