@gravity-ui/charts 1.37.2 → 1.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/ChartInner/index.js +2 -1
- package/dist/cjs/components/ChartInner/useChartInnerProps.d.ts +0 -2
- package/dist/cjs/components/ChartInner/useChartInnerProps.js +1 -4
- package/dist/cjs/hooks/useChartOptions/tooltip.d.ts +5 -0
- package/dist/cjs/hooks/useChartOptions/tooltip.js +2 -2
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/utils/chart/text.js +4 -6
- package/dist/esm/components/ChartInner/index.js +2 -1
- package/dist/esm/components/ChartInner/useChartInnerProps.d.ts +0 -2
- package/dist/esm/components/ChartInner/useChartInnerProps.js +1 -4
- package/dist/esm/hooks/useChartOptions/tooltip.d.ts +5 -0
- package/dist/esm/hooks/useChartOptions/tooltip.js +2 -2
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/utils/chart/text.js +4 -6
- package/package.json +1 -1
|
@@ -66,7 +66,8 @@ export const ChartInner = (props) => {
|
|
|
66
66
|
const { allPreparedSeries, boundsHeight, boundsOffsetLeft, boundsOffsetTop, boundsWidth, handleLegendItemClick, isOutsideBounds, legendConfig, legendItems, preparedLegend, preparedSeries, preparedSeriesOptions, preparedSplit, prevHeight, prevWidth, shapes, shapesData, shapesReady, xAxis, xScale, yAxis, yScale, } = useChartInnerProps(Object.assign(Object.assign({}, props), { clipPathId,
|
|
67
67
|
dispatcher,
|
|
68
68
|
htmlLayout, plotNode: plotRef.current, preparedChart,
|
|
69
|
-
rangeSliderState,
|
|
69
|
+
rangeSliderState,
|
|
70
|
+
updateZoomState,
|
|
70
71
|
zoomState }));
|
|
71
72
|
const debouncedBoundsWidth = useDebouncedValue({
|
|
72
73
|
value: boundsWidth,
|
|
@@ -9,7 +9,6 @@ type Props = ChartInnerProps & {
|
|
|
9
9
|
htmlLayout: HTMLElement | null;
|
|
10
10
|
plotNode: SVGGElement | null;
|
|
11
11
|
preparedChart: PreparedChart;
|
|
12
|
-
svgContainer: SVGGElement | null;
|
|
13
12
|
updateZoomState: (nextZoomState: Partial<ZoomState>) => void;
|
|
14
13
|
zoomState: Partial<ZoomState>;
|
|
15
14
|
rangeSliderState?: RangeSliderState;
|
|
@@ -44,7 +43,6 @@ export declare function useChartInnerProps(props: Props): {
|
|
|
44
43
|
shapes: React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
|
|
45
44
|
shapesData: import("../../hooks").ShapeData[];
|
|
46
45
|
shapesReady: boolean;
|
|
47
|
-
svgXPos: number | undefined;
|
|
48
46
|
xAxis: import("../../hooks").PreparedXAxis | null;
|
|
49
47
|
xScale: import("../../hooks").ChartScale | undefined;
|
|
50
48
|
yAxis: (Omit<import("../../types").ChartAxis, "type" | "labels" | "plotLines" | "plotBands"> & {
|
|
@@ -75,8 +75,7 @@ export function useLegend({ preparedLegend, preparedChart, preparedSeries, width
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
export function useChartInnerProps(props) {
|
|
78
|
-
|
|
79
|
-
const { clipPathId, data, dispatcher, height, htmlLayout, plotNode, preparedChart, rangeSliderState, svgContainer, width, updateZoomState, zoomState, } = props;
|
|
78
|
+
const { clipPathId, data, dispatcher, height, htmlLayout, plotNode, preparedChart, rangeSliderState, width, updateZoomState, zoomState, } = props;
|
|
80
79
|
const prevWidth = usePrevious(width);
|
|
81
80
|
const prevHeight = usePrevious(height);
|
|
82
81
|
const colors = React.useMemo(() => {
|
|
@@ -214,7 +213,6 @@ export function useChartInnerProps(props) {
|
|
|
214
213
|
getYAxisWidth,
|
|
215
214
|
legendConfig,
|
|
216
215
|
});
|
|
217
|
-
const { x } = (_a = svgContainer === null || svgContainer === void 0 ? void 0 : svgContainer.getBoundingClientRect()) !== null && _a !== void 0 ? _a : {};
|
|
218
216
|
return {
|
|
219
217
|
allPreparedSeries,
|
|
220
218
|
boundsHeight,
|
|
@@ -234,7 +232,6 @@ export function useChartInnerProps(props) {
|
|
|
234
232
|
shapes,
|
|
235
233
|
shapesData,
|
|
236
234
|
shapesReady,
|
|
237
|
-
svgXPos: x,
|
|
238
235
|
xAxis,
|
|
239
236
|
xScale,
|
|
240
237
|
yAxis,
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { ChartData, ChartSeries, ChartXAxis, ChartYAxis } from '../../types';
|
|
2
2
|
import type { PreparedTooltip } from './types';
|
|
3
|
+
export declare function getDefaultTooltipHeaderFormat({ seriesData, yAxes, xAxis, }: {
|
|
4
|
+
seriesData: ChartSeries[];
|
|
5
|
+
yAxes?: ChartYAxis[];
|
|
6
|
+
xAxis?: ChartXAxis;
|
|
7
|
+
}): import("../../types").ValueFormat | undefined;
|
|
3
8
|
export declare const getPreparedTooltip: (args: {
|
|
4
9
|
tooltip: ChartData["tooltip"];
|
|
5
10
|
seriesData: ChartSeries[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
2
|
import { getDefaultValueFormat } from '../../components/Tooltip/DefaultTooltipContent/utils';
|
|
3
3
|
import { getDomainDataXBySeries, getDomainDataYBySeries, getMinSpaceBetween } from '../../utils';
|
|
4
|
-
function
|
|
4
|
+
export function getDefaultTooltipHeaderFormat({ seriesData, yAxes, xAxis, }) {
|
|
5
5
|
if (seriesData.every((item) => ['pie', 'treemap', 'waterfall', 'sankey', 'radar', 'heatmap', 'funnel'].includes(item.type))) {
|
|
6
6
|
return undefined;
|
|
7
7
|
}
|
|
@@ -17,5 +17,5 @@ function getDefaultHeaderFormat({ seriesData, yAxes, xAxis, }) {
|
|
|
17
17
|
export const getPreparedTooltip = (args) => {
|
|
18
18
|
var _a, _b;
|
|
19
19
|
const { tooltip, seriesData, yAxes, xAxis } = args;
|
|
20
|
-
return Object.assign(Object.assign({}, tooltip), { enabled: get(tooltip, 'enabled', true), throttle: (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.throttle) !== null && _a !== void 0 ? _a : 0, headerFormat: (_b = tooltip === null || tooltip === void 0 ? void 0 : tooltip.headerFormat) !== null && _b !== void 0 ? _b :
|
|
20
|
+
return Object.assign(Object.assign({}, tooltip), { enabled: get(tooltip, 'enabled', true), throttle: (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.throttle) !== null && _a !== void 0 ? _a : 0, headerFormat: (_b = tooltip === null || tooltip === void 0 ? void 0 : tooltip.headerFormat) !== null && _b !== void 0 ? _b : getDefaultTooltipHeaderFormat({ seriesData, yAxes, xAxis }) });
|
|
21
21
|
};
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -176,9 +176,6 @@ function unescapeHtml(str) {
|
|
|
176
176
|
return result.replace(value, key);
|
|
177
177
|
}, str);
|
|
178
178
|
}
|
|
179
|
-
function getCssStyle(prop, el = document.body) {
|
|
180
|
-
return window.getComputedStyle(el, null).getPropertyValue(prop);
|
|
181
|
-
}
|
|
182
179
|
let measureCanvas = null;
|
|
183
180
|
export function getTextSizeFn({ style }) {
|
|
184
181
|
var _a;
|
|
@@ -188,9 +185,10 @@ export function getTextSizeFn({ style }) {
|
|
|
188
185
|
throw new Error("Couldn't get canvas context");
|
|
189
186
|
}
|
|
190
187
|
const element = (_a = document.getElementsByClassName(b())[0]) !== null && _a !== void 0 ? _a : document.body;
|
|
191
|
-
const
|
|
192
|
-
const
|
|
193
|
-
const
|
|
188
|
+
const computedStyle = window.getComputedStyle(element, null);
|
|
189
|
+
const defaultFontFamily = computedStyle.getPropertyValue('font-family');
|
|
190
|
+
const defaultFontSize = computedStyle.getPropertyValue('font-size');
|
|
191
|
+
const defaultFontWeight = computedStyle.getPropertyValue('font-weight');
|
|
194
192
|
return async (str) => {
|
|
195
193
|
var _a, _b;
|
|
196
194
|
await document.fonts.ready;
|
|
@@ -66,7 +66,8 @@ export const ChartInner = (props) => {
|
|
|
66
66
|
const { allPreparedSeries, boundsHeight, boundsOffsetLeft, boundsOffsetTop, boundsWidth, handleLegendItemClick, isOutsideBounds, legendConfig, legendItems, preparedLegend, preparedSeries, preparedSeriesOptions, preparedSplit, prevHeight, prevWidth, shapes, shapesData, shapesReady, xAxis, xScale, yAxis, yScale, } = useChartInnerProps(Object.assign(Object.assign({}, props), { clipPathId,
|
|
67
67
|
dispatcher,
|
|
68
68
|
htmlLayout, plotNode: plotRef.current, preparedChart,
|
|
69
|
-
rangeSliderState,
|
|
69
|
+
rangeSliderState,
|
|
70
|
+
updateZoomState,
|
|
70
71
|
zoomState }));
|
|
71
72
|
const debouncedBoundsWidth = useDebouncedValue({
|
|
72
73
|
value: boundsWidth,
|
|
@@ -9,7 +9,6 @@ type Props = ChartInnerProps & {
|
|
|
9
9
|
htmlLayout: HTMLElement | null;
|
|
10
10
|
plotNode: SVGGElement | null;
|
|
11
11
|
preparedChart: PreparedChart;
|
|
12
|
-
svgContainer: SVGGElement | null;
|
|
13
12
|
updateZoomState: (nextZoomState: Partial<ZoomState>) => void;
|
|
14
13
|
zoomState: Partial<ZoomState>;
|
|
15
14
|
rangeSliderState?: RangeSliderState;
|
|
@@ -44,7 +43,6 @@ export declare function useChartInnerProps(props: Props): {
|
|
|
44
43
|
shapes: React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
|
|
45
44
|
shapesData: import("../../hooks").ShapeData[];
|
|
46
45
|
shapesReady: boolean;
|
|
47
|
-
svgXPos: number | undefined;
|
|
48
46
|
xAxis: import("../../hooks").PreparedXAxis | null;
|
|
49
47
|
xScale: import("../../hooks").ChartScale | undefined;
|
|
50
48
|
yAxis: (Omit<import("../..").ChartAxis, "type" | "labels" | "plotLines" | "plotBands"> & {
|
|
@@ -75,8 +75,7 @@ export function useLegend({ preparedLegend, preparedChart, preparedSeries, width
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
export function useChartInnerProps(props) {
|
|
78
|
-
|
|
79
|
-
const { clipPathId, data, dispatcher, height, htmlLayout, plotNode, preparedChart, rangeSliderState, svgContainer, width, updateZoomState, zoomState, } = props;
|
|
78
|
+
const { clipPathId, data, dispatcher, height, htmlLayout, plotNode, preparedChart, rangeSliderState, width, updateZoomState, zoomState, } = props;
|
|
80
79
|
const prevWidth = usePrevious(width);
|
|
81
80
|
const prevHeight = usePrevious(height);
|
|
82
81
|
const colors = React.useMemo(() => {
|
|
@@ -214,7 +213,6 @@ export function useChartInnerProps(props) {
|
|
|
214
213
|
getYAxisWidth,
|
|
215
214
|
legendConfig,
|
|
216
215
|
});
|
|
217
|
-
const { x } = (_a = svgContainer === null || svgContainer === void 0 ? void 0 : svgContainer.getBoundingClientRect()) !== null && _a !== void 0 ? _a : {};
|
|
218
216
|
return {
|
|
219
217
|
allPreparedSeries,
|
|
220
218
|
boundsHeight,
|
|
@@ -234,7 +232,6 @@ export function useChartInnerProps(props) {
|
|
|
234
232
|
shapes,
|
|
235
233
|
shapesData,
|
|
236
234
|
shapesReady,
|
|
237
|
-
svgXPos: x,
|
|
238
235
|
xAxis,
|
|
239
236
|
xScale,
|
|
240
237
|
yAxis,
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { ChartData, ChartSeries, ChartXAxis, ChartYAxis } from '../../types';
|
|
2
2
|
import type { PreparedTooltip } from './types';
|
|
3
|
+
export declare function getDefaultTooltipHeaderFormat({ seriesData, yAxes, xAxis, }: {
|
|
4
|
+
seriesData: ChartSeries[];
|
|
5
|
+
yAxes?: ChartYAxis[];
|
|
6
|
+
xAxis?: ChartXAxis;
|
|
7
|
+
}): import("../..").ValueFormat | undefined;
|
|
3
8
|
export declare const getPreparedTooltip: (args: {
|
|
4
9
|
tooltip: ChartData["tooltip"];
|
|
5
10
|
seriesData: ChartSeries[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
2
|
import { getDefaultValueFormat } from '../../components/Tooltip/DefaultTooltipContent/utils';
|
|
3
3
|
import { getDomainDataXBySeries, getDomainDataYBySeries, getMinSpaceBetween } from '../../utils';
|
|
4
|
-
function
|
|
4
|
+
export function getDefaultTooltipHeaderFormat({ seriesData, yAxes, xAxis, }) {
|
|
5
5
|
if (seriesData.every((item) => ['pie', 'treemap', 'waterfall', 'sankey', 'radar', 'heatmap', 'funnel'].includes(item.type))) {
|
|
6
6
|
return undefined;
|
|
7
7
|
}
|
|
@@ -17,5 +17,5 @@ function getDefaultHeaderFormat({ seriesData, yAxes, xAxis, }) {
|
|
|
17
17
|
export const getPreparedTooltip = (args) => {
|
|
18
18
|
var _a, _b;
|
|
19
19
|
const { tooltip, seriesData, yAxes, xAxis } = args;
|
|
20
|
-
return Object.assign(Object.assign({}, tooltip), { enabled: get(tooltip, 'enabled', true), throttle: (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.throttle) !== null && _a !== void 0 ? _a : 0, headerFormat: (_b = tooltip === null || tooltip === void 0 ? void 0 : tooltip.headerFormat) !== null && _b !== void 0 ? _b :
|
|
20
|
+
return Object.assign(Object.assign({}, tooltip), { enabled: get(tooltip, 'enabled', true), throttle: (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.throttle) !== null && _a !== void 0 ? _a : 0, headerFormat: (_b = tooltip === null || tooltip === void 0 ? void 0 : tooltip.headerFormat) !== null && _b !== void 0 ? _b : getDefaultTooltipHeaderFormat({ seriesData, yAxes, xAxis }) });
|
|
21
21
|
};
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -176,9 +176,6 @@ function unescapeHtml(str) {
|
|
|
176
176
|
return result.replace(value, key);
|
|
177
177
|
}, str);
|
|
178
178
|
}
|
|
179
|
-
function getCssStyle(prop, el = document.body) {
|
|
180
|
-
return window.getComputedStyle(el, null).getPropertyValue(prop);
|
|
181
|
-
}
|
|
182
179
|
let measureCanvas = null;
|
|
183
180
|
export function getTextSizeFn({ style }) {
|
|
184
181
|
var _a;
|
|
@@ -188,9 +185,10 @@ export function getTextSizeFn({ style }) {
|
|
|
188
185
|
throw new Error("Couldn't get canvas context");
|
|
189
186
|
}
|
|
190
187
|
const element = (_a = document.getElementsByClassName(b())[0]) !== null && _a !== void 0 ? _a : document.body;
|
|
191
|
-
const
|
|
192
|
-
const
|
|
193
|
-
const
|
|
188
|
+
const computedStyle = window.getComputedStyle(element, null);
|
|
189
|
+
const defaultFontFamily = computedStyle.getPropertyValue('font-family');
|
|
190
|
+
const defaultFontSize = computedStyle.getPropertyValue('font-size');
|
|
191
|
+
const defaultFontWeight = computedStyle.getPropertyValue('font-weight');
|
|
194
192
|
return async (str) => {
|
|
195
193
|
var _a, _b;
|
|
196
194
|
await document.fonts.ready;
|