@gravity-ui/chartkit 2.1.0 → 2.2.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 +12 -0
- package/build/plugins/highcharts/mocks/line.js +6 -0
- package/build/plugins/highcharts/renderer/components/HighchartsComponent.d.ts +3 -0
- package/build/plugins/highcharts/renderer/helpers/config/config.d.ts +3 -0
- package/build/plugins/highcharts/renderer/helpers/config/config.js +15 -1
- package/build/plugins/highcharts/renderer/helpers/graph.d.ts +3 -0
- package/build/plugins/highcharts/renderer/helpers/highcharts/highcharts.js +9 -5
- package/build/plugins/highcharts/renderer/helpers/tooltip/index.js +2 -1
- package/build/plugins/highcharts/types/widget.d.ts +25 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.2.0](https://github.com/gravity-ui/chartkit/compare/v2.1.0...v2.2.0) (2023-03-21)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **Higcharts plugin:** add type for manageTooltipConfig ([#139](https://github.com/gravity-ui/chartkit/issues/139)) ([f781cca](https://github.com/gravity-ui/chartkit/commit/f781cca112bb1e87607d24916aa38bf44fe2abf6))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **Highcharts:** fix resetZoomButton styles ([#137](https://github.com/gravity-ui/chartkit/issues/137)) ([07f610e](https://github.com/gravity-ui/chartkit/commit/07f610e443f2c9a2543ac68bbff443112a1d650a))
|
|
14
|
+
|
|
3
15
|
## [2.1.0](https://github.com/gravity-ui/chartkit/compare/v2.0.0...v2.1.0) (2023-03-13)
|
|
4
16
|
|
|
5
17
|
|
|
@@ -89,6 +89,12 @@ export const data = {
|
|
|
89
89
|
hideHolidays: false,
|
|
90
90
|
normalizeDiv: false,
|
|
91
91
|
normalizeSub: false,
|
|
92
|
+
manageTooltipConfig: (config) => {
|
|
93
|
+
config.lines.forEach((line, index) => {
|
|
94
|
+
line.commentText = `Some comment ${index + 1}`;
|
|
95
|
+
});
|
|
96
|
+
return config;
|
|
97
|
+
},
|
|
92
98
|
},
|
|
93
99
|
libraryConfig: {
|
|
94
100
|
chart: {
|
|
@@ -924,7 +924,7 @@ function fixTooltip(tooltip, options, event) {
|
|
|
924
924
|
top = tooltipRect.top;
|
|
925
925
|
tooltip.preFixationHeight = height;
|
|
926
926
|
}
|
|
927
|
-
tooltip.lastVisibleRowIndex =
|
|
927
|
+
tooltip.lastVisibleRowIndex = undefined;
|
|
928
928
|
tooltip.update({
|
|
929
929
|
style: Object.assign(Object.assign({}, tooltip.style), { pointerEvents: 'auto' }),
|
|
930
930
|
});
|
|
@@ -1324,6 +1324,20 @@ export function prepareConfig(data, options, isMobile, holidays) {
|
|
|
1324
1324
|
return Highcharts.Axis.prototype.defaultLabelFormatter.call(this);
|
|
1325
1325
|
},
|
|
1326
1326
|
},
|
|
1327
|
+
events: {
|
|
1328
|
+
setExtremes: function () {
|
|
1329
|
+
// There is no better way to align zoom button text
|
|
1330
|
+
// Callback setExtremes used because of it obligatory invocation on every zoom event
|
|
1331
|
+
// setTimeout used because of absence resetZoomButton node in dom on first zoom event
|
|
1332
|
+
setTimeout(() => {
|
|
1333
|
+
var _a;
|
|
1334
|
+
const text = (_a = this.chart.resetZoomButton) === null || _a === void 0 ? void 0 : _a.text;
|
|
1335
|
+
if (text) {
|
|
1336
|
+
text.translate(0, -6);
|
|
1337
|
+
}
|
|
1338
|
+
}, 0);
|
|
1339
|
+
},
|
|
1340
|
+
},
|
|
1327
1341
|
}, yAxis: {
|
|
1328
1342
|
crosshair: options.splitTooltip
|
|
1329
1343
|
? getCrosshairConfig(hasScatterSeries ? 'scatter' : chartType, true)
|
|
@@ -31,11 +31,15 @@ Highcharts.setOptions({
|
|
|
31
31
|
resetZoomButton: {
|
|
32
32
|
relativeTo: 'chart',
|
|
33
33
|
theme: {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
r: 6,
|
|
35
|
+
width: 12,
|
|
36
|
+
height: 12,
|
|
36
37
|
'text-align': 'center',
|
|
37
38
|
opacity: '0.8',
|
|
38
39
|
cursor: 'pointer',
|
|
40
|
+
style: {
|
|
41
|
+
fontSize: '20px',
|
|
42
|
+
},
|
|
39
43
|
},
|
|
40
44
|
position: {
|
|
41
45
|
y: 30,
|
|
@@ -223,7 +227,7 @@ function initHighcharts({ isMobile }) {
|
|
|
223
227
|
});
|
|
224
228
|
Highcharts.wrap(Highcharts.Tooltip.prototype, 'hide', function (proceed, ...rest) {
|
|
225
229
|
if (this.lastVisibleRowIndex) {
|
|
226
|
-
this.lastVisibleRowIndex =
|
|
230
|
+
this.lastVisibleRowIndex = undefined;
|
|
227
231
|
}
|
|
228
232
|
if (this.scrollHandler && !this.fixed) {
|
|
229
233
|
window.removeEventListener('scroll', this.scrollHandler);
|
|
@@ -257,7 +261,7 @@ function initHighcharts({ isMobile }) {
|
|
|
257
261
|
const isFixation = rest[1];
|
|
258
262
|
if ((!this.fixed || isFixation) && points) {
|
|
259
263
|
if (isFixation) {
|
|
260
|
-
this.lastVisibleRowIndex =
|
|
264
|
+
this.lastVisibleRowIndex = undefined;
|
|
261
265
|
}
|
|
262
266
|
proceed.apply(this, [points, ...rest]);
|
|
263
267
|
if (chartType === 'timeline') {
|
|
@@ -292,7 +296,7 @@ function initHighcharts({ isMobile }) {
|
|
|
292
296
|
const bottomPadding = parseFloat(window.getComputedStyle(tooltipNode, null).getPropertyValue('padding-bottom'), 10);
|
|
293
297
|
const containerBottomEdge = top + height;
|
|
294
298
|
const rows = tooltipNode.querySelectorAll(`.${TOOLTIP_LIST_CLASS_NAME} .${TOOLTIP_ROW_CLASS_NAME}`);
|
|
295
|
-
let lastVisibleRowIndex
|
|
299
|
+
let lastVisibleRowIndex;
|
|
296
300
|
const selectedSeriesIndex = this.chart.hoverPoints.indexOf(this.chart.hoverPoint);
|
|
297
301
|
const rowForSelectedSeriesHeight = selectedSeriesIndex >= 0
|
|
298
302
|
? rows[selectedSeriesIndex].getBoundingClientRect().height
|
|
@@ -160,7 +160,8 @@ export const formatTooltip = (data, tooltip, isMobile) => {
|
|
|
160
160
|
cellsRenderers,
|
|
161
161
|
useCompareFrom: data.useCompareFrom,
|
|
162
162
|
isSelectedLine: true,
|
|
163
|
-
allowComment:
|
|
163
|
+
allowComment: typeof tooltip.lastVisibleRowIndex === 'number' &&
|
|
164
|
+
selectedLineIndex > tooltip.lastVisibleRowIndex,
|
|
164
165
|
};
|
|
165
166
|
// @ts-ignore
|
|
166
167
|
const windowHeight = document.body.clientHeight / ((window.visualViewport && window.visualViewport.scale) || 1);
|
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
import type { Highcharts } from './lib';
|
|
2
2
|
import type { HighchartsComment } from './comments';
|
|
3
3
|
import type { DrillDownConfig, StringParams } from './misc';
|
|
4
|
+
import type { TooltipData, TooltipLine } from '../renderer/helpers/tooltip/types';
|
|
4
5
|
export declare type CkHighchartsSeriesOptionsType = Highcharts.SeriesOptionsType & {
|
|
5
6
|
title?: string;
|
|
6
7
|
sname?: string;
|
|
7
8
|
fname?: string;
|
|
8
9
|
};
|
|
10
|
+
export declare type HighchartsManageTooltipConfigOptions = {
|
|
11
|
+
count: number;
|
|
12
|
+
lines: TooltipLine[];
|
|
13
|
+
shared: boolean;
|
|
14
|
+
this: {
|
|
15
|
+
x: string;
|
|
16
|
+
y: number;
|
|
17
|
+
points: Highcharts.Point[];
|
|
18
|
+
};
|
|
19
|
+
activeRowAlwaysFirstInTooltip?: boolean;
|
|
20
|
+
hiddenRowsNumber?: number;
|
|
21
|
+
hiddenRowsSum?: string;
|
|
22
|
+
splitTooltip?: boolean;
|
|
23
|
+
tooltipHeader?: string;
|
|
24
|
+
unsafe?: boolean;
|
|
25
|
+
useCompareFrom?: boolean;
|
|
26
|
+
withPercent?: boolean;
|
|
27
|
+
xComments?: TooltipData['xComments'];
|
|
28
|
+
};
|
|
29
|
+
export declare type HighchartsManageTooltipConfig = (options: HighchartsManageTooltipConfigOptions, chart: Highcharts.Chart) => HighchartsManageTooltipConfigOptions;
|
|
9
30
|
export declare type HighchartsWidgetData = {
|
|
10
31
|
data: (CkHighchartsSeriesOptionsType[] | {
|
|
11
32
|
graphs: CkHighchartsSeriesOptionsType[];
|
|
@@ -58,6 +79,10 @@ export declare type HighchartsWidgetData = {
|
|
|
58
79
|
drillDown?: DrillDownConfig;
|
|
59
80
|
enableSum?: boolean;
|
|
60
81
|
unsafe?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Used to modify tooltip data
|
|
84
|
+
*/
|
|
85
|
+
manageTooltipConfig?: HighchartsManageTooltipConfig;
|
|
61
86
|
};
|
|
62
87
|
libraryConfig: Highcharts.Options;
|
|
63
88
|
params?: StringParams;
|
package/package.json
CHANGED