@evergis/charts 4.0.47 → 4.0.48
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/charts/LineChart/drawLabel/index.d.ts +1 -1
- package/dist/charts/LineChart/drawLabel/types.d.ts +3 -2
- package/dist/charts/LineChart/drawTooltip/index.d.ts +1 -1
- package/dist/charts/LineChart/drawTooltip/types.d.ts +4 -1
- package/dist/charts/LineChart/types.d.ts +15 -1
- package/dist/charts.esm.js +86 -51
- package/dist/charts.esm.js.map +1 -1
- package/dist/index.js +86 -51
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DrawLabelProps } from './types';
|
|
2
2
|
export declare const labelClassName = "d3-chart-label";
|
|
3
|
-
export declare const drawLabel: ({ node, data,
|
|
3
|
+
export declare const drawLabel: ({ node, data, yScaleOf, xScale, formatLabel, eachLabel, }: DrawLabelProps) => void;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { LineChartProps } from '../types';
|
|
1
|
+
import { LineChartProps, LineChartScaleResolver } from '../types';
|
|
2
2
|
import * as d3 from 'd3';
|
|
3
3
|
export type DrawLabelProps = {
|
|
4
4
|
node: HTMLElement;
|
|
5
|
-
|
|
5
|
+
/** Шкала значений выбирается по серии: у правой оси она своя. */
|
|
6
|
+
yScaleOf: LineChartScaleResolver;
|
|
6
7
|
xScale: d3.ScaleLinear<number, number>;
|
|
7
8
|
} & Pick<LineChartProps, 'data' | 'formatLabel' | 'eachLabel'>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DrawTooltipProps } from './types';
|
|
2
|
-
export declare const drawTooltip: ({ svg, node, data: argData, xScale, yScale, dynamicCircleRadius, formatDynamicTooltip, renderTooltip, stackedTooltipIndex, stackedTooltip, tooltipLineTop, tooltipRoot, tooltipClassName, dotSnapping, lastIndex, }: DrawTooltipProps) => void;
|
|
2
|
+
export declare const drawTooltip: ({ svg, node, data: argData, xScale, yScale, yScaleOf, dynamicCircleRadius, formatDynamicTooltip, renderTooltip, stackedTooltipIndex, stackedTooltip, tooltipLineTop, tooltipRoot, tooltipClassName, dotSnapping, lastIndex, }: DrawTooltipProps) => void;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { LineChartProps } from '../types';
|
|
1
|
+
import { LineChartProps, LineChartScaleResolver } from '../types';
|
|
2
2
|
import * as d3 from 'd3';
|
|
3
3
|
export type DrawTooltipProps = {
|
|
4
4
|
svg: d3.Selection<SVGSVGElement, unknown, null, undefined>;
|
|
5
5
|
node: HTMLElement;
|
|
6
|
+
/** Основная шкала — нужна только для вертикальных границ области наведения. */
|
|
6
7
|
yScale: d3.ScaleLinear<number, number>;
|
|
8
|
+
/** Шкала значений выбирается по серии: у правой оси она своя. */
|
|
9
|
+
yScaleOf: LineChartScaleResolver;
|
|
7
10
|
xScale: d3.ScaleLinear<number, number>;
|
|
8
11
|
lastIndex: number;
|
|
9
12
|
} & Pick<LineChartProps, 'data' | 'dynamicCircleRadius' | 'formatDynamicTooltip' | 'renderTooltip' | 'stackedTooltipIndex' | 'stackedTooltip' | 'tooltipLineTop' | 'tooltipRoot' | 'tooltipClassName' | 'dotSnapping'>;
|
|
@@ -3,6 +3,10 @@ import { Margin } from '../../common/types/margin';
|
|
|
3
3
|
import { BarChartMarker } from '../BarChart/types';
|
|
4
4
|
import * as d3 from 'd3';
|
|
5
5
|
export type LineChartCustomAxis = (axis: d3.Axis<d3.NumberValue>) => void;
|
|
6
|
+
/** Сторона, на которой выводится шкала значений и к которой привязана серия. */
|
|
7
|
+
export type LineChartAxisSide = 'left' | 'right';
|
|
8
|
+
/** Возвращает шкалу значений, по которой строится переданная серия. */
|
|
9
|
+
export type LineChartScaleResolver = (series: Pick<LineChartData, 'axis'> | undefined) => d3.ScaleLinear<number, number>;
|
|
6
10
|
type LineChartCustomAxisSelection = (selection: d3.Selection<SVGGElement, unknown, null, undefined>) => void;
|
|
7
11
|
export interface LineChartProps extends PropsWithChildren {
|
|
8
12
|
className?: string;
|
|
@@ -13,6 +17,8 @@ export interface LineChartProps extends PropsWithChildren {
|
|
|
13
17
|
margin?: Margin;
|
|
14
18
|
labels?: (string | number)[];
|
|
15
19
|
customYAxis?: LineChartCustomAxis;
|
|
20
|
+
/** Применяется к правой шкале; если не задан — используется customYAxis. */
|
|
21
|
+
customYAxisRight?: LineChartCustomAxis;
|
|
16
22
|
customXAxis?: LineChartCustomAxis;
|
|
17
23
|
customYAxisSelection?: LineChartCustomAxisSelection;
|
|
18
24
|
customXAxisSelection?: LineChartCustomAxisSelection;
|
|
@@ -22,8 +28,12 @@ export interface LineChartProps extends PropsWithChildren {
|
|
|
22
28
|
areaCurve?: d3.CurveFactory;
|
|
23
29
|
drawGridY?: boolean;
|
|
24
30
|
drawGridX?: boolean;
|
|
31
|
+
/** Границы левой шкалы. По умолчанию считаются по сериям с axis !== "right". */
|
|
25
32
|
min?: number;
|
|
26
33
|
max?: number;
|
|
34
|
+
/** Границы правой шкалы. По умолчанию считаются по сериям с axis === "right". */
|
|
35
|
+
rightMin?: number;
|
|
36
|
+
rightMax?: number;
|
|
27
37
|
stacked?: boolean;
|
|
28
38
|
formatLabel?: (value: number, index: number, label: HTMLDivElement[]) => string | number;
|
|
29
39
|
withLabels?: boolean;
|
|
@@ -42,7 +52,10 @@ export interface LineChartProps extends PropsWithChildren {
|
|
|
42
52
|
tooltipLineTop?: boolean;
|
|
43
53
|
customize?: (args: {
|
|
44
54
|
svg: d3.Selection<SVGSVGElement, unknown, null, undefined>;
|
|
55
|
+
/** Левая шкала. */
|
|
45
56
|
yScale: d3.ScaleLinear<number, number>;
|
|
57
|
+
/** Правая шкала; undefined, если серий на правой оси нет. */
|
|
58
|
+
yScaleRight?: d3.ScaleLinear<number, number>;
|
|
46
59
|
xScale: d3.ScaleLinear<number, number>;
|
|
47
60
|
}) => void;
|
|
48
61
|
customYScale?: (yScale: (value: number) => number) => void;
|
|
@@ -51,7 +64,6 @@ export interface LineChartProps extends PropsWithChildren {
|
|
|
51
64
|
tooltipClassName?: string;
|
|
52
65
|
xScaleItemWidth?: number;
|
|
53
66
|
dotSnapping?: boolean;
|
|
54
|
-
rightAxis?: number[];
|
|
55
67
|
markers?: BarChartMarker[];
|
|
56
68
|
transitionDuration?: number;
|
|
57
69
|
}
|
|
@@ -62,6 +74,8 @@ export type LineChartDot = {
|
|
|
62
74
|
};
|
|
63
75
|
export type LineChartData = {
|
|
64
76
|
name?: string;
|
|
77
|
+
/** Шкала значений, по которой строится серия. По умолчанию "left". */
|
|
78
|
+
axis?: LineChartAxisSide;
|
|
65
79
|
values: (number | null)[];
|
|
66
80
|
minAreaValues?: (number | null)[];
|
|
67
81
|
stroke?: string;
|
package/dist/charts.esm.js
CHANGED
|
@@ -1644,14 +1644,15 @@ const Label = styled.div `
|
|
|
1644
1644
|
`;
|
|
1645
1645
|
|
|
1646
1646
|
const labelClassName = "d3-chart-label";
|
|
1647
|
-
const drawLabel = ({ node, data,
|
|
1647
|
+
const drawLabel = ({ node, data, yScaleOf, xScale, formatLabel, eachLabel, }) => {
|
|
1648
1648
|
const labelsDiv = d3
|
|
1649
1649
|
.select(node)
|
|
1650
1650
|
.append("div")
|
|
1651
1651
|
.attr("class", labelClassName);
|
|
1652
1652
|
const format = d3.format(",");
|
|
1653
|
-
|
|
1654
|
-
|
|
1653
|
+
data.forEach(series => {
|
|
1654
|
+
const values = series.values;
|
|
1655
|
+
const yScale = yScaleOf(series);
|
|
1655
1656
|
labelsDiv
|
|
1656
1657
|
.append("div")
|
|
1657
1658
|
.selectAll("div")
|
|
@@ -1670,7 +1671,7 @@ const drawLabel = ({ node, data, yScale, xScale, formatLabel, eachLabel, }) => {
|
|
|
1670
1671
|
});
|
|
1671
1672
|
};
|
|
1672
1673
|
|
|
1673
|
-
const drawTooltip$2 = ({ svg, node, data: argData, xScale, yScale, dynamicCircleRadius, formatDynamicTooltip, renderTooltip, stackedTooltipIndex, stackedTooltip, tooltipLineTop, tooltipRoot, tooltipClassName, dotSnapping, lastIndex, }) => {
|
|
1674
|
+
const drawTooltip$2 = ({ svg, node, data: argData, xScale, yScale, yScaleOf, dynamicCircleRadius, formatDynamicTooltip, renderTooltip, stackedTooltipIndex, stackedTooltip, tooltipLineTop, tooltipRoot, tooltipClassName, dotSnapping, lastIndex, }) => {
|
|
1674
1675
|
const container = tooltipRoot || document.querySelector("body");
|
|
1675
1676
|
const format = d3.format(",");
|
|
1676
1677
|
const chartData = argData.filter(({ tooltipOff }) => !tooltipOff);
|
|
@@ -1779,7 +1780,7 @@ const drawTooltip$2 = ({ svg, node, data: argData, xScale, yScale, dynamicCircle
|
|
|
1779
1780
|
positions[index] = {
|
|
1780
1781
|
x: x1 + Math.round(currIndex) * step,
|
|
1781
1782
|
y: typeof argData[index].values[Math.round(currIndex)] === "number"
|
|
1782
|
-
?
|
|
1783
|
+
? yScaleOf(argData[index])(argData[index].values[Math.round(currIndex)])
|
|
1783
1784
|
: 0,
|
|
1784
1785
|
};
|
|
1785
1786
|
}
|
|
@@ -1795,7 +1796,7 @@ const drawTooltip$2 = ({ svg, node, data: argData, xScale, yScale, dynamicCircle
|
|
|
1795
1796
|
const datas = chartData.map(({ values, ...rest }, i) => ({
|
|
1796
1797
|
...rest,
|
|
1797
1798
|
value: getValue(values),
|
|
1798
|
-
invertValue: positions[i] ?
|
|
1799
|
+
invertValue: positions[i] ? yScaleOf(rest).invert(positions[i].y) : 0,
|
|
1799
1800
|
}));
|
|
1800
1801
|
const noHasData = datas.every(({ value }) => isVoid(value));
|
|
1801
1802
|
if (noHasData && isVisible) {
|
|
@@ -1883,7 +1884,7 @@ const drawTooltip$2 = ({ svg, node, data: argData, xScale, yScale, dynamicCircle
|
|
|
1883
1884
|
};
|
|
1884
1885
|
|
|
1885
1886
|
const draw$2 = (node, props) => {
|
|
1886
|
-
const { data: chartData, labels, margin, customYAxisSelection, customXAxisSelection, customYAxis, customXAxis, curve, yAxisPadding, xAxisPadding, drawGridY, drawGridX, withLabels, formatLabel, eachLabel, stacked, dynamicTooltipEnable, dynamicCircleRadius, formatDynamicTooltip, renderTooltip, stackedTooltip, stackedTooltipIndex, tooltipLineTop, customize, customYScale, customLine, tooltipClassName, xScaleItemWidth, areaCurve, dotSnapping,
|
|
1887
|
+
const { data: chartData, labels, margin, customYAxisSelection, customXAxisSelection, customYAxis, customYAxisRight, customXAxis, curve, yAxisPadding, xAxisPadding, drawGridY, drawGridX, withLabels, formatLabel, eachLabel, stacked, dynamicTooltipEnable, dynamicCircleRadius, formatDynamicTooltip, renderTooltip, stackedTooltip, stackedTooltipIndex, tooltipLineTop, customize, customYScale, customLine, tooltipClassName, xScaleItemWidth, areaCurve, dotSnapping, markers, transitionDuration = 300, } = props;
|
|
1887
1888
|
if (node !== null && chartData.length) {
|
|
1888
1889
|
const data = stacked ? stackedData(chartData) : chartData;
|
|
1889
1890
|
const marginTop = margin ? margin.top : 0;
|
|
@@ -1893,12 +1894,21 @@ const draw$2 = (node, props) => {
|
|
|
1893
1894
|
const { width: nodeWidth } = node.getBoundingClientRect();
|
|
1894
1895
|
const width = props.width || nodeWidth;
|
|
1895
1896
|
const height = props.height || 0;
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
const
|
|
1900
|
-
|
|
1901
|
-
|
|
1897
|
+
// Серии разводятся по двум шкалам: без axis серия считается левой, поэтому график с одной
|
|
1898
|
+
// осью ведёт себя ровно как раньше — правая шкала не создаётся и геометрия не меняется.
|
|
1899
|
+
const isRightSeries = ({ axis }) => axis === 'right';
|
|
1900
|
+
const leftData = data.filter(series => !isRightSeries(series));
|
|
1901
|
+
const rightData = data.filter(isRightSeries);
|
|
1902
|
+
const hasLeftAxis = leftData.length > 0;
|
|
1903
|
+
const hasRightAxis = rightData.length > 0;
|
|
1904
|
+
const domainOf = (series, propMin, propMax) => [
|
|
1905
|
+
typeof propMin === 'number'
|
|
1906
|
+
? propMin
|
|
1907
|
+
: d3.min(series, ({ values }) => d3.min(values)) || 0,
|
|
1908
|
+
typeof propMax === 'number'
|
|
1909
|
+
? propMax
|
|
1910
|
+
: d3.max(series, ({ values }) => d3.max(values)) || 0,
|
|
1911
|
+
];
|
|
1902
1912
|
const prevStrokes = new Map();
|
|
1903
1913
|
if (transitionDuration > 0) {
|
|
1904
1914
|
d3.select(node)
|
|
@@ -1914,32 +1924,48 @@ const draw$2 = (node, props) => {
|
|
|
1914
1924
|
];
|
|
1915
1925
|
const yScale = d3
|
|
1916
1926
|
.scaleLinear()
|
|
1917
|
-
.domain(
|
|
1927
|
+
.domain(domainOf(hasLeftAxis ? leftData : data, props.min, props.max))
|
|
1918
1928
|
.range(yRange)
|
|
1919
1929
|
.nice();
|
|
1930
|
+
const yScaleRight = hasRightAxis
|
|
1931
|
+
? d3
|
|
1932
|
+
.scaleLinear()
|
|
1933
|
+
.domain(domainOf(rightData, props.rightMin, props.rightMax))
|
|
1934
|
+
.range(yRange)
|
|
1935
|
+
.nice()
|
|
1936
|
+
: undefined;
|
|
1937
|
+
// Основная шкала — левая; если левых серий нет, её место занимает правая, чтобы сетка,
|
|
1938
|
+
// маркеры и customize получили осмысленную шкалу.
|
|
1939
|
+
const primaryScale = hasLeftAxis || !yScaleRight ? yScale : yScaleRight;
|
|
1940
|
+
const scaleOf = series => series && isRightSeries(series) && yScaleRight ? yScaleRight : primaryScale;
|
|
1920
1941
|
customYScale && customYScale(yScale);
|
|
1921
1942
|
const yTicksCountDefault = 8;
|
|
1922
1943
|
const yAxisLeft = d3.axisLeft(yScale).ticks(yTicksCountDefault);
|
|
1923
1944
|
customYAxis && customYAxis(yAxisLeft);
|
|
1924
|
-
const yTicksCount = yAxisLeft.tickArguments()[0];
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1945
|
+
const yTicksCount = yAxisLeft.tickArguments()[0] ?? yTicksCountDefault;
|
|
1946
|
+
// Деления двух шкал должны попадать на одни и те же высоты, иначе линии сетки идут по левой
|
|
1947
|
+
// оси, а подписи правой висят между ними. `nice` с явным числом делений округляет домен так,
|
|
1948
|
+
// что обе оси дают одинаковое их количество. Для графика с одной осью домен не трогаем —
|
|
1949
|
+
// иначе поменялась бы геометрия уже существующих графиков.
|
|
1950
|
+
if (hasLeftAxis && yScaleRight) {
|
|
1951
|
+
yScale.nice(yTicksCount);
|
|
1952
|
+
yScaleRight.nice(yTicksCount);
|
|
1953
|
+
}
|
|
1954
|
+
let yAxisWidth = 0;
|
|
1955
|
+
if (hasLeftAxis) {
|
|
1956
|
+
const yAxis = svg
|
|
1957
|
+
.append('g')
|
|
1958
|
+
.attr('class', lineChartClassNames.lineChartYScaleGlobal)
|
|
1959
|
+
.call(yAxisLeft)
|
|
1960
|
+
.call(customYAxisSelection ? customYAxisSelection : none);
|
|
1961
|
+
({ width: yAxisWidth } = computeDimensions(yAxis));
|
|
1962
|
+
yAxis.attr('transform', `translate(${marginLeft + yAxisWidth}, 0)`);
|
|
1963
|
+
}
|
|
1932
1964
|
let yAxisRightWidth = 0;
|
|
1933
1965
|
const left = marginLeft + yAxisWidth + (yAxisPadding || 0);
|
|
1934
|
-
if (
|
|
1935
|
-
const
|
|
1936
|
-
|
|
1937
|
-
const yRightScale = d3
|
|
1938
|
-
.scaleLinear()
|
|
1939
|
-
.domain([rightAxisMin || 0, rightAxisMax || 0])
|
|
1940
|
-
.range(yRange)
|
|
1941
|
-
.nice();
|
|
1942
|
-
const yAxisRightTicks = d3.axisRight(yRightScale).ticks(yTicksCountDefault);
|
|
1966
|
+
if (yScaleRight) {
|
|
1967
|
+
const yAxisRightTicks = d3.axisRight(yScaleRight).ticks(yTicksCount);
|
|
1968
|
+
(customYAxisRight || customYAxis)?.(yAxisRightTicks);
|
|
1943
1969
|
const yAxisRight = svg
|
|
1944
1970
|
.append('g')
|
|
1945
1971
|
.attr('class', `${lineChartClassNames.lineChartYScaleGlobal} ${lineChartClassNames.lineChartYScaleRight}`)
|
|
@@ -1975,7 +2001,7 @@ const draw$2 = (node, props) => {
|
|
|
1975
2001
|
customXAxis && customXAxis(xAxisBottom);
|
|
1976
2002
|
drawGrid$2({
|
|
1977
2003
|
svg,
|
|
1978
|
-
yScale,
|
|
2004
|
+
yScale: primaryScale,
|
|
1979
2005
|
xScale,
|
|
1980
2006
|
yTicksCount,
|
|
1981
2007
|
lastIndex,
|
|
@@ -1991,19 +2017,26 @@ const draw$2 = (node, props) => {
|
|
|
1991
2017
|
const { height: xAxisHeight } = computeDimensions(xAxis);
|
|
1992
2018
|
xAxis.attr('transform', `translate(0, ${height - Math.ceil(xAxisHeight) - marginBottom})`);
|
|
1993
2019
|
}
|
|
1994
|
-
const
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2020
|
+
const createLine = (scale) => {
|
|
2021
|
+
const generator = d3
|
|
2022
|
+
.line()
|
|
2023
|
+
.defined(d => d !== null)
|
|
2024
|
+
.x((_, index) => xScale(index))
|
|
2025
|
+
.y((d) => scale(d))
|
|
2026
|
+
.curve(curve || d3.curveLinear);
|
|
2027
|
+
customLine && customLine(generator);
|
|
2028
|
+
return generator;
|
|
2029
|
+
};
|
|
2030
|
+
const line = createLine(primaryScale);
|
|
2031
|
+
const lineRight = yScaleRight ? createLine(yScaleRight) : line;
|
|
2032
|
+
const lineOf = (series) => isRightSeries(series) && yScaleRight ? lineRight : line;
|
|
2001
2033
|
const withAreas = data.some(({ fill }) => fill);
|
|
2002
2034
|
if (withAreas) {
|
|
2003
2035
|
let dataIndex = -2;
|
|
2004
2036
|
const getArea = (d) => {
|
|
2005
2037
|
const { minAreaValues } = d;
|
|
2006
|
-
const
|
|
2038
|
+
const scale = scaleOf(d);
|
|
2039
|
+
const minTick = scale.ticks()[0];
|
|
2007
2040
|
return d3
|
|
2008
2041
|
.area()
|
|
2009
2042
|
.defined(d => d !== null)
|
|
@@ -2017,18 +2050,18 @@ const draw$2 = (node, props) => {
|
|
|
2017
2050
|
minValue = minAreaValues[index] || minValue;
|
|
2018
2051
|
}
|
|
2019
2052
|
else if (minAreaValues) {
|
|
2020
|
-
minValue =
|
|
2053
|
+
minValue = scale((minValue - value));
|
|
2021
2054
|
}
|
|
2022
2055
|
const currData = data[dataIndex];
|
|
2023
2056
|
return stacked
|
|
2024
2057
|
? dataIndex > -1
|
|
2025
|
-
?
|
|
2058
|
+
? scale(typeof currData.values[index] !== 'number'
|
|
2026
2059
|
? 0
|
|
2027
2060
|
: currData.values[index])
|
|
2028
|
-
:
|
|
2029
|
-
:
|
|
2061
|
+
: scale(minValue)
|
|
2062
|
+
: scale(minValue);
|
|
2030
2063
|
})
|
|
2031
|
-
.y1((d) =>
|
|
2064
|
+
.y1((d) => scale(d))
|
|
2032
2065
|
.curve(areaCurve || curve || d3.curveLinear);
|
|
2033
2066
|
};
|
|
2034
2067
|
svg
|
|
@@ -2052,7 +2085,7 @@ const draw$2 = (node, props) => {
|
|
|
2052
2085
|
.data(data)
|
|
2053
2086
|
.join('path')
|
|
2054
2087
|
.attr('class', lineChartClassNames.lineChartLine)
|
|
2055
|
-
.attr('d', (d) =>
|
|
2088
|
+
.attr('d', (d) => lineOf(d)(d.values))
|
|
2056
2089
|
.attr('style', ({ style }) => style || '');
|
|
2057
2090
|
if (transitionDuration > 0 && prevStrokes.size > 0) {
|
|
2058
2091
|
lineSelection
|
|
@@ -2072,6 +2105,7 @@ const draw$2 = (node, props) => {
|
|
|
2072
2105
|
dots.forEach(item => {
|
|
2073
2106
|
const { values, dot } = item;
|
|
2074
2107
|
const { radius, style, filter } = dot;
|
|
2108
|
+
const scale = scaleOf(item);
|
|
2075
2109
|
const dotsGroup = dotsGlobal
|
|
2076
2110
|
.append('g')
|
|
2077
2111
|
.attr('class', lineChartClassNames.lineChartDotsGlobal);
|
|
@@ -2081,7 +2115,7 @@ const draw$2 = (node, props) => {
|
|
|
2081
2115
|
.join('circle')
|
|
2082
2116
|
.attr('cx', (_, index) => xScale(index))
|
|
2083
2117
|
.attr('class', lineChartClassNames.lineChartDot)
|
|
2084
|
-
.attr('cy', d =>
|
|
2118
|
+
.attr('cy', d => scale(d))
|
|
2085
2119
|
.attr('r', radius || 0)
|
|
2086
2120
|
.attr('style', style || '');
|
|
2087
2121
|
if (filter) {
|
|
@@ -2093,12 +2127,12 @@ const draw$2 = (node, props) => {
|
|
|
2093
2127
|
});
|
|
2094
2128
|
}
|
|
2095
2129
|
const count = data?.[0]?.values?.length || 0;
|
|
2096
|
-
drawMarkers({ svg, markers, width, left, top: height - marginTop, count, yScale });
|
|
2130
|
+
drawMarkers({ svg, markers, width, left, top: height - marginTop, count, yScale: primaryScale });
|
|
2097
2131
|
d3.select(node)
|
|
2098
2132
|
.select(`.${labelClassName}`)
|
|
2099
2133
|
.remove();
|
|
2100
2134
|
withLabels &&
|
|
2101
|
-
drawLabel({ node, eachLabel, data,
|
|
2135
|
+
drawLabel({ node, eachLabel, data, yScaleOf: scaleOf, xScale, formatLabel });
|
|
2102
2136
|
if (dynamicTooltipEnable) {
|
|
2103
2137
|
drawTooltip$2({
|
|
2104
2138
|
tooltipLineTop,
|
|
@@ -2110,14 +2144,15 @@ const draw$2 = (node, props) => {
|
|
|
2110
2144
|
svg,
|
|
2111
2145
|
data,
|
|
2112
2146
|
xScale,
|
|
2113
|
-
yScale,
|
|
2147
|
+
yScale: primaryScale,
|
|
2148
|
+
yScaleOf: scaleOf,
|
|
2114
2149
|
dynamicCircleRadius,
|
|
2115
2150
|
tooltipClassName,
|
|
2116
2151
|
dotSnapping,
|
|
2117
2152
|
lastIndex,
|
|
2118
2153
|
});
|
|
2119
2154
|
}
|
|
2120
|
-
customize && customize({ svg, yScale, xScale });
|
|
2155
|
+
customize && customize({ svg, yScale: primaryScale, yScaleRight, xScale });
|
|
2121
2156
|
}
|
|
2122
2157
|
};
|
|
2123
2158
|
|
package/dist/charts.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"charts.es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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1665,14 +1665,15 @@ const Label = styled.div `
|
|
|
1665
1665
|
`;
|
|
1666
1666
|
|
|
1667
1667
|
const labelClassName = "d3-chart-label";
|
|
1668
|
-
const drawLabel = ({ node, data,
|
|
1668
|
+
const drawLabel = ({ node, data, yScaleOf, xScale, formatLabel, eachLabel, }) => {
|
|
1669
1669
|
const labelsDiv = d3__namespace
|
|
1670
1670
|
.select(node)
|
|
1671
1671
|
.append("div")
|
|
1672
1672
|
.attr("class", labelClassName);
|
|
1673
1673
|
const format = d3__namespace.format(",");
|
|
1674
|
-
|
|
1675
|
-
|
|
1674
|
+
data.forEach(series => {
|
|
1675
|
+
const values = series.values;
|
|
1676
|
+
const yScale = yScaleOf(series);
|
|
1676
1677
|
labelsDiv
|
|
1677
1678
|
.append("div")
|
|
1678
1679
|
.selectAll("div")
|
|
@@ -1691,7 +1692,7 @@ const drawLabel = ({ node, data, yScale, xScale, formatLabel, eachLabel, }) => {
|
|
|
1691
1692
|
});
|
|
1692
1693
|
};
|
|
1693
1694
|
|
|
1694
|
-
const drawTooltip$2 = ({ svg, node, data: argData, xScale, yScale, dynamicCircleRadius, formatDynamicTooltip, renderTooltip, stackedTooltipIndex, stackedTooltip, tooltipLineTop, tooltipRoot, tooltipClassName, dotSnapping, lastIndex, }) => {
|
|
1695
|
+
const drawTooltip$2 = ({ svg, node, data: argData, xScale, yScale, yScaleOf, dynamicCircleRadius, formatDynamicTooltip, renderTooltip, stackedTooltipIndex, stackedTooltip, tooltipLineTop, tooltipRoot, tooltipClassName, dotSnapping, lastIndex, }) => {
|
|
1695
1696
|
const container = tooltipRoot || document.querySelector("body");
|
|
1696
1697
|
const format = d3__namespace.format(",");
|
|
1697
1698
|
const chartData = argData.filter(({ tooltipOff }) => !tooltipOff);
|
|
@@ -1800,7 +1801,7 @@ const drawTooltip$2 = ({ svg, node, data: argData, xScale, yScale, dynamicCircle
|
|
|
1800
1801
|
positions[index] = {
|
|
1801
1802
|
x: x1 + Math.round(currIndex) * step,
|
|
1802
1803
|
y: typeof argData[index].values[Math.round(currIndex)] === "number"
|
|
1803
|
-
?
|
|
1804
|
+
? yScaleOf(argData[index])(argData[index].values[Math.round(currIndex)])
|
|
1804
1805
|
: 0,
|
|
1805
1806
|
};
|
|
1806
1807
|
}
|
|
@@ -1816,7 +1817,7 @@ const drawTooltip$2 = ({ svg, node, data: argData, xScale, yScale, dynamicCircle
|
|
|
1816
1817
|
const datas = chartData.map(({ values, ...rest }, i) => ({
|
|
1817
1818
|
...rest,
|
|
1818
1819
|
value: getValue(values),
|
|
1819
|
-
invertValue: positions[i] ?
|
|
1820
|
+
invertValue: positions[i] ? yScaleOf(rest).invert(positions[i].y) : 0,
|
|
1820
1821
|
}));
|
|
1821
1822
|
const noHasData = datas.every(({ value }) => isVoid(value));
|
|
1822
1823
|
if (noHasData && isVisible) {
|
|
@@ -1904,7 +1905,7 @@ const drawTooltip$2 = ({ svg, node, data: argData, xScale, yScale, dynamicCircle
|
|
|
1904
1905
|
};
|
|
1905
1906
|
|
|
1906
1907
|
const draw$2 = (node, props) => {
|
|
1907
|
-
const { data: chartData, labels, margin, customYAxisSelection, customXAxisSelection, customYAxis, customXAxis, curve, yAxisPadding, xAxisPadding, drawGridY, drawGridX, withLabels, formatLabel, eachLabel, stacked, dynamicTooltipEnable, dynamicCircleRadius, formatDynamicTooltip, renderTooltip, stackedTooltip, stackedTooltipIndex, tooltipLineTop, customize, customYScale, customLine, tooltipClassName, xScaleItemWidth, areaCurve, dotSnapping,
|
|
1908
|
+
const { data: chartData, labels, margin, customYAxisSelection, customXAxisSelection, customYAxis, customYAxisRight, customXAxis, curve, yAxisPadding, xAxisPadding, drawGridY, drawGridX, withLabels, formatLabel, eachLabel, stacked, dynamicTooltipEnable, dynamicCircleRadius, formatDynamicTooltip, renderTooltip, stackedTooltip, stackedTooltipIndex, tooltipLineTop, customize, customYScale, customLine, tooltipClassName, xScaleItemWidth, areaCurve, dotSnapping, markers, transitionDuration = 300, } = props;
|
|
1908
1909
|
if (node !== null && chartData.length) {
|
|
1909
1910
|
const data = stacked ? stackedData(chartData) : chartData;
|
|
1910
1911
|
const marginTop = margin ? margin.top : 0;
|
|
@@ -1914,12 +1915,21 @@ const draw$2 = (node, props) => {
|
|
|
1914
1915
|
const { width: nodeWidth } = node.getBoundingClientRect();
|
|
1915
1916
|
const width = props.width || nodeWidth;
|
|
1916
1917
|
const height = props.height || 0;
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
const
|
|
1921
|
-
|
|
1922
|
-
|
|
1918
|
+
// Серии разводятся по двум шкалам: без axis серия считается левой, поэтому график с одной
|
|
1919
|
+
// осью ведёт себя ровно как раньше — правая шкала не создаётся и геометрия не меняется.
|
|
1920
|
+
const isRightSeries = ({ axis }) => axis === 'right';
|
|
1921
|
+
const leftData = data.filter(series => !isRightSeries(series));
|
|
1922
|
+
const rightData = data.filter(isRightSeries);
|
|
1923
|
+
const hasLeftAxis = leftData.length > 0;
|
|
1924
|
+
const hasRightAxis = rightData.length > 0;
|
|
1925
|
+
const domainOf = (series, propMin, propMax) => [
|
|
1926
|
+
typeof propMin === 'number'
|
|
1927
|
+
? propMin
|
|
1928
|
+
: d3__namespace.min(series, ({ values }) => d3__namespace.min(values)) || 0,
|
|
1929
|
+
typeof propMax === 'number'
|
|
1930
|
+
? propMax
|
|
1931
|
+
: d3__namespace.max(series, ({ values }) => d3__namespace.max(values)) || 0,
|
|
1932
|
+
];
|
|
1923
1933
|
const prevStrokes = new Map();
|
|
1924
1934
|
if (transitionDuration > 0) {
|
|
1925
1935
|
d3__namespace.select(node)
|
|
@@ -1935,32 +1945,48 @@ const draw$2 = (node, props) => {
|
|
|
1935
1945
|
];
|
|
1936
1946
|
const yScale = d3__namespace
|
|
1937
1947
|
.scaleLinear()
|
|
1938
|
-
.domain(
|
|
1948
|
+
.domain(domainOf(hasLeftAxis ? leftData : data, props.min, props.max))
|
|
1939
1949
|
.range(yRange)
|
|
1940
1950
|
.nice();
|
|
1951
|
+
const yScaleRight = hasRightAxis
|
|
1952
|
+
? d3__namespace
|
|
1953
|
+
.scaleLinear()
|
|
1954
|
+
.domain(domainOf(rightData, props.rightMin, props.rightMax))
|
|
1955
|
+
.range(yRange)
|
|
1956
|
+
.nice()
|
|
1957
|
+
: undefined;
|
|
1958
|
+
// Основная шкала — левая; если левых серий нет, её место занимает правая, чтобы сетка,
|
|
1959
|
+
// маркеры и customize получили осмысленную шкалу.
|
|
1960
|
+
const primaryScale = hasLeftAxis || !yScaleRight ? yScale : yScaleRight;
|
|
1961
|
+
const scaleOf = series => series && isRightSeries(series) && yScaleRight ? yScaleRight : primaryScale;
|
|
1941
1962
|
customYScale && customYScale(yScale);
|
|
1942
1963
|
const yTicksCountDefault = 8;
|
|
1943
1964
|
const yAxisLeft = d3__namespace.axisLeft(yScale).ticks(yTicksCountDefault);
|
|
1944
1965
|
customYAxis && customYAxis(yAxisLeft);
|
|
1945
|
-
const yTicksCount = yAxisLeft.tickArguments()[0];
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1966
|
+
const yTicksCount = yAxisLeft.tickArguments()[0] ?? yTicksCountDefault;
|
|
1967
|
+
// Деления двух шкал должны попадать на одни и те же высоты, иначе линии сетки идут по левой
|
|
1968
|
+
// оси, а подписи правой висят между ними. `nice` с явным числом делений округляет домен так,
|
|
1969
|
+
// что обе оси дают одинаковое их количество. Для графика с одной осью домен не трогаем —
|
|
1970
|
+
// иначе поменялась бы геометрия уже существующих графиков.
|
|
1971
|
+
if (hasLeftAxis && yScaleRight) {
|
|
1972
|
+
yScale.nice(yTicksCount);
|
|
1973
|
+
yScaleRight.nice(yTicksCount);
|
|
1974
|
+
}
|
|
1975
|
+
let yAxisWidth = 0;
|
|
1976
|
+
if (hasLeftAxis) {
|
|
1977
|
+
const yAxis = svg
|
|
1978
|
+
.append('g')
|
|
1979
|
+
.attr('class', lineChartClassNames.lineChartYScaleGlobal)
|
|
1980
|
+
.call(yAxisLeft)
|
|
1981
|
+
.call(customYAxisSelection ? customYAxisSelection : none);
|
|
1982
|
+
({ width: yAxisWidth } = computeDimensions(yAxis));
|
|
1983
|
+
yAxis.attr('transform', `translate(${marginLeft + yAxisWidth}, 0)`);
|
|
1984
|
+
}
|
|
1953
1985
|
let yAxisRightWidth = 0;
|
|
1954
1986
|
const left = marginLeft + yAxisWidth + (yAxisPadding || 0);
|
|
1955
|
-
if (
|
|
1956
|
-
const
|
|
1957
|
-
|
|
1958
|
-
const yRightScale = d3__namespace
|
|
1959
|
-
.scaleLinear()
|
|
1960
|
-
.domain([rightAxisMin || 0, rightAxisMax || 0])
|
|
1961
|
-
.range(yRange)
|
|
1962
|
-
.nice();
|
|
1963
|
-
const yAxisRightTicks = d3__namespace.axisRight(yRightScale).ticks(yTicksCountDefault);
|
|
1987
|
+
if (yScaleRight) {
|
|
1988
|
+
const yAxisRightTicks = d3__namespace.axisRight(yScaleRight).ticks(yTicksCount);
|
|
1989
|
+
(customYAxisRight || customYAxis)?.(yAxisRightTicks);
|
|
1964
1990
|
const yAxisRight = svg
|
|
1965
1991
|
.append('g')
|
|
1966
1992
|
.attr('class', `${lineChartClassNames.lineChartYScaleGlobal} ${lineChartClassNames.lineChartYScaleRight}`)
|
|
@@ -1996,7 +2022,7 @@ const draw$2 = (node, props) => {
|
|
|
1996
2022
|
customXAxis && customXAxis(xAxisBottom);
|
|
1997
2023
|
drawGrid$2({
|
|
1998
2024
|
svg,
|
|
1999
|
-
yScale,
|
|
2025
|
+
yScale: primaryScale,
|
|
2000
2026
|
xScale,
|
|
2001
2027
|
yTicksCount,
|
|
2002
2028
|
lastIndex,
|
|
@@ -2012,19 +2038,26 @@ const draw$2 = (node, props) => {
|
|
|
2012
2038
|
const { height: xAxisHeight } = computeDimensions(xAxis);
|
|
2013
2039
|
xAxis.attr('transform', `translate(0, ${height - Math.ceil(xAxisHeight) - marginBottom})`);
|
|
2014
2040
|
}
|
|
2015
|
-
const
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2041
|
+
const createLine = (scale) => {
|
|
2042
|
+
const generator = d3__namespace
|
|
2043
|
+
.line()
|
|
2044
|
+
.defined(d => d !== null)
|
|
2045
|
+
.x((_, index) => xScale(index))
|
|
2046
|
+
.y((d) => scale(d))
|
|
2047
|
+
.curve(curve || d3__namespace.curveLinear);
|
|
2048
|
+
customLine && customLine(generator);
|
|
2049
|
+
return generator;
|
|
2050
|
+
};
|
|
2051
|
+
const line = createLine(primaryScale);
|
|
2052
|
+
const lineRight = yScaleRight ? createLine(yScaleRight) : line;
|
|
2053
|
+
const lineOf = (series) => isRightSeries(series) && yScaleRight ? lineRight : line;
|
|
2022
2054
|
const withAreas = data.some(({ fill }) => fill);
|
|
2023
2055
|
if (withAreas) {
|
|
2024
2056
|
let dataIndex = -2;
|
|
2025
2057
|
const getArea = (d) => {
|
|
2026
2058
|
const { minAreaValues } = d;
|
|
2027
|
-
const
|
|
2059
|
+
const scale = scaleOf(d);
|
|
2060
|
+
const minTick = scale.ticks()[0];
|
|
2028
2061
|
return d3__namespace
|
|
2029
2062
|
.area()
|
|
2030
2063
|
.defined(d => d !== null)
|
|
@@ -2038,18 +2071,18 @@ const draw$2 = (node, props) => {
|
|
|
2038
2071
|
minValue = minAreaValues[index] || minValue;
|
|
2039
2072
|
}
|
|
2040
2073
|
else if (minAreaValues) {
|
|
2041
|
-
minValue =
|
|
2074
|
+
minValue = scale((minValue - value));
|
|
2042
2075
|
}
|
|
2043
2076
|
const currData = data[dataIndex];
|
|
2044
2077
|
return stacked
|
|
2045
2078
|
? dataIndex > -1
|
|
2046
|
-
?
|
|
2079
|
+
? scale(typeof currData.values[index] !== 'number'
|
|
2047
2080
|
? 0
|
|
2048
2081
|
: currData.values[index])
|
|
2049
|
-
:
|
|
2050
|
-
:
|
|
2082
|
+
: scale(minValue)
|
|
2083
|
+
: scale(minValue);
|
|
2051
2084
|
})
|
|
2052
|
-
.y1((d) =>
|
|
2085
|
+
.y1((d) => scale(d))
|
|
2053
2086
|
.curve(areaCurve || curve || d3__namespace.curveLinear);
|
|
2054
2087
|
};
|
|
2055
2088
|
svg
|
|
@@ -2073,7 +2106,7 @@ const draw$2 = (node, props) => {
|
|
|
2073
2106
|
.data(data)
|
|
2074
2107
|
.join('path')
|
|
2075
2108
|
.attr('class', lineChartClassNames.lineChartLine)
|
|
2076
|
-
.attr('d', (d) =>
|
|
2109
|
+
.attr('d', (d) => lineOf(d)(d.values))
|
|
2077
2110
|
.attr('style', ({ style }) => style || '');
|
|
2078
2111
|
if (transitionDuration > 0 && prevStrokes.size > 0) {
|
|
2079
2112
|
lineSelection
|
|
@@ -2093,6 +2126,7 @@ const draw$2 = (node, props) => {
|
|
|
2093
2126
|
dots.forEach(item => {
|
|
2094
2127
|
const { values, dot } = item;
|
|
2095
2128
|
const { radius, style, filter } = dot;
|
|
2129
|
+
const scale = scaleOf(item);
|
|
2096
2130
|
const dotsGroup = dotsGlobal
|
|
2097
2131
|
.append('g')
|
|
2098
2132
|
.attr('class', lineChartClassNames.lineChartDotsGlobal);
|
|
@@ -2102,7 +2136,7 @@ const draw$2 = (node, props) => {
|
|
|
2102
2136
|
.join('circle')
|
|
2103
2137
|
.attr('cx', (_, index) => xScale(index))
|
|
2104
2138
|
.attr('class', lineChartClassNames.lineChartDot)
|
|
2105
|
-
.attr('cy', d =>
|
|
2139
|
+
.attr('cy', d => scale(d))
|
|
2106
2140
|
.attr('r', radius || 0)
|
|
2107
2141
|
.attr('style', style || '');
|
|
2108
2142
|
if (filter) {
|
|
@@ -2114,12 +2148,12 @@ const draw$2 = (node, props) => {
|
|
|
2114
2148
|
});
|
|
2115
2149
|
}
|
|
2116
2150
|
const count = data?.[0]?.values?.length || 0;
|
|
2117
|
-
drawMarkers({ svg, markers, width, left, top: height - marginTop, count, yScale });
|
|
2151
|
+
drawMarkers({ svg, markers, width, left, top: height - marginTop, count, yScale: primaryScale });
|
|
2118
2152
|
d3__namespace.select(node)
|
|
2119
2153
|
.select(`.${labelClassName}`)
|
|
2120
2154
|
.remove();
|
|
2121
2155
|
withLabels &&
|
|
2122
|
-
drawLabel({ node, eachLabel, data,
|
|
2156
|
+
drawLabel({ node, eachLabel, data, yScaleOf: scaleOf, xScale, formatLabel });
|
|
2123
2157
|
if (dynamicTooltipEnable) {
|
|
2124
2158
|
drawTooltip$2({
|
|
2125
2159
|
tooltipLineTop,
|
|
@@ -2131,14 +2165,15 @@ const draw$2 = (node, props) => {
|
|
|
2131
2165
|
svg,
|
|
2132
2166
|
data,
|
|
2133
2167
|
xScale,
|
|
2134
|
-
yScale,
|
|
2168
|
+
yScale: primaryScale,
|
|
2169
|
+
yScaleOf: scaleOf,
|
|
2135
2170
|
dynamicCircleRadius,
|
|
2136
2171
|
tooltipClassName,
|
|
2137
2172
|
dotSnapping,
|
|
2138
2173
|
lastIndex,
|
|
2139
2174
|
});
|
|
2140
2175
|
}
|
|
2141
|
-
customize && customize({ svg, yScale, xScale });
|
|
2176
|
+
customize && customize({ svg, yScale: primaryScale, yScaleRight, xScale });
|
|
2142
2177
|
}
|
|
2143
2178
|
};
|
|
2144
2179
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.0.
|
|
2
|
+
"version": "4.0.48",
|
|
3
3
|
"name": "@evergis/charts",
|
|
4
4
|
"author": "Everpoint",
|
|
5
5
|
"license": "MIT",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"react-is": "^19.1.1",
|
|
55
55
|
"styled-components": "5.3.5"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "00e65767be0339fc7999e3081cb4be3ac3c7e888"
|
|
58
58
|
}
|