@gravity-ui/chartkit 2.2.0 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/build/plugins/highcharts/renderer/components/HighchartsComponent.d.ts +2 -2
- package/build/plugins/highcharts/renderer/helpers/config/config.d.ts +2 -2
- package/build/plugins/highcharts/renderer/helpers/config/handleLegendItemClick.d.ts +1 -1
- package/build/plugins/highcharts/renderer/helpers/config/handleLegendItemClick.js +16 -6
- package/build/plugins/highcharts/renderer/helpers/config/utils/isNavigatorSeries.d.ts +1 -1
- package/build/plugins/highcharts/renderer/helpers/graph.d.ts +2 -2
- package/build/plugins/highcharts/renderer/helpers/prepare-data.js +5 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.2.2](https://github.com/gravity-ui/chartkit/compare/v2.2.1...v2.2.2) (2023-03-28)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **Highcharts plugin:** fix legend item click ([#142](https://github.com/gravity-ui/chartkit/issues/142)) ([a64f1b9](https://github.com/gravity-ui/chartkit/commit/a64f1b962bec45bfd2568110c1c9050fc9d75807))
|
|
9
|
+
|
|
10
|
+
## [2.2.1](https://github.com/gravity-ui/chartkit/compare/v2.2.0...v2.2.1) (2023-03-27)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **Highcharts plugin:** proper message for empty data ([#140](https://github.com/gravity-ui/chartkit/issues/140)) ([ee41ace](https://github.com/gravity-ui/chartkit/commit/ee41ace81ddaa88601b584273a7759dfe1dbe1c9))
|
|
16
|
+
|
|
3
17
|
## [2.2.0](https://github.com/gravity-ui/chartkit/compare/v2.1.0...v2.2.0) (2023-03-21)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -360,7 +360,7 @@ export declare class HighchartsComponent extends React.PureComponent<Props, Stat
|
|
|
360
360
|
};
|
|
361
361
|
series: {
|
|
362
362
|
events: {
|
|
363
|
-
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject) => void;
|
|
363
|
+
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void;
|
|
364
364
|
mouseOver: () => void;
|
|
365
365
|
mouseOut: () => void;
|
|
366
366
|
click: (event: any) => void;
|
|
@@ -386,7 +386,7 @@ export declare class HighchartsComponent extends React.PureComponent<Props, Stat
|
|
|
386
386
|
pie: {
|
|
387
387
|
point: {
|
|
388
388
|
events: {
|
|
389
|
-
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject) => void;
|
|
389
|
+
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void;
|
|
390
390
|
};
|
|
391
391
|
};
|
|
392
392
|
};
|
|
@@ -518,7 +518,7 @@ export function prepareConfig(data: any, options: any, isMobile: any, holidays:
|
|
|
518
518
|
};
|
|
519
519
|
series: {
|
|
520
520
|
events: {
|
|
521
|
-
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject) => void;
|
|
521
|
+
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void;
|
|
522
522
|
mouseOver: () => void;
|
|
523
523
|
mouseOut: () => void;
|
|
524
524
|
click: (event: any) => void;
|
|
@@ -544,7 +544,7 @@ export function prepareConfig(data: any, options: any, isMobile: any, holidays:
|
|
|
544
544
|
pie: {
|
|
545
545
|
point: {
|
|
546
546
|
events: {
|
|
547
|
-
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject) => void;
|
|
547
|
+
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void;
|
|
548
548
|
};
|
|
549
549
|
};
|
|
550
550
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import Highcharts from 'highcharts';
|
|
2
|
-
export declare const handleLegendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject) => void;
|
|
2
|
+
export declare const handleLegendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { drawComments, hideComments } from '../comments/drawing';
|
|
2
2
|
import { isNavigatorSeries } from './utils';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import Highcharts from 'highcharts';
|
|
4
|
+
const getSeriesIdentifier = (item) => {
|
|
5
|
+
if (item instanceof Highcharts.Point) {
|
|
6
|
+
return item.name;
|
|
7
|
+
}
|
|
8
|
+
return item.userOptions.id || item.name;
|
|
5
9
|
};
|
|
6
10
|
const needSetVisible = (seriesName, seriesVisible, chartSeries) => {
|
|
7
11
|
if (!seriesVisible) {
|
|
8
12
|
return false;
|
|
9
13
|
}
|
|
14
|
+
// TypeScript have problems when filter/map/reduce with union type arrays.
|
|
15
|
+
// https://github.com/microsoft/TypeScript/issues/44373
|
|
10
16
|
const hasAnotherVisibleSeries = chartSeries
|
|
11
17
|
.filter((series) => series.options.showInLegend !== false && getSeriesIdentifier(series) !== seriesName)
|
|
12
18
|
.some((series) => series.visible);
|
|
@@ -18,6 +24,10 @@ const updateSeries = (series, chartSeries, type) => {
|
|
|
18
24
|
case 'extended': {
|
|
19
25
|
chartSeries.forEach((item) => {
|
|
20
26
|
if (getSeriesIdentifier(item) === clickedSeriesName) {
|
|
27
|
+
// Highcharts.Series has serVisible in types
|
|
28
|
+
// Highcharts.Point doesn't have this method in types
|
|
29
|
+
// but it has this method in __proto__ and it works
|
|
30
|
+
// @ts-ignore
|
|
21
31
|
item.setVisible(!item.visible, false);
|
|
22
32
|
}
|
|
23
33
|
});
|
|
@@ -27,9 +37,11 @@ const updateSeries = (series, chartSeries, type) => {
|
|
|
27
37
|
const visible = needSetVisible(getSeriesIdentifier(series), series.visible, chartSeries);
|
|
28
38
|
chartSeries.forEach((item) => {
|
|
29
39
|
if (getSeriesIdentifier(item) === clickedSeriesName) {
|
|
40
|
+
// @ts-ignore
|
|
30
41
|
item.setVisible(true, false);
|
|
31
42
|
}
|
|
32
43
|
else {
|
|
44
|
+
// @ts-ignore
|
|
33
45
|
item.setVisible(visible, false);
|
|
34
46
|
}
|
|
35
47
|
});
|
|
@@ -47,10 +59,8 @@ const updateComments = (chart) => {
|
|
|
47
59
|
export const handleLegendItemClick = (event) => {
|
|
48
60
|
event.preventDefault();
|
|
49
61
|
const series = event.target;
|
|
50
|
-
const chart = series.
|
|
51
|
-
const chartSeries = series.chart
|
|
52
|
-
? chart.series
|
|
53
|
-
: series.series.data;
|
|
62
|
+
const chart = series instanceof Highcharts.Point ? series.series.chart : series.chart;
|
|
63
|
+
const chartSeries = series instanceof Highcharts.Point ? series.series.data : series.chart.series;
|
|
54
64
|
if (isNavigatorSeries(series)) {
|
|
55
65
|
return;
|
|
56
66
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Highcharts } from '../../../../types';
|
|
2
|
-
export declare const isNavigatorSeries: (series?: Highcharts.Series | undefined) => boolean;
|
|
2
|
+
export declare const isNavigatorSeries: (series?: Highcharts.Point | Highcharts.Series | undefined) => boolean;
|
|
@@ -354,7 +354,7 @@ declare function getGraph({ options, data, comments, isMobile, holidays }: GetGr
|
|
|
354
354
|
};
|
|
355
355
|
series: {
|
|
356
356
|
events: {
|
|
357
|
-
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject) => void;
|
|
357
|
+
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void;
|
|
358
358
|
mouseOver: () => void;
|
|
359
359
|
mouseOut: () => void;
|
|
360
360
|
click: (event: any) => void;
|
|
@@ -380,7 +380,7 @@ declare function getGraph({ options, data, comments, isMobile, holidays }: GetGr
|
|
|
380
380
|
pie: {
|
|
381
381
|
point: {
|
|
382
382
|
events: {
|
|
383
|
-
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject) => void;
|
|
383
|
+
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void;
|
|
384
384
|
};
|
|
385
385
|
};
|
|
386
386
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import moment from 'moment';
|
|
2
2
|
import lodashMin from 'lodash/min';
|
|
3
|
+
import { i18n } from '../../../../i18n';
|
|
3
4
|
import { ChartKitError, CHARTKIT_ERROR_CODE } from '../../../../libs';
|
|
4
5
|
import { DEFAULT_LINES_LIMIT } from './constants';
|
|
5
6
|
function prepareValue(value, firstValue, options) {
|
|
@@ -90,7 +91,10 @@ export function prepareData(data, options, holidays) {
|
|
|
90
91
|
(data.graphs &&
|
|
91
92
|
!(data.graphs.length && data.graphs.some((graph) => graph.data && graph.data.length))) ||
|
|
92
93
|
(Array.isArray(data) && !data.length)) {
|
|
93
|
-
throw new ChartKitError({
|
|
94
|
+
throw new ChartKitError({
|
|
95
|
+
code: CHARTKIT_ERROR_CODE.NO_DATA,
|
|
96
|
+
message: i18n('error', 'label_no-data'),
|
|
97
|
+
});
|
|
94
98
|
}
|
|
95
99
|
if (data.graphs) {
|
|
96
100
|
if (data.graphs.length > limit && !options.withoutLineLimit) {
|
package/package.json
CHANGED