@gravity-ui/chartkit 4.20.1 → 5.1.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/build/components/ChartKit.css +20 -20
- package/build/components/ChartKit.d.ts +2 -2
- package/build/components/ErrorBoundary/ErrorBoundary.js +1 -1
- package/build/libs/settings/settings.d.ts +1 -1
- package/build/libs/settings/settings.js +1 -1
- package/build/plugins/d3/examples/area/PercentStacking.js +1 -1
- package/build/plugins/d3/examples/area/StackedArea.js +1 -1
- package/build/plugins/d3/examples/combined/LineAndBarX.js +1 -1
- package/build/plugins/d3/examples/pie/DonutWithTotals.js +1 -1
- package/build/plugins/d3/renderer/D3Widget.d.ts +1 -1
- package/build/plugins/d3/renderer/D3Widget.js +1 -1
- package/build/plugins/d3/renderer/components/AxisX.d.ts +1 -1
- package/build/plugins/d3/renderer/components/AxisX.js +2 -2
- package/build/plugins/d3/renderer/components/AxisY.js +1 -1
- package/build/plugins/d3/renderer/components/Chart.js +13 -4
- package/build/plugins/d3/renderer/components/Legend.d.ts +1 -1
- package/build/plugins/d3/renderer/components/Legend.js +2 -2
- package/build/plugins/d3/renderer/components/Tooltip/DefaultContent.js +1 -1
- package/build/plugins/d3/renderer/components/Tooltip/TooltipTriggerArea.js +19 -7
- package/build/plugins/d3/renderer/components/Tooltip/index.js +1 -1
- package/build/plugins/d3/renderer/components/styles.css +1 -1
- package/build/plugins/d3/renderer/d3-dispatcher.js +1 -1
- package/build/plugins/d3/renderer/hooks/useAxisScales/index.d.ts +1 -1
- package/build/plugins/d3/renderer/hooks/useAxisScales/index.js +2 -2
- package/build/plugins/d3/renderer/hooks/useChartOptions/types.d.ts +1 -1
- package/build/plugins/d3/renderer/hooks/useChartOptions/x-axis.d.ts +1 -1
- package/build/plugins/d3/renderer/hooks/useChartOptions/x-axis.js +1 -1
- package/build/plugins/d3/renderer/hooks/useChartOptions/y-axis.js +2 -2
- package/build/plugins/d3/renderer/hooks/useSeries/index.d.ts +1 -1
- package/build/plugins/d3/renderer/hooks/useSeries/index.js +2 -2
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-area.d.ts +1 -1
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-area.js +1 -1
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-bar-x.js +1 -1
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-bar-y.js +2 -2
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-legend.d.ts +1 -1
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-legend.js +1 -1
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-line.d.ts +1 -1
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-line.js +2 -1
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-pie.js +3 -2
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-scatter.d.ts +1 -1
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-scatter.js +2 -2
- package/build/plugins/d3/renderer/hooks/useSeries/prepareSeries.js +2 -2
- package/build/plugins/d3/renderer/hooks/useSeries/types.d.ts +4 -2
- package/build/plugins/d3/renderer/hooks/useSeries/utils.d.ts +2 -2
- package/build/plugins/d3/renderer/hooks/useSeries/utils.js +1 -1
- package/build/plugins/d3/renderer/hooks/useShapes/area/index.js +2 -2
- package/build/plugins/d3/renderer/hooks/useShapes/area/prepare-data.d.ts +2 -2
- package/build/plugins/d3/renderer/hooks/useShapes/area/prepare-data.js +1 -1
- package/build/plugins/d3/renderer/hooks/useShapes/area/types.d.ts +1 -1
- package/build/plugins/d3/renderer/hooks/useShapes/bar-x/index.js +3 -2
- package/build/plugins/d3/renderer/hooks/useShapes/bar-x/prepare-data.js +1 -0
- package/build/plugins/d3/renderer/hooks/useShapes/bar-x/types.d.ts +2 -1
- package/build/plugins/d3/renderer/hooks/useShapes/bar-y/index.js +3 -2
- package/build/plugins/d3/renderer/hooks/useShapes/bar-y/prepare-data.js +1 -0
- package/build/plugins/d3/renderer/hooks/useShapes/bar-y/types.d.ts +1 -0
- package/build/plugins/d3/renderer/hooks/useShapes/index.d.ts +6 -6
- package/build/plugins/d3/renderer/hooks/useShapes/index.js +6 -6
- package/build/plugins/d3/renderer/hooks/useShapes/line/index.js +3 -2
- package/build/plugins/d3/renderer/hooks/useShapes/line/prepare-data.d.ts +2 -2
- package/build/plugins/d3/renderer/hooks/useShapes/line/prepare-data.js +2 -1
- package/build/plugins/d3/renderer/hooks/useShapes/line/types.d.ts +3 -2
- package/build/plugins/d3/renderer/hooks/useShapes/marker.d.ts +1 -1
- package/build/plugins/d3/renderer/hooks/useShapes/marker.js +10 -3
- package/build/plugins/d3/renderer/hooks/useShapes/pie/index.js +20 -11
- package/build/plugins/d3/renderer/hooks/useShapes/pie/prepare-data.js +1 -0
- package/build/plugins/d3/renderer/hooks/useShapes/pie/types.d.ts +3 -2
- package/build/plugins/d3/renderer/hooks/useShapes/pie/utils.js +1 -1
- package/build/plugins/d3/renderer/hooks/useShapes/scatter/index.js +14 -4
- package/build/plugins/d3/renderer/hooks/useShapes/scatter/prepare-data.js +2 -0
- package/build/plugins/d3/renderer/hooks/useShapes/scatter/types.d.ts +1 -0
- package/build/plugins/d3/renderer/hooks/useShapes/treemap/index.js +11 -4
- package/build/plugins/d3/renderer/hooks/useShapes/utils.d.ts +1 -1
- package/build/plugins/d3/renderer/hooks/useTooltip/index.d.ts +1 -1
- package/build/plugins/d3/renderer/utils/axis-generators/bottom.js +1 -1
- package/build/plugins/d3/renderer/utils/axis.d.ts +1 -1
- package/build/plugins/d3/renderer/utils/index.js +3 -3
- package/build/plugins/d3/renderer/utils/symbol.js +1 -1
- package/build/plugins/d3/renderer/validation/index.js +1 -1
- package/build/plugins/highcharts/renderer/components/HighchartsComponent.d.ts +1 -1
- package/build/plugins/highcharts/renderer/components/HighchartsComponent.js +2 -2
- package/build/plugins/highcharts/renderer/components/HighchartsReact.js +7 -1
- package/build/plugins/highcharts/renderer/components/StyledSplitPane/StyledSplitPane.css +1 -1
- package/build/plugins/highcharts/renderer/helpers/config/config.js +15 -15
- package/build/plugins/highcharts/renderer/helpers/config/handleLegendItemClick.js +1 -1
- package/build/plugins/highcharts/renderer/helpers/config/options.d.ts +98 -98
- package/build/plugins/highcharts/renderer/helpers/config/options.js +1 -1
- package/build/plugins/highcharts/renderer/helpers/config/utils/index.d.ts +39 -10
- package/build/plugins/highcharts/renderer/helpers/graph.css +4 -4
- package/build/plugins/highcharts/renderer/helpers/graph.d.ts +1 -1
- package/build/plugins/highcharts/renderer/helpers/graph.js +2 -2
- package/build/plugins/highcharts/renderer/helpers/highcharts/highcharts.js +2 -2
- package/build/plugins/highcharts/renderer/helpers/prepare-data.js +2 -2
- package/build/plugins/highcharts/renderer/helpers/tooltip/index.js +1 -1
- package/build/plugins/highcharts/renderer/helpers/tooltip/tooltip.css +6 -7
- package/build/plugins/highcharts/types/highcharts-extends.d.ts +1 -0
- package/build/plugins/highcharts/types/widget.d.ts +2 -2
- package/build/plugins/indicator/renderer/IndicatorWidget.css +1 -1
- package/build/plugins/indicator/renderer/IndicatorWidget.js +1 -1
- package/build/plugins/shared/format-number/format-number.d.ts +1 -1
- package/build/plugins/shared/format-number/format-number.js +2 -2
- package/build/plugins/shared/format-number/format-number.test.js +1 -1
- package/build/plugins/yagr/renderer/YagrWidget.css +1 -1
- package/build/plugins/yagr/renderer/YagrWidget.js +5 -3
- package/build/plugins/yagr/renderer/tooltip/tooltip.css +15 -16
- package/build/plugins/yagr/renderer/utils.d.ts +1 -1
- package/build/plugins/yagr/renderer/utils.js +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/widget-data/area.d.ts +15 -0
- package/build/types/widget-data/bar-x.d.ts +3 -1
- package/build/types/widget-data/bar-y.d.ts +3 -1
- package/build/types/widget-data/chart.d.ts +6 -0
- package/build/types/widget-data/line.d.ts +10 -1
- package/build/types/widget-data/pie.d.ts +2 -0
- package/build/types/widget-data/scatter.d.ts +3 -0
- package/build/types/widget-data/series.d.ts +6 -6
- package/build/types/widget-data/tooltip.d.ts +3 -3
- package/build/types/widget.d.ts +2 -2
- package/package.json +23 -24
|
@@ -8,25 +8,25 @@
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
.chartkit-theme_common {
|
|
11
|
-
--highcarts-navigator-border: var(--
|
|
12
|
-
--highcarts-navigator-track: var(--
|
|
13
|
-
--highcarts-navigator-body: var(--
|
|
14
|
-
--highcharts-series-border: var(--
|
|
15
|
-
--highcharts-grid-line: var(--
|
|
16
|
-
--highcharts-axis-line: var(--
|
|
17
|
-
--highcharts-tick: var(--
|
|
18
|
-
--highcharts-title: var(--
|
|
19
|
-
--highcharts-axis-labels: var(--
|
|
20
|
-
--highcharts-data-labels: var(--
|
|
21
|
-
--highcharts-plot-line-label: var(--
|
|
22
|
-
--highcharts-legend-item: var(--
|
|
23
|
-
--highcharts-legend-item-hover: var(--
|
|
24
|
-
--highcharts-legend-item-hidden: var(--
|
|
25
|
-
--highcharts-floating-bg: var(--
|
|
26
|
-
--highcharts-tooltip-text: var(--
|
|
11
|
+
--highcarts-navigator-border: var(--g-color-line-generic);
|
|
12
|
+
--highcarts-navigator-track: var(--g-color-base-generic);
|
|
13
|
+
--highcarts-navigator-body: var(--g-color-scroll-handle);
|
|
14
|
+
--highcharts-series-border: var(--g-color-base-background);
|
|
15
|
+
--highcharts-grid-line: var(--g-color-line-generic);
|
|
16
|
+
--highcharts-axis-line: var(--g-color-line-generic);
|
|
17
|
+
--highcharts-tick: var(--g-color-line-generic);
|
|
18
|
+
--highcharts-title: var(--g-color-text-primary);
|
|
19
|
+
--highcharts-axis-labels: var(--g-color-text-secondary);
|
|
20
|
+
--highcharts-data-labels: var(--g-color-text-secondary);
|
|
21
|
+
--highcharts-plot-line-label: var(--g-color-text-secondary);
|
|
22
|
+
--highcharts-legend-item: var(--g-color-text-secondary);
|
|
23
|
+
--highcharts-legend-item-hover: var(--g-color-text-primary);
|
|
24
|
+
--highcharts-legend-item-hidden: var(--g-color-text-hint);
|
|
25
|
+
--highcharts-floating-bg: var(--g-color-infographics-tooltip-bg);
|
|
26
|
+
--highcharts-tooltip-text: var(--g-color-text-primary);
|
|
27
27
|
--highcharts-tooltip-bg: var(--highcharts-floating-bg);
|
|
28
|
-
--highcharts-tooltip-alternate-bg: var(--
|
|
29
|
-
--highcharts-tooltip-text-complementary: var(--
|
|
30
|
-
--highcharts-holiday-band: var(--
|
|
31
|
-
--d3-data-labels: var(--
|
|
28
|
+
--highcharts-tooltip-alternate-bg: var(--g-color-base-generic);
|
|
29
|
+
--highcharts-tooltip-text-complementary: var(--g-color-text-secondary);
|
|
30
|
+
--highcharts-holiday-band: var(--g-color-base-generic);
|
|
31
|
+
--d3-data-labels: var(--g-color-text-secondary);
|
|
32
32
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ChartKitProps, ChartKitRef, ChartKitType } from '../types';
|
|
3
3
|
import './ChartKit.css';
|
|
4
4
|
type ChartKitComponentProps<T extends ChartKitType> = Omit<ChartKitProps<T>, 'onError'> & {
|
|
5
5
|
instanceRef?: React.ForwardedRef<ChartKitRef | undefined>;
|
|
@@ -16,7 +16,7 @@ export declare const ChartKit: <T extends keyof import("../types").ChartKitWidge
|
|
|
16
16
|
onError?: import("../types").ChartKitOnError | undefined;
|
|
17
17
|
renderError?: import("../types").RenderError | undefined;
|
|
18
18
|
renderPluginLoader?: import("../types").ChartKitRenderPluginLoader | undefined;
|
|
19
|
-
} &
|
|
19
|
+
} & { [key in keyof Omit<import("../types").ChartKitWidget[T], "data" | "widget">]: import("../types").ChartKitWidget[T][key]; } & {
|
|
20
20
|
ref?: React.ForwardedRef<ChartKitRef | undefined> | undefined;
|
|
21
21
|
}) => ReturnType<typeof ChartKitComponent>;
|
|
22
22
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { getErrorMessage } from '../../utils/getErrorMessage';
|
|
3
2
|
import { CHARTKIT_ERROR_CODE } from '../../libs';
|
|
3
|
+
import { getErrorMessage } from '../../utils/getErrorMessage';
|
|
4
4
|
export class ErrorBoundary extends React.Component {
|
|
5
5
|
constructor() {
|
|
6
6
|
super(...arguments);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { configure } from '@gravity-ui/uikit';
|
|
1
2
|
import get from 'lodash/get';
|
|
2
3
|
import merge from 'lodash/merge';
|
|
3
|
-
import { configure } from '@gravity-ui/uikit';
|
|
4
4
|
import { i18nFactory } from '../../i18n';
|
|
5
5
|
import { EventEmitter } from './eventEmitter';
|
|
6
6
|
export const settingsEventEmitter = new EventEmitter();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { groups, max,
|
|
2
|
+
import { groups, max, median, min } from 'd3';
|
|
3
3
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
4
4
|
import { ExampleWrapper } from '../ExampleWrapper';
|
|
5
5
|
import nintendoGames from '../nintendoGames';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { groups } from 'd3';
|
|
3
3
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
4
|
+
import { CustomShapeRenderer } from '../../utils';
|
|
4
5
|
import { ExampleWrapper } from '../ExampleWrapper';
|
|
5
6
|
import nintendoGames from '../nintendoGames';
|
|
6
|
-
import { CustomShapeRenderer } from '../../utils';
|
|
7
7
|
function prepareData() {
|
|
8
8
|
const gamesByPlatform = groups(nintendoGames, (d) => d.esrb_rating || 'unknown');
|
|
9
9
|
return gamesByPlatform.map(([value, games]) => ({
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import type { ChartKitWidgetRef } from '../../../types';
|
|
3
3
|
declare const D3Widget: React.ForwardRefExoticComponent<{
|
|
4
4
|
type: "d3";
|
|
5
|
-
data: import("../../../types").ChartKitWidgetData
|
|
5
|
+
data: import("../../../types").ChartKitWidgetData;
|
|
6
6
|
id?: string | undefined;
|
|
7
7
|
isMobile?: boolean | undefined;
|
|
8
8
|
onLoad?: ((data?: import("../../../types").ChartKitOnLoadData<"d3"> | undefined) => void) | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import afterFrame from 'afterframe';
|
|
2
3
|
import { select } from 'd3';
|
|
3
4
|
import debounce from 'lodash/debounce';
|
|
4
|
-
import afterFrame from 'afterframe';
|
|
5
5
|
import { getRandomCKId, measurePerformance } from '../../../utils';
|
|
6
6
|
import { Chart } from './components';
|
|
7
7
|
import { validateData } from './validation';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { select } from 'd3';
|
|
3
3
|
import { block } from '../../../../utils/cn';
|
|
4
|
-
import { formatAxisTickLabel, getClosestPointsRange,
|
|
4
|
+
import { formatAxisTickLabel, getClosestPointsRange, getMaxTickCount, getScaleTicks, getTicksCount, setEllipsisForOverflowText, } from '../utils';
|
|
5
5
|
import { axisBottom } from '../utils/axis-generators';
|
|
6
6
|
const b = block('d3-axis');
|
|
7
7
|
function getLabelFormatter({ axis, scale }) {
|
|
@@ -18,7 +18,7 @@ function getLabelFormatter({ axis, scale }) {
|
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
export const AxisX = React.memo(({ axis, width, height, scale })
|
|
21
|
+
export const AxisX = React.memo(function AxisX({ axis, width, height, scale }) {
|
|
22
22
|
const ref = React.useRef(null);
|
|
23
23
|
React.useEffect(() => {
|
|
24
24
|
if (!ref.current) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { axisLeft, select } from 'd3';
|
|
3
3
|
import { block } from '../../../../utils/cn';
|
|
4
|
-
import {
|
|
4
|
+
import { calculateCos, calculateSin, formatAxisTickLabel, getClosestPointsRange, getScaleTicks, getTicksCount, parseTransformStyle, setEllipsisForOverflowText, setEllipsisForOverflowTexts, } from '../utils';
|
|
5
5
|
const b = block('d3-axis');
|
|
6
6
|
function transformLabel(node, axis) {
|
|
7
7
|
let topOffset = axis.labels.lineHeight / 2;
|
|
@@ -2,14 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import { block } from '../../../../utils/cn';
|
|
3
3
|
import { getD3Dispatcher } from '../d3-dispatcher';
|
|
4
4
|
import { useAxisScales, useChartDimensions, useChartOptions, useSeries, useShapes, useTooltip, } from '../hooks';
|
|
5
|
-
import {
|
|
5
|
+
import { getWidthOccupiedByYAxis } from '../hooks/useChartDimensions/utils';
|
|
6
|
+
import { getPreparedXAxis } from '../hooks/useChartOptions/x-axis';
|
|
7
|
+
import { getPreparedYAxis } from '../hooks/useChartOptions/y-axis';
|
|
6
8
|
import { AxisX } from './AxisX';
|
|
9
|
+
import { AxisY } from './AxisY';
|
|
7
10
|
import { Legend } from './Legend';
|
|
8
11
|
import { Title } from './Title';
|
|
9
12
|
import { Tooltip, TooltipTriggerArea } from './Tooltip';
|
|
10
|
-
import { getPreparedXAxis } from '../hooks/useChartOptions/x-axis';
|
|
11
|
-
import { getWidthOccupiedByYAxis } from '../hooks/useChartDimensions/utils';
|
|
12
|
-
import { getPreparedYAxis } from '../hooks/useChartOptions/y-axis';
|
|
13
13
|
import './styles.css';
|
|
14
14
|
const b = block('d3');
|
|
15
15
|
export const Chart = (props) => {
|
|
@@ -60,6 +60,15 @@ export const Chart = (props) => {
|
|
|
60
60
|
yScale,
|
|
61
61
|
svgContainer: svgRef.current,
|
|
62
62
|
});
|
|
63
|
+
React.useEffect(() => {
|
|
64
|
+
var _a, _b, _c, _d;
|
|
65
|
+
if ((_b = (_a = data.chart) === null || _a === void 0 ? void 0 : _a.events) === null || _b === void 0 ? void 0 : _b.click) {
|
|
66
|
+
dispatcher.on('click-chart', (_d = (_c = data.chart) === null || _c === void 0 ? void 0 : _c.events) === null || _d === void 0 ? void 0 : _d.click);
|
|
67
|
+
}
|
|
68
|
+
return () => {
|
|
69
|
+
dispatcher.on('click-chart', null);
|
|
70
|
+
};
|
|
71
|
+
}, [dispatcher]);
|
|
63
72
|
const boundsOffsetTop = chart.margin.top;
|
|
64
73
|
const boundsOffsetLeft = chart.margin.left + getWidthOccupiedByYAxis({ preparedAxis: yAxis });
|
|
65
74
|
return (React.createElement(React.Fragment, null,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { LegendConfig, LegendItem, OnLegendItemClick, PreparedLegend, PreparedSeries } from '../hooks';
|
|
3
3
|
type Props = {
|
|
4
4
|
boundsWidth: number;
|
|
5
5
|
chartSeries: PreparedSeries[];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { getSymbol } from '../utils';
|
|
2
|
+
import { line as lineGenerator, select, symbol } from 'd3';
|
|
4
3
|
import { block } from '../../../../utils/cn';
|
|
5
4
|
import { getLineDashArray } from '../hooks/useShapes/utils';
|
|
5
|
+
import { getSymbol } from '../utils';
|
|
6
6
|
const b = block('d3-legend');
|
|
7
7
|
const getLegendPosition = (args) => {
|
|
8
8
|
const { align, offsetWidth, width, contentWidth } = args;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import get from 'lodash/get';
|
|
3
2
|
import { dateTime } from '@gravity-ui/date-utils';
|
|
3
|
+
import get from 'lodash/get';
|
|
4
4
|
import { formatNumber } from '../../../../shared';
|
|
5
5
|
import { getDataCategoryValue } from '../../utils';
|
|
6
6
|
const DEFAULT_DATE_FORMAT = 'DD.MM.YY';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { bisector, group, pointer, sort } from 'd3';
|
|
3
|
+
import get from 'lodash/get';
|
|
2
4
|
import throttle from 'lodash/throttle';
|
|
3
|
-
import { bisector, pointer, sort, group } from 'd3';
|
|
4
5
|
import { extractD3DataFromNode, isNodeContainsD3Data } from '../../utils';
|
|
5
|
-
import get from 'lodash/get';
|
|
6
6
|
const THROTTLE_DELAY = 50;
|
|
7
7
|
const isNodeContainsData = (node) => {
|
|
8
8
|
return isNodeContainsD3Data(node);
|
|
@@ -101,7 +101,7 @@ export const TooltipTriggerArea = (args) => {
|
|
|
101
101
|
});
|
|
102
102
|
return sort(result, (item) => item.y);
|
|
103
103
|
}, [shapesData]);
|
|
104
|
-
const
|
|
104
|
+
const getShapeData = (point) => {
|
|
105
105
|
var _a, _b;
|
|
106
106
|
const { left: ownLeft, top: ownTop } = ((_a = rectRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) || {
|
|
107
107
|
left: 0,
|
|
@@ -111,9 +111,9 @@ export const TooltipTriggerArea = (args) => {
|
|
|
111
111
|
left: 0,
|
|
112
112
|
top: 0,
|
|
113
113
|
};
|
|
114
|
-
const [pointerX, pointerY] = pointer(e, svgContainer);
|
|
115
|
-
const
|
|
116
|
-
|
|
114
|
+
const [pointerX, pointerY] = point; //pointer(e, svgContainer);
|
|
115
|
+
const result = [];
|
|
116
|
+
result === null || result === void 0 ? void 0 : result.push(...getBarXShapeData({
|
|
117
117
|
shapesData,
|
|
118
118
|
point: [pointerX, pointerY],
|
|
119
119
|
left: ownLeft - containerLeft,
|
|
@@ -127,6 +127,11 @@ export const TooltipTriggerArea = (args) => {
|
|
|
127
127
|
data: barYData,
|
|
128
128
|
point: [pointerX - (ownLeft - containerLeft), pointerY - (ownTop - containerTop)],
|
|
129
129
|
}));
|
|
130
|
+
return result;
|
|
131
|
+
};
|
|
132
|
+
const handleMouseMove = (e) => {
|
|
133
|
+
const [pointerX, pointerY] = pointer(e, svgContainer);
|
|
134
|
+
const hoverShapeData = getShapeData([pointerX, pointerY]);
|
|
130
135
|
if (hoverShapeData.length) {
|
|
131
136
|
const position = [pointerX, pointerY];
|
|
132
137
|
dispatcher.call('hover-shape', e.target, hoverShapeData, position);
|
|
@@ -137,5 +142,12 @@ export const TooltipTriggerArea = (args) => {
|
|
|
137
142
|
throttledHandleMouseMove.cancel();
|
|
138
143
|
dispatcher.call('hover-shape', {}, undefined);
|
|
139
144
|
};
|
|
140
|
-
|
|
145
|
+
const handleClick = (e) => {
|
|
146
|
+
const [pointerX, pointerY] = pointer(e, svgContainer);
|
|
147
|
+
const shapeData = getShapeData([pointerX, pointerY]);
|
|
148
|
+
if (shapeData.length) {
|
|
149
|
+
dispatcher.call('click-chart', undefined, { point: get(shapeData, '[0].data'), series: get(shapeData, '[0].series') }, e);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
return (React.createElement("rect", { ref: rectRef, width: boundsWidth, height: boundsHeight, fill: "transparent", onMouseMove: throttledHandleMouseMove, onMouseLeave: handleMouseLeave, onClick: handleClick }));
|
|
141
153
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import isNil from 'lodash/isNil';
|
|
3
2
|
import { Popup, useVirtualElementRef } from '@gravity-ui/uikit';
|
|
3
|
+
import isNil from 'lodash/isNil';
|
|
4
4
|
import { block } from '../../../../../utils/cn';
|
|
5
5
|
import { DefaultContent } from './DefaultContent';
|
|
6
6
|
export * from './TooltipTriggerArea';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ScaleBand, ScaleLinear, ScaleTime } from 'd3';
|
|
2
|
+
import { ChartKitWidgetAxis, ChartKitWidgetSeries } from '../../../../../types';
|
|
2
3
|
import type { PreparedAxis } from '../useChartOptions/types';
|
|
3
4
|
import { PreparedSeries } from '../useSeries/types';
|
|
4
|
-
import { ChartKitWidgetAxis, ChartKitWidgetSeries } from '../../../../../types';
|
|
5
5
|
export type ChartScale = ScaleLinear<number, number> | ScaleBand<string> | ScaleTime<number, number>;
|
|
6
6
|
type Args = {
|
|
7
7
|
boundsWidth: number;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { scaleBand, scaleLinear, scaleUtc
|
|
2
|
+
import { extent, scaleBand, scaleLinear, scaleUtc } from 'd3';
|
|
3
3
|
import get from 'lodash/get';
|
|
4
|
-
import { getOnlyVisibleSeries, getDataCategoryValue, getDomainDataYBySeries, getDomainDataXBySeries, isAxisRelatedSeries, isSeriesWithCategoryValues, } from '../../utils';
|
|
5
4
|
import { DEFAULT_AXIS_TYPE } from '../../constants';
|
|
5
|
+
import { getDataCategoryValue, getDomainDataXBySeries, getDomainDataYBySeries, getOnlyVisibleSeries, isAxisRelatedSeries, isSeriesWithCategoryValues, } from '../../utils';
|
|
6
6
|
const isNumericalArrayData = (data) => {
|
|
7
7
|
return data.every((d) => typeof d === 'number' || d === null);
|
|
8
8
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BaseTextStyle,
|
|
1
|
+
import type { BaseTextStyle, ChartKitWidgetAxis, ChartKitWidgetAxisLabels, ChartKitWidgetAxisType, ChartKitWidgetData, ChartMargin } from '../../../../../types';
|
|
2
2
|
type PreparedAxisLabels = Omit<ChartKitWidgetAxisLabels, 'enabled' | 'padding' | 'style' | 'autoRotation'> & Required<Pick<ChartKitWidgetAxisLabels, 'enabled' | 'padding' | 'margin' | 'rotation'>> & {
|
|
3
3
|
style: BaseTextStyle;
|
|
4
4
|
rotation: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ChartKitWidgetAxis, ChartKitWidgetSeries } from '../../../../../types';
|
|
2
2
|
import type { PreparedAxis } from './types';
|
|
3
3
|
export declare const getPreparedXAxis: ({ xAxis, series, width, }: {
|
|
4
4
|
xAxis?: ChartKitWidgetAxis | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
|
-
import {
|
|
2
|
+
import { DEFAULT_AXIS_LABEL_FONT_SIZE, axisLabelsDefaults, xAxisTitleDefaults, } from '../../constants';
|
|
3
3
|
import { calculateCos, formatAxisTickLabel, getClosestPointsRange, getHorisontalSvgTextHeight, getLabelsSize, getMaxTickCount, getTicksCount, getXAxisItems, hasOverlappingLabels, } from '../../utils';
|
|
4
4
|
import { createXScale } from '../useAxisScales';
|
|
5
5
|
function getLabelSettings({ axis, series, width, autoRotation = true, }) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { DEFAULT_AXIS_LABEL_FONT_SIZE, axisLabelsDefaults, yAxisTitleDefaults, } from '../../constants';
|
|
3
|
+
import { formatAxisTickLabel, getClosestPointsRange, getHorisontalSvgTextHeight, getLabelsSize, getScaleTicks, } from '../../utils';
|
|
4
4
|
import { createYScale } from '../useAxisScales';
|
|
5
5
|
const getAxisLabelMaxWidth = (args) => {
|
|
6
6
|
const { axis, series } = args;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ChartKitWidgetData } from '../../../../../types';
|
|
2
2
|
import type { PreparedAxis, PreparedChart } from '../useChartOptions/types';
|
|
3
|
-
import type {
|
|
3
|
+
import type { OnLegendItemClick, PreparedSeries } from './types';
|
|
4
4
|
type Args = {
|
|
5
5
|
chartWidth: number;
|
|
6
6
|
chartHeight: number;
|
|
@@ -2,10 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import { group, scaleOrdinal } from 'd3';
|
|
3
3
|
import { DEFAULT_PALETTE } from '../../constants';
|
|
4
4
|
import { getSeriesNames } from '../../utils';
|
|
5
|
-
import {
|
|
6
|
-
import { getPreparedLegend, getLegendComponents } from './prepare-legend';
|
|
5
|
+
import { getLegendComponents, getPreparedLegend } from './prepare-legend';
|
|
7
6
|
import { getPreparedOptions } from './prepare-options';
|
|
8
7
|
import { prepareSeries } from './prepareSeries';
|
|
8
|
+
import { getActiveLegendItems, getAllLegendItems } from './utils';
|
|
9
9
|
export const useSeries = (args) => {
|
|
10
10
|
const { chartWidth, chartHeight, chartMargin, legend, preparedYAxis, series: { data: series, options: seriesOptions }, } = args;
|
|
11
11
|
const preparedLegend = React.useMemo(() => getPreparedLegend({ legend, series }), [legend, series]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ScaleOrdinal } from 'd3';
|
|
2
|
-
import {
|
|
2
|
+
import { AreaSeries, ChartKitWidgetSeriesOptions } from '../../../../../types';
|
|
3
3
|
import { PreparedAreaSeries, PreparedLegend } from './types';
|
|
4
4
|
export declare const DEFAULT_LINE_WIDTH = 1;
|
|
5
5
|
export declare const DEFAULT_MARKER: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
2
|
import merge from 'lodash/merge';
|
|
3
|
-
import { DEFAULT_DATALABELS_PADDING, DEFAULT_DATALABELS_STYLE, DEFAULT_HALO_OPTIONS, DEFAULT_POINT_MARKER_OPTIONS, } from './constants';
|
|
4
3
|
import { getRandomCKId } from '../../../../../utils';
|
|
4
|
+
import { DEFAULT_DATALABELS_PADDING, DEFAULT_DATALABELS_STYLE, DEFAULT_HALO_OPTIONS, DEFAULT_POINT_MARKER_OPTIONS, } from './constants';
|
|
5
5
|
import { getSeriesStackId, prepareLegendSymbol } from './utils';
|
|
6
6
|
export const DEFAULT_LINE_WIDTH = 1;
|
|
7
7
|
export const DEFAULT_MARKER = Object.assign(Object.assign({}, DEFAULT_POINT_MARKER_OPTIONS), { enabled: false });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
2
|
import { getRandomCKId } from '../../../../../utils';
|
|
3
|
-
import { getSeriesStackId, prepareLegendSymbol } from './utils';
|
|
4
3
|
import { DEFAULT_DATALABELS_PADDING, DEFAULT_DATALABELS_STYLE } from './constants';
|
|
4
|
+
import { getSeriesStackId, prepareLegendSymbol } from './utils';
|
|
5
5
|
export function prepareBarXSeries(args) {
|
|
6
6
|
const { colorScale, series: seriesList, legend } = args;
|
|
7
7
|
return seriesList.map((series) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
2
|
import { getRandomCKId } from '../../../../../utils';
|
|
3
|
-
import { getSeriesStackId, prepareLegendSymbol } from './utils';
|
|
4
|
-
import { DEFAULT_DATALABELS_STYLE } from './constants';
|
|
5
3
|
import { getLabelsSize } from '../../utils';
|
|
4
|
+
import { DEFAULT_DATALABELS_STYLE } from './constants';
|
|
5
|
+
import { getSeriesStackId, prepareLegendSymbol } from './utils';
|
|
6
6
|
function prepareDataLabels(series) {
|
|
7
7
|
var _a;
|
|
8
8
|
const enabled = get(series, 'dataLabels.enabled', false);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ChartKitWidgetData } from '../../../../../types';
|
|
2
2
|
import type { PreparedAxis, PreparedChart } from '../useChartOptions/types';
|
|
3
|
-
import type { PreparedLegend, PreparedSeries
|
|
3
|
+
import type { LegendItem, PreparedLegend, PreparedSeries } from './types';
|
|
4
4
|
export declare const getPreparedLegend: (args: {
|
|
5
5
|
legend: ChartKitWidgetData['legend'];
|
|
6
6
|
series: ChartKitWidgetData['series']['data'];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { select } from 'd3';
|
|
1
2
|
import clone from 'lodash/clone';
|
|
2
3
|
import get from 'lodash/get';
|
|
3
4
|
import merge from 'lodash/merge';
|
|
4
|
-
import { select } from 'd3';
|
|
5
5
|
import { legendDefaults } from '../../constants';
|
|
6
6
|
import { getHorisontalSvgTextHeight } from '../../utils';
|
|
7
7
|
import { getBoundsWidth } from '../useChartDimensions';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ScaleOrdinal } from 'd3';
|
|
2
2
|
import { DashStyle } from '../../../../../constants';
|
|
3
3
|
import { ChartKitWidgetSeriesOptions, LineSeries } from '../../../../../types';
|
|
4
|
-
import {
|
|
4
|
+
import { PreparedLegend, PreparedLineSeries } from './types';
|
|
5
5
|
export declare const DEFAULT_LEGEND_SYMBOL_SIZE = 16;
|
|
6
6
|
export declare const DEFAULT_LINE_WIDTH = 1;
|
|
7
7
|
export declare const DEFAULT_DASH_STYLE = DashStyle.Solid;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
2
|
import merge from 'lodash/merge';
|
|
3
3
|
import { DashStyle, LineCap } from '../../../../../constants';
|
|
4
|
-
import { DEFAULT_DATALABELS_PADDING, DEFAULT_DATALABELS_STYLE, DEFAULT_HALO_OPTIONS, DEFAULT_LEGEND_SYMBOL_PADDING, DEFAULT_POINT_MARKER_OPTIONS, } from './constants';
|
|
5
4
|
import { getRandomCKId } from '../../../../../utils';
|
|
5
|
+
import { DEFAULT_DATALABELS_PADDING, DEFAULT_DATALABELS_STYLE, DEFAULT_HALO_OPTIONS, DEFAULT_LEGEND_SYMBOL_PADDING, DEFAULT_POINT_MARKER_OPTIONS, } from './constants';
|
|
6
6
|
export const DEFAULT_LEGEND_SYMBOL_SIZE = 16;
|
|
7
7
|
export const DEFAULT_LINE_WIDTH = 1;
|
|
8
8
|
export const DEFAULT_DASH_STYLE = DashStyle.Solid;
|
|
@@ -72,6 +72,7 @@ export function prepareLineSeries(args) {
|
|
|
72
72
|
marker: prepareMarker(series, seriesOptions),
|
|
73
73
|
dashStyle: dashStyle,
|
|
74
74
|
linecap: prepareLinecap(dashStyle, series, seriesOptions),
|
|
75
|
+
opacity: get(series, 'opacity', null),
|
|
75
76
|
};
|
|
76
77
|
return prepared;
|
|
77
78
|
}, []);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { scaleOrdinal } from 'd3';
|
|
2
|
-
import { DEFAULT_PALETTE } from '../../constants';
|
|
3
|
-
import { getRandomCKId } from '../../../../../utils';
|
|
4
2
|
import get from 'lodash/get';
|
|
3
|
+
import { getRandomCKId } from '../../../../../utils';
|
|
4
|
+
import { DEFAULT_PALETTE } from '../../constants';
|
|
5
5
|
import { DEFAULT_DATALABELS_PADDING, DEFAULT_DATALABELS_STYLE } from './constants';
|
|
6
6
|
import { prepareLegendSymbol } from './utils';
|
|
7
7
|
export function preparePieSeries(args) {
|
|
@@ -52,6 +52,7 @@ export function preparePieSeries(args) {
|
|
|
52
52
|
},
|
|
53
53
|
},
|
|
54
54
|
renderCustomShape: series.renderCustomShape,
|
|
55
|
+
opacity: get(dataItem, 'opacity', null),
|
|
55
56
|
};
|
|
56
57
|
return result;
|
|
57
58
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ScaleOrdinal } from 'd3';
|
|
2
|
-
import type { PreparedLegend, PreparedScatterSeries } from './types';
|
|
3
2
|
import type { ChartKitWidgetSeriesOptions, ScatterSeries } from '../../../../../types';
|
|
3
|
+
import type { PreparedLegend, PreparedScatterSeries } from './types';
|
|
4
4
|
interface PrepareScatterSeriesArgs {
|
|
5
5
|
colorScale: ScaleOrdinal<string, string>;
|
|
6
6
|
series: ScatterSeries[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
2
|
import merge from 'lodash/merge';
|
|
3
|
+
import { getRandomCKId } from '../../../../../utils';
|
|
3
4
|
import { getSymbolType } from '../../utils';
|
|
4
|
-
import { prepareLegendSymbol } from './utils';
|
|
5
5
|
import { DEFAULT_HALO_OPTIONS, DEFAULT_POINT_MARKER_OPTIONS } from './constants';
|
|
6
|
-
import {
|
|
6
|
+
import { prepareLegendSymbol } from './utils';
|
|
7
7
|
function prepareMarker(series, seriesOptions, index) {
|
|
8
8
|
const seriesHoverState = get(seriesOptions, 'scatter.states.hover');
|
|
9
9
|
const markerNormalState = Object.assign(Object.assign({}, DEFAULT_POINT_MARKER_OPTIONS), { enabled: true, symbol: series.symbolType || getSymbolType(index) });
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ChartKitError } from '../../../../../libs';
|
|
2
|
-
import {
|
|
2
|
+
import { prepareArea } from './prepare-area';
|
|
3
3
|
import { prepareBarXSeries } from './prepare-bar-x';
|
|
4
4
|
import { prepareBarYSeries } from './prepare-bar-y';
|
|
5
|
+
import { prepareLineSeries } from './prepare-line';
|
|
5
6
|
import { preparePieSeries } from './prepare-pie';
|
|
6
|
-
import { prepareArea } from './prepare-area';
|
|
7
7
|
import { prepareScatterSeries } from './prepare-scatter';
|
|
8
8
|
import { prepareTreemap } from './prepare-treemap';
|
|
9
9
|
export function prepareSeries(args) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BarXSeries, BarXSeriesData, BaseTextStyle, ChartKitWidgetLegend, PieSeries, PieSeriesData, RectLegendSymbolOptions, ScatterSeries, ScatterSeriesData, BarYSeries, BarYSeriesData, LineSeries, LineSeriesData, ConnectorShape, ConnectorCurve, PathLegendSymbolOptions, SymbolLegendSymbolOptions, AreaSeries, AreaSeriesData, TreemapSeries, TreemapSeriesData } from '../../../../../types';
|
|
2
|
-
import type { SeriesOptionsDefaults } from '../../constants';
|
|
3
1
|
import { DashStyle, LayoutAlgorithm, LineCap, SymbolType } from '../../../../../constants';
|
|
2
|
+
import { AreaSeries, AreaSeriesData, BarXSeries, BarXSeriesData, BarYSeries, BarYSeriesData, BaseTextStyle, ChartKitWidgetLegend, ConnectorCurve, ConnectorShape, LineSeries, LineSeriesData, PathLegendSymbolOptions, PieSeries, PieSeriesData, RectLegendSymbolOptions, ScatterSeries, ScatterSeriesData, SymbolLegendSymbolOptions, TreemapSeries, TreemapSeriesData } from '../../../../../types';
|
|
3
|
+
import type { SeriesOptionsDefaults } from '../../constants';
|
|
4
4
|
export type RectLegendSymbol = {
|
|
5
5
|
shape: 'rect';
|
|
6
6
|
} & Required<RectLegendSymbolOptions>;
|
|
@@ -130,6 +130,7 @@ export type PreparedPieSeries = {
|
|
|
130
130
|
};
|
|
131
131
|
};
|
|
132
132
|
renderCustomShape?: PieSeries['renderCustomShape'];
|
|
133
|
+
opacity: number | null;
|
|
133
134
|
} & BasePreparedSeries;
|
|
134
135
|
export type PreparedLineSeries = {
|
|
135
136
|
type: LineSeries['type'];
|
|
@@ -161,6 +162,7 @@ export type PreparedLineSeries = {
|
|
|
161
162
|
};
|
|
162
163
|
dashStyle: DashStyle;
|
|
163
164
|
linecap: LineCap;
|
|
165
|
+
opacity: number | null;
|
|
164
166
|
} & BasePreparedSeries;
|
|
165
167
|
export type PreparedAreaSeries = {
|
|
166
168
|
type: AreaSeries['type'];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PreparedLegendSymbol, PreparedSeries, StackedSeries } from './types';
|
|
2
|
-
import { ChartKitWidgetSeries } from '../../../../../types';
|
|
3
1
|
import { SymbolType } from '../../../../../constants';
|
|
2
|
+
import { ChartKitWidgetSeries } from '../../../../../types';
|
|
3
|
+
import { PreparedLegendSymbol, PreparedSeries, StackedSeries } from './types';
|
|
4
4
|
export declare const getActiveLegendItems: (series: PreparedSeries[]) => string[];
|
|
5
5
|
export declare const getAllLegendItems: (series: PreparedSeries[]) => string[];
|
|
6
6
|
export declare function prepareLegendSymbol(series: ChartKitWidgetSeries, symbolType?: `${SymbolType}`): PreparedLegendSymbol;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import memoize from 'lodash/memoize';
|
|
2
|
+
import { SymbolType } from '../../../../../constants';
|
|
2
3
|
import { getRandomCKId } from '../../../../../utils';
|
|
3
4
|
import { DEFAULT_LEGEND_SYMBOL_PADDING, DEFAULT_LEGEND_SYMBOL_SIZE } from './constants';
|
|
4
|
-
import { SymbolType } from '../../../../../constants';
|
|
5
5
|
export const getActiveLegendItems = (series) => {
|
|
6
6
|
return series.reduce((acc, s) => {
|
|
7
7
|
if (s.legend.enabled && s.visible) {
|