@gravity-ui/chartkit 4.13.0 → 4.15.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.
Files changed (94) hide show
  1. package/build/constants/index.d.ts +1 -0
  2. package/build/constants/index.js +1 -0
  3. package/build/constants/widget-data.d.ts +27 -0
  4. package/build/constants/widget-data.js +29 -0
  5. package/build/i18n/keysets/en.json +6 -1
  6. package/build/i18n/keysets/ru.json +6 -1
  7. package/build/libs/chartkit-error/chartkit-error.d.ts +1 -0
  8. package/build/libs/chartkit-error/chartkit-error.js +1 -0
  9. package/build/plugins/d3/examples/ExampleWrapper.d.ts +7 -0
  10. package/build/plugins/d3/examples/ExampleWrapper.js +5 -0
  11. package/build/plugins/d3/examples/area/Basic.d.ts +2 -0
  12. package/build/plugins/d3/examples/area/Basic.js +34 -0
  13. package/build/plugins/d3/examples/area/StackedArea.d.ts +2 -0
  14. package/build/plugins/d3/examples/area/StackedArea.js +47 -0
  15. package/build/plugins/d3/examples/bar-x/Basic.js +19 -9
  16. package/build/plugins/d3/examples/bar-x/DataLabels.js +4 -2
  17. package/build/plugins/d3/examples/bar-x/GroupedColumns.js +4 -2
  18. package/build/plugins/d3/examples/bar-x/StackedColumns.js +4 -2
  19. package/build/plugins/d3/examples/bar-y/Basic.js +4 -2
  20. package/build/plugins/d3/examples/bar-y/GroupedColumns.js +4 -2
  21. package/build/plugins/d3/examples/bar-y/StackedColumns.js +4 -2
  22. package/build/plugins/d3/examples/combined/LineAndBarX.js +5 -3
  23. package/build/plugins/d3/examples/line/Basic.js +4 -2
  24. package/build/plugins/d3/examples/line/DataLabels.js +4 -2
  25. package/build/plugins/d3/examples/line/LineWithMarkers.js +4 -2
  26. package/build/plugins/d3/examples/line/Shapes.d.ts +2 -0
  27. package/build/plugins/d3/examples/line/Shapes.js +93 -0
  28. package/build/plugins/d3/examples/pie/Basic.js +4 -2
  29. package/build/plugins/d3/examples/pie/Donut.js +4 -2
  30. package/build/plugins/d3/examples/scatter/Basic.js +4 -2
  31. package/build/plugins/d3/renderer/D3Widget.js +27 -23
  32. package/build/plugins/d3/renderer/components/Legend.js +4 -0
  33. package/build/plugins/d3/renderer/components/Tooltip/DefaultContent.js +1 -0
  34. package/build/plugins/d3/renderer/components/Tooltip/TooltipTriggerArea.js +1 -1
  35. package/build/plugins/d3/renderer/constants/defaults/axis.d.ts +2 -0
  36. package/build/plugins/d3/renderer/constants/defaults/axis.js +1 -0
  37. package/build/plugins/d3/renderer/constants/defaults/series-options.js +16 -4
  38. package/build/plugins/d3/renderer/hooks/useAxisScales/index.js +3 -2
  39. package/build/plugins/d3/renderer/hooks/useChartOptions/y-axis.js +2 -1
  40. package/build/plugins/d3/renderer/hooks/useSeries/constants.d.ts +2 -1
  41. package/build/plugins/d3/renderer/hooks/useSeries/constants.js +5 -0
  42. package/build/plugins/d3/renderer/hooks/useSeries/prepare-area.d.ts +19 -0
  43. package/build/plugins/d3/renderer/hooks/useSeries/prepare-area.js +66 -0
  44. package/build/plugins/d3/renderer/hooks/useSeries/prepare-bar-x.js +2 -7
  45. package/build/plugins/d3/renderer/hooks/useSeries/prepare-bar-y.js +2 -7
  46. package/build/plugins/d3/renderer/hooks/useSeries/prepare-line-series.d.ts +2 -0
  47. package/build/plugins/d3/renderer/hooks/useSeries/prepare-line-series.js +13 -6
  48. package/build/plugins/d3/renderer/hooks/useSeries/prepare-pie.d.ts +2 -1
  49. package/build/plugins/d3/renderer/hooks/useSeries/prepare-pie.js +11 -1
  50. package/build/plugins/d3/renderer/hooks/useSeries/prepareSeries.js +10 -1
  51. package/build/plugins/d3/renderer/hooks/useSeries/types.d.ts +50 -7
  52. package/build/plugins/d3/renderer/hooks/useSeries/utils.d.ts +2 -1
  53. package/build/plugins/d3/renderer/hooks/useSeries/utils.js +10 -0
  54. package/build/plugins/d3/renderer/hooks/useShapes/area/index.d.ts +11 -0
  55. package/build/plugins/d3/renderer/hooks/useShapes/area/index.js +137 -0
  56. package/build/plugins/d3/renderer/hooks/useShapes/area/prepare-data.d.ts +11 -0
  57. package/build/plugins/d3/renderer/hooks/useShapes/area/prepare-data.js +114 -0
  58. package/build/plugins/d3/renderer/hooks/useShapes/area/types.d.ts +27 -0
  59. package/build/plugins/d3/renderer/hooks/useShapes/area/types.js +1 -0
  60. package/build/plugins/d3/renderer/hooks/useShapes/index.d.ts +2 -1
  61. package/build/plugins/d3/renderer/hooks/useShapes/index.js +16 -0
  62. package/build/plugins/d3/renderer/hooks/useShapes/line/index.js +9 -65
  63. package/build/plugins/d3/renderer/hooks/useShapes/line/prepare-data.js +5 -2
  64. package/build/plugins/d3/renderer/hooks/useShapes/line/types.d.ts +3 -0
  65. package/build/plugins/d3/renderer/hooks/useShapes/marker.d.ts +12 -0
  66. package/build/plugins/d3/renderer/hooks/useShapes/marker.js +70 -0
  67. package/build/plugins/d3/renderer/hooks/useShapes/pie/index.d.ts +3 -2
  68. package/build/plugins/d3/renderer/hooks/useShapes/pie/index.js +28 -0
  69. package/build/plugins/d3/renderer/hooks/useShapes/pie/prepare-data.js +9 -3
  70. package/build/plugins/d3/renderer/hooks/useShapes/pie/types.d.ts +5 -0
  71. package/build/plugins/d3/renderer/hooks/useShapes/scatter/index.js +1 -1
  72. package/build/plugins/d3/renderer/hooks/useShapes/utils.d.ts +2 -0
  73. package/build/plugins/d3/renderer/hooks/useShapes/utils.js +17 -0
  74. package/build/plugins/d3/renderer/utils/index.d.ts +1 -1
  75. package/build/plugins/d3/renderer/utils/index.js +16 -9
  76. package/build/plugins/d3/renderer/validation/__mocks__/index.d.ts +3 -0
  77. package/build/plugins/d3/renderer/validation/__mocks__/index.js +44 -0
  78. package/build/plugins/d3/renderer/validation/index.d.ts +2 -0
  79. package/build/plugins/d3/renderer/validation/index.js +139 -0
  80. package/build/plugins/highcharts/renderer/helpers/config/config.js +0 -3
  81. package/build/types/widget-data/area.d.ts +58 -0
  82. package/build/types/widget-data/area.js +1 -0
  83. package/build/types/widget-data/bar-x.d.ts +2 -1
  84. package/build/types/widget-data/bar-y.d.ts +2 -1
  85. package/build/types/widget-data/halo.d.ts +9 -0
  86. package/build/types/widget-data/halo.js +1 -0
  87. package/build/types/widget-data/index.d.ts +2 -0
  88. package/build/types/widget-data/index.js +2 -0
  89. package/build/types/widget-data/line.d.ts +9 -4
  90. package/build/types/widget-data/pie.d.ts +2 -1
  91. package/build/types/widget-data/scatter.d.ts +2 -1
  92. package/build/types/widget-data/series.d.ts +40 -9
  93. package/build/types/widget-data/tooltip.d.ts +10 -1
  94. package/package.json +7 -2
@@ -31,4 +31,9 @@ export type PreparedPieData = {
31
31
  borderColor: string;
32
32
  series: PreparedPieSeries;
33
33
  connectorCurve: ConnectorCurve;
34
+ halo: {
35
+ enabled: boolean;
36
+ opacity: number;
37
+ size: number;
38
+ };
34
39
  };
@@ -22,7 +22,7 @@ export function ScatterSeriesShape(props) {
22
22
  const hoverOptions = get(seriesOptions, 'scatter.states.hover');
23
23
  const inactiveOptions = get(seriesOptions, 'scatter.states.inactive');
24
24
  const selection = svgElement
25
- .selectAll(`circle`)
25
+ .selectAll('circle')
26
26
  .data(preparedData, shapeKey)
27
27
  .join((enter) => enter.append('circle').attr('class', b('point')), (update) => update, (exit) => exit.remove())
28
28
  .attr('fill', (d) => d.data.color || d.series.color || '')
@@ -2,6 +2,7 @@ import type { BaseType } from 'd3';
2
2
  import type { BasicInactiveState } from '../../../../../types';
3
3
  import type { ChartScale } from '../useAxisScales';
4
4
  import type { PreparedAxis } from '../useChartOptions/types';
5
+ import { DashStyle } from '../../../../../constants';
5
6
  export declare function getXValue(args: {
6
7
  point: {
7
8
  x?: number | string;
@@ -25,3 +26,4 @@ export declare function setActiveState<T extends {
25
26
  state: BasicInactiveState | undefined;
26
27
  active: boolean;
27
28
  }): T;
29
+ export declare const getLineDashArray: (dashStyle: DashStyle, strokeWidth?: number) => string;
@@ -34,3 +34,20 @@ export function setActiveState(args) {
34
34
  }
35
35
  return datum;
36
36
  }
37
+ export const getLineDashArray = (dashStyle, strokeWidth = 2) => {
38
+ const value = dashStyle.toLowerCase();
39
+ const arrayValue = value
40
+ .replace('shortdashdotdot', '3,1,1,1,1,1,')
41
+ .replace('shortdashdot', '3,1,1,1')
42
+ .replace('shortdot', '1,1,')
43
+ .replace('shortdash', '3,1,')
44
+ .replace('longdash', '8,3,')
45
+ .replace(/dot/g, '1,3,')
46
+ .replace('dash', '4,3,')
47
+ .replace(/,$/, '')
48
+ .split(',')
49
+ .map((part) => {
50
+ return `${parseInt(part, 10) * strokeWidth}`;
51
+ });
52
+ return arrayValue.join(',').replace(/NaN/g, 'none');
53
+ };
@@ -1,5 +1,5 @@
1
1
  import { AxisDomain } from 'd3';
2
- import type { BaseTextStyle, ChartKitWidgetSeries, ChartKitWidgetSeriesData } from '../../../../types/widget-data';
2
+ import type { BaseTextStyle, ChartKitWidgetSeries, ChartKitWidgetSeriesData } from '../../../../types';
3
3
  import { PreparedAxis } from '../hooks';
4
4
  export * from './math';
5
5
  export * from './text';
@@ -6,6 +6,7 @@ import { formatNumber } from '../../../shared';
6
6
  import { DEFAULT_AXIS_LABEL_FONT_SIZE } from '../constants';
7
7
  import { getNumberUnitRate } from '../../../shared/format-number/format-number';
8
8
  import { getDefaultDateFormat } from './time';
9
+ import { getSeriesStackId } from '../hooks/useSeries/utils';
9
10
  export * from './math';
10
11
  export * from './text';
11
12
  export * from './time';
@@ -42,20 +43,26 @@ export const getDomainDataYBySeries = (series) => {
42
43
  const groupedSeries = group(series, (item) => item.type);
43
44
  return Array.from(groupedSeries).reduce((acc, [type, seriesList]) => {
44
45
  switch (type) {
46
+ case 'area':
45
47
  case 'bar-x': {
46
- const barXSeries = seriesList;
47
- const stackedSeries = group(barXSeries, (item) => item.stackId);
48
- Array.from(stackedSeries).forEach(([, stack]) => {
48
+ const stackedSeries = group(seriesList, getSeriesStackId);
49
+ Array.from(stackedSeries).forEach(([_stackId, seriesStack]) => {
49
50
  const values = {};
50
- stack.forEach((singleSeries) => {
51
+ seriesStack.forEach((singleSeries) => {
52
+ const data = new Map();
51
53
  singleSeries.data.forEach((point) => {
52
- const key = String(point.x || point.category);
53
- if (typeof values[key] === 'undefined') {
54
- values[key] = 0;
55
- }
54
+ const key = String(point.x);
55
+ let value = 0;
56
56
  if (point.y && typeof point.y === 'number') {
57
- values[key] += point.y;
57
+ value = point.y;
58
+ }
59
+ if (data.has(key)) {
60
+ value = Math.max(value, data.get(key));
58
61
  }
62
+ data.set(key, value);
63
+ });
64
+ Array.from(data).forEach(([key, value]) => {
65
+ values[key] = (values[key] || 0) + value;
59
66
  });
60
67
  });
61
68
  acc.push(...Object.values(values));
@@ -0,0 +1,3 @@
1
+ import { ChartKitWidgetData } from '../../../../../types';
2
+ export declare const XY_SERIES: Record<string, ChartKitWidgetData>;
3
+ export declare const PIE_SERIES: Record<string, ChartKitWidgetData>;
@@ -0,0 +1,44 @@
1
+ export const XY_SERIES = {
2
+ INVALID_CATEGORY_X: {
3
+ series: {
4
+ data: [{ type: 'scatter', data: [{ x: undefined, y: 1 }], name: 'Series' }],
5
+ },
6
+ xAxis: { type: 'category' },
7
+ },
8
+ INVALID_CATEGORY_Y: {
9
+ series: {
10
+ data: [{ type: 'scatter', data: [{ x: 1, y: undefined }], name: 'Series' }],
11
+ },
12
+ yAxis: [{ type: 'category' }],
13
+ },
14
+ INVALID_DATETIME_X: {
15
+ series: {
16
+ data: [{ type: 'scatter', data: [{ x: undefined, y: 1 }], name: 'Series' }],
17
+ },
18
+ xAxis: { type: 'datetime' },
19
+ },
20
+ INVALID_DATETIME_Y: {
21
+ series: {
22
+ data: [{ type: 'scatter', data: [{ x: undefined, y: 1 }], name: 'Series' }],
23
+ },
24
+ yAxis: [{ type: 'datetime' }],
25
+ },
26
+ INVALID_LINEAR_X: {
27
+ series: {
28
+ data: [{ type: 'scatter', data: [{ x: 'str', y: 1 }], name: 'Series' }],
29
+ },
30
+ },
31
+ INVALID_LINEAR_Y: {
32
+ series: {
33
+ data: [{ type: 'scatter', data: [{ x: 1, y: 'str' }], name: 'Series' }],
34
+ },
35
+ },
36
+ };
37
+ export const PIE_SERIES = {
38
+ INVALID_VALUE: {
39
+ series: {
40
+ // @ts-expect-error
41
+ data: [{ type: 'pie', data: [{ value: undefined, name: 'Series' }] }],
42
+ },
43
+ },
44
+ };
@@ -0,0 +1,2 @@
1
+ import { ChartKitWidgetData } from '../../../../types';
2
+ export declare const validateData: (data?: ChartKitWidgetData) => void;
@@ -0,0 +1,139 @@
1
+ import get from 'lodash/get';
2
+ import isEmpty from 'lodash/isEmpty';
3
+ import { SeriesType } from '../../../../constants';
4
+ import { ChartKitError, CHARTKIT_ERROR_CODE } from '../../../../libs';
5
+ import { i18n } from '../../../../i18n';
6
+ import { DEFAULT_AXIS_TYPE } from '../constants';
7
+ const AVAILABLE_SERIES_TYPES = Object.values(SeriesType);
8
+ const validateXYSeries = (args) => {
9
+ const { series, xAxis, yAxis } = args;
10
+ const xType = get(xAxis, 'type', DEFAULT_AXIS_TYPE);
11
+ const yType = get(yAxis, 'type', DEFAULT_AXIS_TYPE);
12
+ series.data.forEach(({ x, y }) => {
13
+ switch (xType) {
14
+ case 'category': {
15
+ if (typeof x !== 'string' && typeof x !== 'number') {
16
+ throw new ChartKitError({
17
+ code: CHARTKIT_ERROR_CODE.INVALID_DATA,
18
+ message: i18n('error', 'label_invalid-axis-category-data-point', {
19
+ key: 'x',
20
+ seriesName: series.name,
21
+ }),
22
+ });
23
+ }
24
+ break;
25
+ }
26
+ case 'datetime': {
27
+ if (typeof x !== 'number') {
28
+ throw new ChartKitError({
29
+ code: CHARTKIT_ERROR_CODE.INVALID_DATA,
30
+ message: i18n('error', 'label_invalid-axis-datetime-data-point', {
31
+ key: 'x',
32
+ seriesName: series.name,
33
+ }),
34
+ });
35
+ }
36
+ break;
37
+ }
38
+ case 'linear': {
39
+ if (typeof x !== 'number' && x !== null) {
40
+ throw new ChartKitError({
41
+ code: CHARTKIT_ERROR_CODE.INVALID_DATA,
42
+ message: i18n('error', 'label_invalid-axis-linear-data-point', {
43
+ key: 'x',
44
+ seriesName: series.name,
45
+ }),
46
+ });
47
+ }
48
+ }
49
+ }
50
+ switch (yType) {
51
+ case 'category': {
52
+ if (typeof y !== 'string' && typeof y !== 'number') {
53
+ throw new ChartKitError({
54
+ code: CHARTKIT_ERROR_CODE.INVALID_DATA,
55
+ message: i18n('error', 'label_invalid-axis-category-data-point', {
56
+ key: 'y',
57
+ seriesName: series.name,
58
+ }),
59
+ });
60
+ }
61
+ break;
62
+ }
63
+ case 'datetime': {
64
+ if (typeof y !== 'number') {
65
+ throw new ChartKitError({
66
+ code: CHARTKIT_ERROR_CODE.INVALID_DATA,
67
+ message: i18n('error', 'label_invalid-axis-datetime-data-point', {
68
+ key: 'y',
69
+ seriesName: series.name,
70
+ }),
71
+ });
72
+ }
73
+ break;
74
+ }
75
+ case 'linear': {
76
+ if (typeof y !== 'number' && y !== null) {
77
+ throw new ChartKitError({
78
+ code: CHARTKIT_ERROR_CODE.INVALID_DATA,
79
+ message: i18n('error', 'label_invalid-axis-linear-data-point', {
80
+ key: 'y',
81
+ seriesName: series.name,
82
+ }),
83
+ });
84
+ }
85
+ }
86
+ }
87
+ });
88
+ };
89
+ const validatePieSeries = ({ series }) => {
90
+ series.data.forEach(({ value }) => {
91
+ if (typeof value !== 'number') {
92
+ throw new ChartKitError({
93
+ code: CHARTKIT_ERROR_CODE.INVALID_DATA,
94
+ message: i18n('error', 'label_invalid-pie-data-value'),
95
+ });
96
+ }
97
+ });
98
+ };
99
+ const validateSeries = (args) => {
100
+ const { series, xAxis, yAxis } = args;
101
+ if (!AVAILABLE_SERIES_TYPES.includes(series.type)) {
102
+ throw new ChartKitError({
103
+ code: CHARTKIT_ERROR_CODE.INVALID_DATA,
104
+ message: i18n('error', 'label_invalid-series-type', {
105
+ types: AVAILABLE_SERIES_TYPES.join(', '),
106
+ }),
107
+ });
108
+ }
109
+ switch (series.type) {
110
+ case 'bar-x':
111
+ case 'bar-y':
112
+ case 'line':
113
+ case 'scatter': {
114
+ validateXYSeries({ series, xAxis, yAxis });
115
+ break;
116
+ }
117
+ case 'pie': {
118
+ validatePieSeries({ series });
119
+ }
120
+ }
121
+ };
122
+ export const validateData = (data) => {
123
+ if (isEmpty(data) || isEmpty(data.series) || isEmpty(data.series.data)) {
124
+ throw new ChartKitError({
125
+ code: CHARTKIT_ERROR_CODE.NO_DATA,
126
+ message: i18n('error', 'label_no-data'),
127
+ });
128
+ }
129
+ if (data.series.data.some((s) => isEmpty(s.data))) {
130
+ throw new ChartKitError({
131
+ code: CHARTKIT_ERROR_CODE.INVALID_DATA,
132
+ message: 'You should specify data for all series',
133
+ });
134
+ }
135
+ data.series.data.forEach((series) => {
136
+ var _a;
137
+ validateSeries({ series, yAxis: (_a = data.yAxis) === null || _a === void 0 ? void 0 : _a[0], xAxis: data.xAxis });
138
+ });
139
+ };
@@ -1155,9 +1155,6 @@ export function prepareConfig(data, options, isMobile, holidays) {
1155
1155
  var _a;
1156
1156
  if (chartType === 'column' || chartType === 'bar') {
1157
1157
  this.series.forEach((seriesItem) => {
1158
- if (!seriesItem.legendItem) {
1159
- return;
1160
- }
1161
1158
  const color = seriesItem.color;
1162
1159
  // The update method updates all series, and therefore,
1163
1160
  // after working out the handleLegendItemMouseOverAndOut,
@@ -0,0 +1,58 @@
1
+ import { SeriesType } from '../../constants';
2
+ import type { BaseSeries, BaseSeriesData } from './base';
3
+ import type { ChartKitWidgetLegend, RectLegendSymbolOptions } from './legend';
4
+ import type { PointMarkerOptions } from './marker';
5
+ export type AreaSeriesData<T = any> = BaseSeriesData<T> & {
6
+ /**
7
+ * The `x` value of the point. Depending on the context , it may represents:
8
+ * - numeric value (for `linear` x axis)
9
+ * - timestamp value (for `datetime` x axis)
10
+ * - x axis category value (for `category` x axis). If the type is a string, then it is a category value itself. If the type is a number, then it is the index of an element in the array of categories described in `xAxis.categories`
11
+ */
12
+ x?: string | number;
13
+ /**
14
+ * The `y` value of the point. Depending on the context , it may represents:
15
+ * - numeric value (for `linear` y axis)
16
+ * - timestamp value (for `datetime` y axis)
17
+ * - y axis category value (for `category` y axis). If the type is a string, then it is a category value itself. If the type is a number, then it is the index of an element in the array of categories described in `yAxis[0].categories`
18
+ */
19
+ y?: string | number;
20
+ /** Data label value of the point. If not specified, the y value is used. */
21
+ label?: string | number;
22
+ };
23
+ export type AreaMarkerSymbol = 'circle' | 'square';
24
+ export type AreaMarkerOptions = PointMarkerOptions & {
25
+ symbol?: AreaMarkerSymbol;
26
+ };
27
+ export type AreaSeries<T = any> = BaseSeries & {
28
+ type: typeof SeriesType.Area;
29
+ data: AreaSeriesData<T>[];
30
+ /** The name of the series (used in legend, tooltip etc) */
31
+ name: string;
32
+ /** Whether to stack the values of each series on top of each other.
33
+ * Possible values are undefined to disable, "normal" to stack by value
34
+ *
35
+ * @default undefined
36
+ * */
37
+ stacking?: 'normal';
38
+ /** This option allows grouping series in a stacked chart */
39
+ stackId?: string;
40
+ /** The main color of the series (hex, rgba) */
41
+ color?: string;
42
+ /** Fill opacity for the area
43
+ *
44
+ * @default 0.75
45
+ * */
46
+ opacity?: number;
47
+ /** Pixel width of the graph line.
48
+ *
49
+ * @default 1
50
+ * */
51
+ lineWidth?: number;
52
+ /** Individual series legend options. Has higher priority than legend options in widget data */
53
+ legend?: ChartKitWidgetLegend & {
54
+ symbol?: RectLegendSymbolOptions;
55
+ };
56
+ /** Options for the point markers of line in area series */
57
+ marker?: AreaMarkerOptions;
58
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
+ import { SeriesType } from '../../constants';
1
2
  import type { BaseSeries, BaseSeriesData } from './base';
2
3
  import type { ChartKitWidgetSeriesOptions } from './series';
3
4
  import { ChartKitWidgetLegend, RectLegendSymbolOptions } from './legend';
@@ -26,7 +27,7 @@ export type BarXSeriesData<T = any> = BaseSeriesData<T> & {
26
27
  label?: string | number;
27
28
  };
28
29
  export type BarXSeries<T = any> = BaseSeries & {
29
- type: 'bar-x';
30
+ type: typeof SeriesType.BarX;
30
31
  data: BarXSeriesData<T>[];
31
32
  /** The name of the series (used in legend, tooltip etc) */
32
33
  name: string;
@@ -1,3 +1,4 @@
1
+ import { SeriesType } from '../../constants';
1
2
  import type { BaseSeries, BaseSeriesData } from './base';
2
3
  import type { ChartKitWidgetSeriesOptions } from './series';
3
4
  import { ChartKitWidgetLegend, RectLegendSymbolOptions } from './legend';
@@ -20,7 +21,7 @@ export type BarYSeriesData<T = any> = BaseSeriesData<T> & {
20
21
  label?: string | number;
21
22
  };
22
23
  export type BarYSeries<T = any> = BaseSeries & {
23
- type: 'bar-y';
24
+ type: typeof SeriesType.BarY;
24
25
  data: BarYSeriesData<T>[];
25
26
  /** The name of the series (used in legend, tooltip etc) */
26
27
  name: string;
@@ -0,0 +1,9 @@
1
+ /** The halo appearing around the hovered part of series(point in line-type series or slice in pie charts) */
2
+ export type Halo = {
3
+ /** Enable or disable the halo */
4
+ enabled?: boolean;
5
+ /** The opacity of halo */
6
+ opacity?: number;
7
+ /** The pixel size of the halo. Radius for point markers or width of the outside slice in pie charts. */
8
+ size?: number;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -12,10 +12,12 @@ export * from './pie';
12
12
  export * from './scatter';
13
13
  export * from './bar-x';
14
14
  export * from './bar-y';
15
+ export * from './area';
15
16
  export * from './line';
16
17
  export * from './series';
17
18
  export * from './title';
18
19
  export * from './tooltip';
20
+ export * from './halo';
19
21
  export type ChartKitWidgetData<T = any> = {
20
22
  chart?: ChartKitWidgetChart;
21
23
  legend?: ChartKitWidgetLegend;
@@ -6,7 +6,9 @@ export * from './pie';
6
6
  export * from './scatter';
7
7
  export * from './bar-x';
8
8
  export * from './bar-y';
9
+ export * from './area';
9
10
  export * from './line';
10
11
  export * from './series';
11
12
  export * from './title';
12
13
  export * from './tooltip';
14
+ export * from './halo';
@@ -1,6 +1,7 @@
1
- import { BaseSeries, BaseSeriesData } from './base';
2
- import { ChartKitWidgetLegend, RectLegendSymbolOptions } from './legend';
3
- import { PointMarkerOptions } from './marker';
1
+ import type { BaseSeries, BaseSeriesData } from './base';
2
+ import type { ChartKitWidgetLegend, RectLegendSymbolOptions } from './legend';
3
+ import type { PointMarkerOptions } from './marker';
4
+ import { DashStyle, LineCap, SeriesType } from '../../constants';
4
5
  export type LineSeriesData<T = any> = BaseSeriesData<T> & {
5
6
  /**
6
7
  * The `x` value of the point. Depending on the context , it may represents:
@@ -24,7 +25,7 @@ export type LineMarkerOptions = PointMarkerOptions & {
24
25
  symbol?: LineMarkerSymbol;
25
26
  };
26
27
  export type LineSeries<T = any> = BaseSeries & {
27
- type: 'line';
28
+ type: typeof SeriesType.Line;
28
29
  data: LineSeriesData<T>[];
29
30
  /** The name of the series (used in legend, tooltip etc) */
30
31
  name: string;
@@ -41,4 +42,8 @@ export type LineSeries<T = any> = BaseSeries & {
41
42
  };
42
43
  /** Options for the point markers of line series */
43
44
  marker?: LineMarkerOptions;
45
+ /** Option for line stroke style */
46
+ dashStyle?: `${DashStyle}`;
47
+ /** Option for line cap style */
48
+ linecap?: `${LineCap}`;
44
49
  };
@@ -1,3 +1,4 @@
1
+ import { SeriesType } from '../../constants';
1
2
  import type { BaseSeries, BaseSeriesData } from './base';
2
3
  import { ChartKitWidgetLegend, RectLegendSymbolOptions } from './legend';
3
4
  export type PieSeriesData<T = any> = BaseSeriesData<T> & {
@@ -13,7 +14,7 @@ export type PieSeriesData<T = any> = BaseSeriesData<T> & {
13
14
  export type ConnectorShape = 'straight-line' | 'polyline';
14
15
  export type ConnectorCurve = 'linear' | 'basic';
15
16
  export type PieSeries<T = any> = BaseSeries & {
16
- type: 'pie';
17
+ type: typeof SeriesType.Pie;
17
18
  data: PieSeriesData<T>[];
18
19
  /**
19
20
  * The color of the border surrounding each segment.
@@ -1,3 +1,4 @@
1
+ import { SeriesType } from '../../constants';
1
2
  import type { BaseSeries, BaseSeriesData } from './base';
2
3
  import type { ChartKitWidgetLegend, RectLegendSymbolOptions } from './legend';
3
4
  export type ScatterSeriesData<T = any> = BaseSeriesData<T> & {
@@ -24,7 +25,7 @@ export type ScatterSeriesData<T = any> = BaseSeriesData<T> & {
24
25
  radius?: number;
25
26
  };
26
27
  export type ScatterSeries<T = any> = BaseSeries & {
27
- type: 'scatter';
28
+ type: typeof SeriesType.Scatter;
28
29
  data: ScatterSeriesData<T>[];
29
30
  /** The name of the series (used in legend, tooltip etc) */
30
31
  name: string;
@@ -4,9 +4,12 @@ import type { ScatterSeries, ScatterSeriesData } from './scatter';
4
4
  import type { BarXSeries, BarXSeriesData } from './bar-x';
5
5
  import type { LineSeries, LineSeriesData, LineMarkerOptions } from './line';
6
6
  import type { BarYSeries, BarYSeriesData } from './bar-y';
7
- import { PointMarkerOptions } from './marker';
8
- export type ChartKitWidgetSeries<T = any> = ScatterSeries<T> | PieSeries<T> | BarXSeries<T> | BarYSeries<T> | LineSeries<T>;
9
- export type ChartKitWidgetSeriesData<T = any> = ScatterSeriesData<T> | PieSeriesData<T> | BarXSeriesData<T> | BarYSeriesData<T> | LineSeriesData<T>;
7
+ import type { PointMarkerOptions } from './marker';
8
+ import type { AreaSeries, AreaSeriesData } from './area';
9
+ import type { Halo } from './halo';
10
+ import { DashStyle, LineCap } from '../../constants';
11
+ export type ChartKitWidgetSeries<T = any> = ScatterSeries<T> | PieSeries<T> | BarXSeries<T> | BarYSeries<T> | LineSeries<T> | AreaSeries<T>;
12
+ export type ChartKitWidgetSeriesData<T = any> = ScatterSeriesData<T> | PieSeriesData<T> | BarXSeriesData<T> | BarYSeriesData<T> | LineSeriesData<T> | AreaSeriesData<T>;
10
13
  export type DataLabelRendererData<T = any> = {
11
14
  data: ChartKitWidgetSeriesData<T>;
12
15
  };
@@ -124,7 +127,10 @@ export type ChartKitWidgetSeriesOptions = {
124
127
  pie?: {
125
128
  /** Options for the series states that provide additional styling information to the series. */
126
129
  states?: {
127
- hover?: BasicHoverState;
130
+ hover?: BasicHoverState & {
131
+ /** Options for the halo appearing outside the hovered slice */
132
+ halo?: Halo;
133
+ };
128
134
  inactive?: BasicInactiveState;
129
135
  };
130
136
  };
@@ -146,11 +152,36 @@ export type ChartKitWidgetSeriesOptions = {
146
152
  hover?: BasicHoverState & {
147
153
  marker?: PointMarkerOptions & {
148
154
  /** Options for the halo appearing around the hovered point */
149
- halo?: {
150
- enabled?: boolean;
151
- opacity?: number;
152
- radius?: number;
153
- };
155
+ halo?: Halo;
156
+ };
157
+ };
158
+ inactive?: BasicInactiveState;
159
+ };
160
+ /** Options for the point markers of line series */
161
+ marker?: LineMarkerOptions;
162
+ /** Options for line style
163
+ *
164
+ * @default 'Solid'
165
+ * */
166
+ dashStyle?: `${DashStyle}`;
167
+ /** Options for line cap style
168
+ *
169
+ * @default 'round' when dashStyle is not 'solid', 'none' when dashStyle is not 'solid'
170
+ * */
171
+ linecap?: `${LineCap}`;
172
+ };
173
+ area?: {
174
+ /** Pixel width of the graph line.
175
+ *
176
+ * @default 1
177
+ * */
178
+ lineWidth?: number;
179
+ /** Options for the series states that provide additional styling information to the series. */
180
+ states?: {
181
+ hover?: BasicHoverState & {
182
+ marker?: PointMarkerOptions & {
183
+ /** Options for the halo appearing around the hovered point */
184
+ halo?: Halo;
154
185
  };
155
186
  };
156
187
  inactive?: BasicInactiveState;
@@ -4,6 +4,7 @@ import type { PieSeries, PieSeriesData } from './pie';
4
4
  import type { ScatterSeries, ScatterSeriesData } from './scatter';
5
5
  import type { LineSeries, LineSeriesData } from './line';
6
6
  import type { BarYSeries, BarYSeriesData } from './bar-y';
7
+ import type { AreaSeries, AreaSeriesData } from './area';
7
8
  export type TooltipDataChunkBarX<T = any> = {
8
9
  data: BarXSeriesData<T>;
9
10
  series: BarXSeries<T>;
@@ -32,7 +33,15 @@ export type TooltipDataChunkLine<T = any> = {
32
33
  name: string;
33
34
  };
34
35
  };
35
- export type TooltipDataChunk<T = any> = TooltipDataChunkBarX<T> | TooltipDataChunkBarY<T> | TooltipDataChunkPie<T> | TooltipDataChunkScatter<T> | TooltipDataChunkLine<T>;
36
+ export type TooltipDataChunkArea<T = any> = {
37
+ data: AreaSeriesData<T>;
38
+ series: {
39
+ type: AreaSeries['type'];
40
+ id: string;
41
+ name: string;
42
+ };
43
+ };
44
+ export type TooltipDataChunk<T = any> = TooltipDataChunkBarX<T> | TooltipDataChunkBarY<T> | TooltipDataChunkPie<T> | TooltipDataChunkScatter<T> | TooltipDataChunkLine<T> | TooltipDataChunkArea<T>;
36
45
  export type ChartKitWidgetTooltip<T = any> = {
37
46
  enabled?: boolean;
38
47
  /** Specifies the renderer for the tooltip. If returned null default tooltip renderer will be used. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/chartkit",
3
- "version": "4.13.0",
3
+ "version": "4.15.0",
4
4
  "description": "React component used to render charts based on any sources you need",
5
5
  "license": "MIT",
6
6
  "repository": "git@github.com:gravity-ui/ChartKit.git",
@@ -48,7 +48,7 @@
48
48
  "dependencies": {
49
49
  "@bem-react/classname": "^1.6.0",
50
50
  "@gravity-ui/date-utils": "^1.4.1",
51
- "@gravity-ui/yagr": "^4.0.3",
51
+ "@gravity-ui/yagr": "^4.1.0",
52
52
  "afterframe": "^1.0.2",
53
53
  "d3": "^7.8.5",
54
54
  "lodash": "^4.17.21",
@@ -120,6 +120,11 @@
120
120
  "lint:prettier": "prettier --check --loglevel=error '**/*.{js,jsx,ts,tsx,scss}'",
121
121
  "lint": "run-p lint:*",
122
122
  "typecheck": "tsc --noEmit",
123
+ "docs:deps": "cd ./documentation && npm ci",
124
+ "docs:start": "cd ./documentation && npm run start",
125
+ "docs:start:ru": "cd ./documentation && npm run start:ru",
126
+ "docs:build": "cd ./documentation && npm run build",
127
+ "docs:serve": "cd ./documentation && npm run serve",
123
128
  "prepublishOnly": "npm run build"
124
129
  },
125
130
  "husky": {