Skip to content

Commit

Permalink
update measurement span
Browse files Browse the repository at this point in the history
  • Loading branch information
krkshitij committed Feb 18, 2025
1 parent d93b9bd commit 4d2856f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/charts/react-charting/src/utilities/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
IHorizontalBarChartWithAxisDataPoint,
} from '../index';
import { formatPrefix as d3FormatPrefix } from 'd3-format';
import { getId } from '@fluentui/react';

export type NumericAxis = D3Axis<number | { valueOf(): number }>;
export type StringAxis = D3Axis<string>;
Expand Down Expand Up @@ -1467,16 +1468,17 @@ export function copyStyle(properties: string[] | Record<string, string>, fromEl:
}
}

const SPAN_STYLE = {
const MEASUREMENT_SPAN_STYLE = {
position: 'absolute',
visibility: 'hidden',
top: '-20000px',
left: 0,
padding: 0,
margin: 0,
border: 'none',
whiteSpace: 'pre',
};
const MEASUREMENT_SPAN_ID = 'measurement_span';
const MEASUREMENT_SPAN_ID = getId('measurement_span_');

export const createMeasurementSpan = (text: string | number, className: string) => {
let measurementSpan = document.getElementById(MEASUREMENT_SPAN_ID);
Expand All @@ -1487,8 +1489,8 @@ export const createMeasurementSpan = (text: string | number, className: string)
document.body.appendChild(measurementSpan);
}

Object.assign(measurementSpan.style, SPAN_STYLE);
measurementSpan.setAttribute('class', className);
Object.assign(measurementSpan.style, MEASUREMENT_SPAN_STYLE);
measurementSpan.textContent = `${text}`;

return measurementSpan;
Expand Down

0 comments on commit 4d2856f

Please sign in to comment.