@gravity-ui/chartkit 2.0.0 → 2.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/CHANGELOG.md +7 -2
- package/build/components/ErrorView/ErrorView.js +2 -1
- package/build/plugins/highcharts/__stories__/Line.stories.js +1 -1
- package/build/plugins/highcharts/__stories__/Pie.stories.js +1 -1
- package/build/plugins/highcharts/__stories__/area/Range.stories.js +1 -1
- package/build/plugins/highcharts/__stories__/area/Stacked.stories.js +1 -1
- package/build/plugins/highcharts/__stories__/column/HorizontalStacked.stories.js +1 -1
- package/build/plugins/highcharts/__stories__/column/Vertical.stories.js +1 -1
- package/build/plugins/highcharts/__stories__/column/VerticalStacked.stories.js +1 -1
- package/build/plugins/highcharts/__stories__/combined/ComboChartWithSameLegendValues.stories.js +1 -1
- package/build/plugins/highcharts/__stories__/complex/TwoAxis.stories.js +1 -1
- package/build/plugins/highcharts/__stories__/components/ChartStory.js +1 -1
- package/build/plugins/highcharts/__tests__/prepare-data.test.d.ts +1 -0
- package/build/plugins/highcharts/__tests__/prepare-data.test.js +13 -0
- package/build/plugins/highcharts/mocks/area-range.d.ts +2 -0
- package/build/plugins/highcharts/mocks/area-stacked.d.ts +2 -0
- package/build/plugins/highcharts/mocks/column-hor-stacked.d.ts +2 -0
- package/build/plugins/highcharts/mocks/column-ver-stacked.d.ts +2 -0
- package/build/plugins/highcharts/mocks/column-ver.d.ts +2 -0
- package/build/plugins/highcharts/mocks/combo-chart-with-same-legend-titles.d.ts +2 -0
- package/build/plugins/highcharts/mocks/complex.d.ts +2 -0
- package/build/plugins/highcharts/mocks/line.d.ts +2 -0
- package/build/plugins/highcharts/{__stories__/mocks → mocks}/line.js +1 -2
- package/build/plugins/highcharts/mocks/pie.d.ts +2 -0
- package/build/plugins/highcharts/renderer/helpers/constants.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/constants.js +1 -0
- package/build/plugins/highcharts/renderer/helpers/prepare-data.js +3 -1
- package/build/plugins/highcharts/types/widget.d.ts +12 -0
- package/package.json +1 -1
- package/build/plugins/highcharts/__stories__/mocks/area-range.d.ts +0 -2
- package/build/plugins/highcharts/__stories__/mocks/area-stacked.d.ts +0 -2
- package/build/plugins/highcharts/__stories__/mocks/column-hor-stacked.d.ts +0 -2
- package/build/plugins/highcharts/__stories__/mocks/column-ver-stacked.d.ts +0 -2
- package/build/plugins/highcharts/__stories__/mocks/column-ver.d.ts +0 -2
- package/build/plugins/highcharts/__stories__/mocks/combo-chart-with-same-legend-titles.d.ts +0 -2
- package/build/plugins/highcharts/__stories__/mocks/complex.d.ts +0 -2
- package/build/plugins/highcharts/__stories__/mocks/line.d.ts +0 -2
- package/build/plugins/highcharts/__stories__/mocks/pie.d.ts +0 -2
- /package/build/plugins/highcharts/{__stories__/mocks → mocks}/area-range.js +0 -0
- /package/build/plugins/highcharts/{__stories__/mocks → mocks}/area-stacked.js +0 -0
- /package/build/plugins/highcharts/{__stories__/mocks → mocks}/column-hor-stacked.js +0 -0
- /package/build/plugins/highcharts/{__stories__/mocks → mocks}/column-ver-stacked.js +0 -0
- /package/build/plugins/highcharts/{__stories__/mocks → mocks}/column-ver.js +0 -0
- /package/build/plugins/highcharts/{__stories__/mocks → mocks}/combo-chart-with-same-legend-titles.js +0 -0
- /package/build/plugins/highcharts/{__stories__/mocks → mocks}/complex.js +0 -0
- /package/build/plugins/highcharts/{__stories__/mocks → mocks}/holidays.d.ts +0 -0
- /package/build/plugins/highcharts/{__stories__/mocks → mocks}/holidays.js +0 -0
- /package/build/plugins/highcharts/{__stories__/mocks → mocks}/pie.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.1.0](https://github.com/gravity-ui/chartkit/compare/v2.0.0...v2.1.0) (2023-03-13)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **Highcharts:** add linesLimit property to HighchartsWidgetData.config ([#135](https://github.com/gravity-ui/chartkit/issues/135)) ([91d16a3](https://github.com/gravity-ui/chartkit/commit/91d16a32aad00fb683c68f3f39a6477f14f18c33))
|
|
9
|
+
|
|
3
10
|
## [2.0.0](https://github.com/gravity-ui/chartkit/compare/v1.6.7...v2.0.0) (2023-03-09)
|
|
4
11
|
|
|
5
12
|
|
|
6
13
|
### ⚠ BREAKING CHANGES
|
|
7
14
|
|
|
8
|
-
* update uikit up to 4
|
|
9
15
|
* update uikit up to 4 ([#133](https://github.com/gravity-ui/chartkit/issues/133))
|
|
10
16
|
|
|
11
17
|
### Features
|
|
12
18
|
|
|
13
|
-
* update uikit up to 4 ([8ae0c8d](https://github.com/gravity-ui/chartkit/commit/8ae0c8d179273a448de8f670dfe1b3f2314c0523))
|
|
14
19
|
* update uikit up to 4 ([#133](https://github.com/gravity-ui/chartkit/issues/133)) ([8ae0c8d](https://github.com/gravity-ui/chartkit/commit/8ae0c8d179273a448de8f670dfe1b3f2314c0523))
|
|
15
20
|
|
|
16
21
|
## [1.6.7](https://github.com/gravity-ui/chartkit/compare/v1.6.6...v1.6.7) (2023-02-21)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { i18n } from '../../i18n';
|
|
3
3
|
export const ErrorView = ({ error }) => {
|
|
4
|
-
const
|
|
4
|
+
const code = 'code' in error && error.code;
|
|
5
|
+
const message = error.message || code || i18n('error', 'label_unknown-error');
|
|
5
6
|
return React.createElement("div", null, message);
|
|
6
7
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ChartKit } from '../../../components/ChartKit';
|
|
3
|
-
import { data } from '
|
|
3
|
+
import { data } from '../mocks/line';
|
|
4
4
|
import { ChartStory } from './components/ChartStory';
|
|
5
5
|
export default {
|
|
6
6
|
title: 'Plugins/Highcharts/Line',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ChartKit } from '../../../components/ChartKit';
|
|
3
|
-
import { data } from '
|
|
3
|
+
import { data } from '../mocks/pie';
|
|
4
4
|
import { ChartStory } from './components/ChartStory';
|
|
5
5
|
export default {
|
|
6
6
|
title: 'Plugins/Highcharts/Pie',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
3
|
-
import { data } from '
|
|
3
|
+
import { data } from '../../mocks/area-range';
|
|
4
4
|
import { ChartStory } from '../components/ChartStory';
|
|
5
5
|
export default {
|
|
6
6
|
title: 'Plugins/Highcharts/Area',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
3
|
-
import { data } from '
|
|
3
|
+
import { data } from '../../mocks/area-stacked';
|
|
4
4
|
import { ChartStory } from '../components/ChartStory';
|
|
5
5
|
export default {
|
|
6
6
|
title: 'Plugins/Highcharts/Area',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
3
|
-
import { data } from '
|
|
3
|
+
import { data } from '../../mocks/column-hor-stacked';
|
|
4
4
|
import { ChartStory } from '../components/ChartStory';
|
|
5
5
|
export default {
|
|
6
6
|
title: 'Plugins/Highcharts/Column',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
3
|
-
import { data } from '
|
|
3
|
+
import { data } from '../../mocks/column-ver';
|
|
4
4
|
import { ChartStory } from '../components/ChartStory';
|
|
5
5
|
export default {
|
|
6
6
|
title: 'Plugins/Highcharts/Column',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
3
|
-
import { data } from '
|
|
3
|
+
import { data } from '../../mocks/column-ver-stacked';
|
|
4
4
|
import { ChartStory } from '../components/ChartStory';
|
|
5
5
|
export default {
|
|
6
6
|
title: 'Plugins/Highcharts/Column',
|
package/build/plugins/highcharts/__stories__/combined/ComboChartWithSameLegendValues.stories.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
3
|
-
import { data } from '
|
|
3
|
+
import { data } from '../../mocks/combo-chart-with-same-legend-titles';
|
|
4
4
|
import { ChartStory } from '../components/ChartStory';
|
|
5
5
|
export default {
|
|
6
6
|
title: 'Plugins/Highcharts/Combined Charts',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
3
3
|
import { ChartStory } from '../components/ChartStory';
|
|
4
|
-
import { data } from '
|
|
4
|
+
import { data } from '../../mocks/complex';
|
|
5
5
|
export default {
|
|
6
6
|
title: 'Plugins/Highcharts/TwoAxis',
|
|
7
7
|
component: ChartKit,
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Button } from '@gravity-ui/uikit';
|
|
3
3
|
import { settings } from '../../../../libs';
|
|
4
4
|
import { HighchartsPlugin } from '../../index';
|
|
5
|
-
import holidays from '
|
|
5
|
+
import holidays from '../../mocks/holidays';
|
|
6
6
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
7
7
|
const DEFAULT_STORY_HEIGHT = '300px';
|
|
8
8
|
const DEFAULT_STORY_WIDTH = '100%';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { prepareData } from '../renderer/helpers/prepare-data';
|
|
2
|
+
import { data } from '../mocks/line';
|
|
3
|
+
describe('plugins/highcharts/helpers', () => {
|
|
4
|
+
describe('prepareData', () => {
|
|
5
|
+
it('should not throw an error', () => {
|
|
6
|
+
expect(() => prepareData(data.data, data.config)).not.toThrowError();
|
|
7
|
+
});
|
|
8
|
+
it('should throw an error', () => {
|
|
9
|
+
const configWithLinesLimit = Object.assign(Object.assign({}, data.config), { linesLimit: 1 });
|
|
10
|
+
expect(() => prepareData(data.data, configWithLinesLimit)).toThrowError();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -83,10 +83,9 @@ export const data = {
|
|
|
83
83
|
categories: ['Furniture', 'Office Supplies', 'Technology'],
|
|
84
84
|
},
|
|
85
85
|
config: {
|
|
86
|
-
|
|
86
|
+
precision: 2,
|
|
87
87
|
hideHolidaysBands: true,
|
|
88
88
|
enableSum: true,
|
|
89
|
-
precision: 2,
|
|
90
89
|
hideHolidays: false,
|
|
91
90
|
normalizeDiv: false,
|
|
92
91
|
normalizeSub: false,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import moment from 'moment';
|
|
2
2
|
import lodashMin from 'lodash/min';
|
|
3
3
|
import { ChartKitError, CHARTKIT_ERROR_CODE } from '../../../../libs';
|
|
4
|
+
import { DEFAULT_LINES_LIMIT } from './constants';
|
|
4
5
|
function prepareValue(value, firstValue, options) {
|
|
5
6
|
if (value === null) {
|
|
6
7
|
return null;
|
|
@@ -83,6 +84,7 @@ function removeHolidays(data, options, holidays) {
|
|
|
83
84
|
}
|
|
84
85
|
// eslint-disable-next-line complexity
|
|
85
86
|
export function prepareData(data, options, holidays) {
|
|
87
|
+
const limit = options.linesLimit || DEFAULT_LINES_LIMIT;
|
|
86
88
|
if (!data ||
|
|
87
89
|
(typeof data === 'object' && !Object.keys(data).length) ||
|
|
88
90
|
(data.graphs &&
|
|
@@ -91,7 +93,7 @@ export function prepareData(data, options, holidays) {
|
|
|
91
93
|
throw new ChartKitError({ code: CHARTKIT_ERROR_CODE.NO_DATA });
|
|
92
94
|
}
|
|
93
95
|
if (data.graphs) {
|
|
94
|
-
if (data.graphs.length >
|
|
96
|
+
if (data.graphs.length > limit && !options.withoutLineLimit) {
|
|
95
97
|
throw new ChartKitError({ code: CHARTKIT_ERROR_CODE.TOO_MANY_LINES });
|
|
96
98
|
}
|
|
97
99
|
data.graphs.forEach((graph) => {
|
|
@@ -27,14 +27,26 @@ export declare type HighchartsWidgetData = {
|
|
|
27
27
|
showLegend?: boolean;
|
|
28
28
|
/**
|
|
29
29
|
* Percentage value displayed in tooltip.
|
|
30
|
+
*
|
|
30
31
|
* Relevant in case of initialized [stacking](https://api.highcharts.com/highcharts/plotOptions.column.stacking) property only.
|
|
31
32
|
*/
|
|
32
33
|
showPercentInTooltip?: boolean;
|
|
33
34
|
disableExternalComments?: boolean;
|
|
34
35
|
normalizeDiv?: boolean;
|
|
35
36
|
normalizeSub?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Used to ignore `linesLimit` option
|
|
39
|
+
*/
|
|
36
40
|
withoutLineLimit?: boolean;
|
|
37
41
|
precision?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Lines (series) count limit.
|
|
44
|
+
*
|
|
45
|
+
* If you have lines more than `limit`, your chart will throw an error 'ERR.CK.TOO_MANY_LINES'.
|
|
46
|
+
*
|
|
47
|
+
* Ingnored in case of `withoutLineLimit: true`. Default: 50.
|
|
48
|
+
*/
|
|
49
|
+
linesLimit?: number;
|
|
38
50
|
title?: string;
|
|
39
51
|
subtitle?: string;
|
|
40
52
|
highstock?: {
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/build/plugins/highcharts/{__stories__/mocks → mocks}/combo-chart-with-same-legend-titles.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|