@gravity-ui/charts 1.27.1 → 1.27.2
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/hooks/useAxis/index.js +2 -1
- package/dist/cjs/hooks/useAxis/x-axis.js +1 -1
- package/dist/cjs/utils/chart/axis/x-axis.js +3 -3
- package/dist/esm/hooks/useAxis/index.js +2 -1
- package/dist/esm/hooks/useAxis/x-axis.js +1 -1
- package/dist/esm/utils/chart/axis/x-axis.js +3 -3
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import isEqual from 'lodash/isEqual';
|
|
3
|
+
import { getWidthOccupiedByYAxis } from '../useChartDimensions/utils';
|
|
3
4
|
import { getPreparedXAxis } from './x-axis';
|
|
4
5
|
import { getPreparedYAxis } from './y-axis';
|
|
5
6
|
export function useAxis(props) {
|
|
@@ -21,7 +22,7 @@ export function useAxis(props) {
|
|
|
21
22
|
seriesData,
|
|
22
23
|
yAxis,
|
|
23
24
|
});
|
|
24
|
-
const axesWidth =
|
|
25
|
+
const axesWidth = getWidthOccupiedByYAxis({ preparedAxis: estimatedPreparedYAxis });
|
|
25
26
|
const estimatedBoundsWidth = width - (axesWidth + preparedChart.margin.left + preparedChart.margin.right);
|
|
26
27
|
const preparedXAxis = await getPreparedXAxis({
|
|
27
28
|
xAxis,
|
|
@@ -17,7 +17,7 @@ async function setLabelSettings({ axis, seriesData, width, axisLabels, }) {
|
|
|
17
17
|
const labelLineHeight = (await getTextSize('Tmp')).height;
|
|
18
18
|
const tickValues = getXAxisTickValues({ axis, scale, labelLineHeight });
|
|
19
19
|
const tickStep = getMinSpaceBetween(tickValues, (d) => Number(d.value));
|
|
20
|
-
if (axis.type === 'datetime' && !
|
|
20
|
+
if (axis.type === 'datetime' && !(axisLabels === null || axisLabels === void 0 ? void 0 : axisLabels.dateFormat)) {
|
|
21
21
|
axis.labels.dateFormat = getDefaultDateFormat(tickStep);
|
|
22
22
|
}
|
|
23
23
|
const labels = tickValues.map((tick) => formatAxisTickLabel({
|
|
@@ -3,11 +3,11 @@ import { getTicksCount, isBandScale, thinOut } from './common';
|
|
|
3
3
|
export function getXAxisTickValues({ scale, axis, labelLineHeight, }) {
|
|
4
4
|
if ('ticks' in scale && typeof scale.ticks === 'function') {
|
|
5
5
|
const range = scale.range();
|
|
6
|
-
const
|
|
7
|
-
if (!
|
|
6
|
+
const axisWidth = Math.abs(range[0] - range[1]);
|
|
7
|
+
if (!axisWidth) {
|
|
8
8
|
return [];
|
|
9
9
|
}
|
|
10
|
-
const scaleTicksCount = getTicksCount({ axis, range:
|
|
10
|
+
const scaleTicksCount = getTicksCount({ axis, range: axisWidth });
|
|
11
11
|
const scaleTicks = scale.ticks(scaleTicksCount);
|
|
12
12
|
const originalTickValues = scaleTicks.map((t) => ({
|
|
13
13
|
x: scale(t),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import isEqual from 'lodash/isEqual';
|
|
3
|
+
import { getWidthOccupiedByYAxis } from '../useChartDimensions/utils';
|
|
3
4
|
import { getPreparedXAxis } from './x-axis';
|
|
4
5
|
import { getPreparedYAxis } from './y-axis';
|
|
5
6
|
export function useAxis(props) {
|
|
@@ -21,7 +22,7 @@ export function useAxis(props) {
|
|
|
21
22
|
seriesData,
|
|
22
23
|
yAxis,
|
|
23
24
|
});
|
|
24
|
-
const axesWidth =
|
|
25
|
+
const axesWidth = getWidthOccupiedByYAxis({ preparedAxis: estimatedPreparedYAxis });
|
|
25
26
|
const estimatedBoundsWidth = width - (axesWidth + preparedChart.margin.left + preparedChart.margin.right);
|
|
26
27
|
const preparedXAxis = await getPreparedXAxis({
|
|
27
28
|
xAxis,
|
|
@@ -17,7 +17,7 @@ async function setLabelSettings({ axis, seriesData, width, axisLabels, }) {
|
|
|
17
17
|
const labelLineHeight = (await getTextSize('Tmp')).height;
|
|
18
18
|
const tickValues = getXAxisTickValues({ axis, scale, labelLineHeight });
|
|
19
19
|
const tickStep = getMinSpaceBetween(tickValues, (d) => Number(d.value));
|
|
20
|
-
if (axis.type === 'datetime' && !
|
|
20
|
+
if (axis.type === 'datetime' && !(axisLabels === null || axisLabels === void 0 ? void 0 : axisLabels.dateFormat)) {
|
|
21
21
|
axis.labels.dateFormat = getDefaultDateFormat(tickStep);
|
|
22
22
|
}
|
|
23
23
|
const labels = tickValues.map((tick) => formatAxisTickLabel({
|
|
@@ -3,11 +3,11 @@ import { getTicksCount, isBandScale, thinOut } from './common';
|
|
|
3
3
|
export function getXAxisTickValues({ scale, axis, labelLineHeight, }) {
|
|
4
4
|
if ('ticks' in scale && typeof scale.ticks === 'function') {
|
|
5
5
|
const range = scale.range();
|
|
6
|
-
const
|
|
7
|
-
if (!
|
|
6
|
+
const axisWidth = Math.abs(range[0] - range[1]);
|
|
7
|
+
if (!axisWidth) {
|
|
8
8
|
return [];
|
|
9
9
|
}
|
|
10
|
-
const scaleTicksCount = getTicksCount({ axis, range:
|
|
10
|
+
const scaleTicksCount = getTicksCount({ axis, range: axisWidth });
|
|
11
11
|
const scaleTicks = scale.ticks(scaleTicksCount);
|
|
12
12
|
const originalTickValues = scaleTicks.map((t) => ({
|
|
13
13
|
x: scale(t),
|