@gravity-ui/charts 1.38.5 → 1.38.7
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/AxisX/prepare-axis-data.d.ts +1 -1
- package/dist/cjs/components/AxisX/prepare-axis-data.js +10 -9
- package/dist/cjs/components/AxisY/prepare-axis-data.d.ts +1 -1
- package/dist/cjs/components/AxisY/prepare-axis-data.js +2 -2
- package/dist/cjs/components/ChartInner/index.js +8 -3
- package/dist/cjs/components/ChartInner/useChartInnerProps.d.ts +18 -19
- package/dist/cjs/components/ChartInner/useChartInnerProps.js +232 -138
- package/dist/cjs/components/ChartInner/useChartInnerState.js +2 -1
- package/dist/cjs/components/Legend/index.d.ts +1 -1
- package/dist/cjs/components/Legend/index.js +1 -1
- package/dist/cjs/hooks/useAxis/index.d.ts +40 -5
- package/dist/cjs/hooks/useAxis/index.js +55 -41
- package/dist/cjs/hooks/useAxis/types.d.ts +0 -2
- package/dist/cjs/hooks/useAxisScales/index.d.ts +4 -0
- package/dist/cjs/hooks/useAxisScales/index.js +1 -1
- package/dist/cjs/hooks/useChartDimensions/index.d.ts +1 -1
- package/dist/cjs/hooks/useChartDimensions/index.js +14 -29
- package/dist/cjs/hooks/useCrosshair/index.d.ts +1 -1
- package/dist/cjs/hooks/useNormalizedOriginalData/index.d.ts +29 -34
- package/dist/cjs/hooks/useNormalizedOriginalData/index.js +19 -30
- package/dist/cjs/hooks/useSeries/index.d.ts +10 -14
- package/dist/cjs/hooks/useSeries/index.js +8 -80
- package/dist/cjs/hooks/useShapes/index.d.ts +4 -0
- package/dist/cjs/hooks/useShapes/index.js +194 -189
- package/dist/cjs/hooks/useSplit/index.d.ts +5 -2
- package/dist/cjs/hooks/useSplit/index.js +27 -30
- package/dist/cjs/hooks/useYAxisLabelWidth/index.d.ts +39 -6
- package/dist/cjs/hooks/useYAxisLabelWidth/index.js +30 -43
- package/dist/cjs/hooks/useZoom/index.d.ts +1 -1
- package/dist/cjs/hooks/useZoom/index.js +2 -2
- package/dist/cjs/utils/chart/axis/common.d.ts +1 -1
- package/dist/cjs/utils/chart/axis/common.js +1 -1
- package/dist/esm/components/AxisX/prepare-axis-data.d.ts +1 -1
- package/dist/esm/components/AxisX/prepare-axis-data.js +10 -9
- package/dist/esm/components/AxisY/prepare-axis-data.d.ts +1 -1
- package/dist/esm/components/AxisY/prepare-axis-data.js +2 -2
- package/dist/esm/components/ChartInner/index.js +8 -3
- package/dist/esm/components/ChartInner/useChartInnerProps.d.ts +18 -19
- package/dist/esm/components/ChartInner/useChartInnerProps.js +232 -138
- package/dist/esm/components/ChartInner/useChartInnerState.js +2 -1
- package/dist/esm/components/Legend/index.d.ts +1 -1
- package/dist/esm/components/Legend/index.js +1 -1
- package/dist/esm/hooks/useAxis/index.d.ts +40 -5
- package/dist/esm/hooks/useAxis/index.js +55 -41
- package/dist/esm/hooks/useAxis/types.d.ts +0 -2
- package/dist/esm/hooks/useAxisScales/index.d.ts +4 -0
- package/dist/esm/hooks/useAxisScales/index.js +1 -1
- package/dist/esm/hooks/useChartDimensions/index.d.ts +1 -1
- package/dist/esm/hooks/useChartDimensions/index.js +14 -29
- package/dist/esm/hooks/useCrosshair/index.d.ts +1 -1
- package/dist/esm/hooks/useNormalizedOriginalData/index.d.ts +29 -34
- package/dist/esm/hooks/useNormalizedOriginalData/index.js +19 -30
- package/dist/esm/hooks/useSeries/index.d.ts +10 -14
- package/dist/esm/hooks/useSeries/index.js +8 -80
- package/dist/esm/hooks/useShapes/index.d.ts +4 -0
- package/dist/esm/hooks/useShapes/index.js +194 -189
- package/dist/esm/hooks/useSplit/index.d.ts +5 -2
- package/dist/esm/hooks/useSplit/index.js +27 -30
- package/dist/esm/hooks/useYAxisLabelWidth/index.d.ts +39 -6
- package/dist/esm/hooks/useYAxisLabelWidth/index.js +30 -43
- package/dist/esm/hooks/useZoom/index.d.ts +1 -1
- package/dist/esm/hooks/useZoom/index.js +2 -2
- package/dist/esm/utils/chart/axis/common.d.ts +1 -1
- package/dist/esm/utils/chart/axis/common.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/components/ChartInner/useLegend.d.ts +0 -14
- package/dist/cjs/components/ChartInner/useLegend.js +0 -34
- package/dist/esm/components/ChartInner/useLegend.d.ts +0 -14
- package/dist/esm/components/ChartInner/useLegend.js +0 -34
package/package.json
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { LegendItem, PreparedChart, PreparedLegend, PreparedSeries } from '../../hooks';
|
|
2
|
-
import type { LegendConfig } from '../../types';
|
|
3
|
-
type LegendState = {
|
|
4
|
-
legendConfig?: LegendConfig;
|
|
5
|
-
legendItems: LegendItem[][];
|
|
6
|
-
};
|
|
7
|
-
export declare function useLegend({ preparedLegend, preparedChart, preparedSeries, width, height, }: {
|
|
8
|
-
preparedLegend: PreparedLegend | null;
|
|
9
|
-
preparedChart: PreparedChart;
|
|
10
|
-
preparedSeries: PreparedSeries[];
|
|
11
|
-
width: number;
|
|
12
|
-
height: number;
|
|
13
|
-
}): LegendState;
|
|
14
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import isEqual from 'lodash/isEqual';
|
|
3
|
-
import { getLegendComponents } from '../../hooks/useSeries/prepare-legend';
|
|
4
|
-
export function useLegend({ preparedLegend, preparedChart, preparedSeries, width, height, }) {
|
|
5
|
-
const [legendState, setLegend] = React.useState({
|
|
6
|
-
legendConfig: undefined,
|
|
7
|
-
legendItems: [],
|
|
8
|
-
});
|
|
9
|
-
const legendStateRunRef = React.useRef(0);
|
|
10
|
-
const prevLegendStateValue = React.useRef(legendState);
|
|
11
|
-
React.useEffect(() => {
|
|
12
|
-
legendStateRunRef.current++;
|
|
13
|
-
const currentRun = legendStateRunRef.current;
|
|
14
|
-
if (!preparedLegend) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
(async function () {
|
|
18
|
-
const newStateValue = await getLegendComponents({
|
|
19
|
-
chartWidth: width,
|
|
20
|
-
chartHeight: height,
|
|
21
|
-
chartMargin: preparedChart.margin,
|
|
22
|
-
series: preparedSeries,
|
|
23
|
-
preparedLegend,
|
|
24
|
-
});
|
|
25
|
-
if (legendStateRunRef.current === currentRun) {
|
|
26
|
-
if (!isEqual(prevLegendStateValue.current, newStateValue)) {
|
|
27
|
-
setLegend(newStateValue);
|
|
28
|
-
prevLegendStateValue.current = newStateValue;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
})();
|
|
32
|
-
}, [height, preparedChart.margin, preparedLegend, preparedSeries, width]);
|
|
33
|
-
return legendState;
|
|
34
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { LegendItem, PreparedChart, PreparedLegend, PreparedSeries } from '../../hooks';
|
|
2
|
-
import type { LegendConfig } from '../../types';
|
|
3
|
-
type LegendState = {
|
|
4
|
-
legendConfig?: LegendConfig;
|
|
5
|
-
legendItems: LegendItem[][];
|
|
6
|
-
};
|
|
7
|
-
export declare function useLegend({ preparedLegend, preparedChart, preparedSeries, width, height, }: {
|
|
8
|
-
preparedLegend: PreparedLegend | null;
|
|
9
|
-
preparedChart: PreparedChart;
|
|
10
|
-
preparedSeries: PreparedSeries[];
|
|
11
|
-
width: number;
|
|
12
|
-
height: number;
|
|
13
|
-
}): LegendState;
|
|
14
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import isEqual from 'lodash/isEqual';
|
|
3
|
-
import { getLegendComponents } from '../../hooks/useSeries/prepare-legend';
|
|
4
|
-
export function useLegend({ preparedLegend, preparedChart, preparedSeries, width, height, }) {
|
|
5
|
-
const [legendState, setLegend] = React.useState({
|
|
6
|
-
legendConfig: undefined,
|
|
7
|
-
legendItems: [],
|
|
8
|
-
});
|
|
9
|
-
const legendStateRunRef = React.useRef(0);
|
|
10
|
-
const prevLegendStateValue = React.useRef(legendState);
|
|
11
|
-
React.useEffect(() => {
|
|
12
|
-
legendStateRunRef.current++;
|
|
13
|
-
const currentRun = legendStateRunRef.current;
|
|
14
|
-
if (!preparedLegend) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
(async function () {
|
|
18
|
-
const newStateValue = await getLegendComponents({
|
|
19
|
-
chartWidth: width,
|
|
20
|
-
chartHeight: height,
|
|
21
|
-
chartMargin: preparedChart.margin,
|
|
22
|
-
series: preparedSeries,
|
|
23
|
-
preparedLegend,
|
|
24
|
-
});
|
|
25
|
-
if (legendStateRunRef.current === currentRun) {
|
|
26
|
-
if (!isEqual(prevLegendStateValue.current, newStateValue)) {
|
|
27
|
-
setLegend(newStateValue);
|
|
28
|
-
prevLegendStateValue.current = newStateValue;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
})();
|
|
32
|
-
}, [height, preparedChart.margin, preparedLegend, preparedSeries, width]);
|
|
33
|
-
return legendState;
|
|
34
|
-
}
|