@gravity-ui/chartkit 4.18.1 → 4.19.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/plugins/highcharts/renderer/components/withSplitPane/withSplitPane.js +2 -1
- package/build/plugins/indicator/renderer/IndicatorWidget.js +1 -1
- package/build/plugins/yagr/renderer/tooltip/index.d.ts +1 -1
- package/build/plugins/yagr/renderer/tooltip/index.js +1 -1
- package/build/plugins/yagr/renderer/tooltip/renderTooltip.d.ts +1 -1
- package/build/plugins/yagr/renderer/tooltip/renderTooltip.js +2 -2
- package/build/plugins/yagr/renderer/utils.js +7 -6
- package/build/plugins/yagr/types.d.ts +8 -0
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint callback-return: 0 */
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import
|
|
3
|
+
import debounce from 'lodash/debounce';
|
|
4
|
+
import get from 'lodash/get';
|
|
4
5
|
import { getRandomCKId } from '../../../../../utils';
|
|
5
6
|
import { cn } from '../../../../../utils/cn';
|
|
6
7
|
import { chartTypesWithoutCrosshair } from '../../helpers/config/config';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import isEmpty from 'lodash/isEmpty';
|
|
3
3
|
import { i18n } from '../../../i18n';
|
|
4
4
|
import { CHARTKIT_ERROR_CODE, ChartKitError } from '../../../libs';
|
|
5
5
|
import { CHARTKIT_SCROLLABLE_NODE_CLASSNAME } from '../../../constants';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getRenderTooltip } from './renderTooltip';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getRenderTooltip } from './renderTooltip';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { TooltipRenderOptions } from '../../types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const getRenderTooltip: (timeZone?: string) => (data: TooltipRenderOptions) => string;
|
|
@@ -12,7 +12,7 @@ const calcOption = (d) => {
|
|
|
12
12
|
* Adapter between native Yagr tooltip config and ChartKit
|
|
13
13
|
* tooltip renderer.
|
|
14
14
|
*/
|
|
15
|
-
export const
|
|
15
|
+
export const getRenderTooltip = (timeZone) => (data) => {
|
|
16
16
|
const cfg = data.yagr.config;
|
|
17
17
|
const timeMultiplier = cfg.chart.timeMultiplier || 1;
|
|
18
18
|
const opts = data.options;
|
|
@@ -39,7 +39,7 @@ export const renderTooltip = (data) => {
|
|
|
39
39
|
: undefined;
|
|
40
40
|
const tooltipFormatOptions = {
|
|
41
41
|
activeRowAlwaysFirstInTooltip: rows.length > 1,
|
|
42
|
-
tooltipHeader: dateTime({ input: x / timeMultiplier }).format('DD MMMM YYYY HH:mm:ss'),
|
|
42
|
+
tooltipHeader: dateTime({ input: x / timeMultiplier, timeZone }).format('DD MMMM YYYY HH:mm:ss'),
|
|
43
43
|
shared: true,
|
|
44
44
|
lines: rows.map((row, i) => (Object.assign(Object.assign({}, row), { seriesName: row.name || 'Serie ' + (i + 1), seriesColor: row.color, selectedSeries: row.active, seriesIdx: row.seriesIdx, percentValue: typeof row.transformed === 'number' ? row.transformed.toFixed(1) : '' }))),
|
|
45
45
|
withPercent: calcOption(opts.percent),
|
|
@@ -2,7 +2,7 @@ import merge from 'lodash/merge';
|
|
|
2
2
|
import { dateTime } from '@gravity-ui/date-utils';
|
|
3
3
|
import { defaults } from '@gravity-ui/yagr';
|
|
4
4
|
import { settings } from '../../../libs';
|
|
5
|
-
import {
|
|
5
|
+
import { getRenderTooltip } from './tooltip';
|
|
6
6
|
const TOOLTIP_HEADER_CLASS_NAME = '_tooltip-header';
|
|
7
7
|
const TOOLTIP_LIST_CLASS_NAME = '_tooltip-list';
|
|
8
8
|
export const synchronizeTooltipTablesCellsWidth = (tooltipContainer) => {
|
|
@@ -72,10 +72,10 @@ export const detectClickOutside = (args) => (event) => {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
|
-
const getXAxisFormatter = (msm = 1) => (_, ticks) => {
|
|
75
|
+
const getXAxisFormatter = (msm = 1, timeZone) => (_, ticks) => {
|
|
76
76
|
const range = (ticks[ticks.length - 1] - ticks[0]) / msm;
|
|
77
77
|
return ticks.map((rawValue) => {
|
|
78
|
-
const d = dateTime({ input: rawValue / msm });
|
|
78
|
+
const d = dateTime({ input: rawValue / msm, timeZone });
|
|
79
79
|
if (d.hour() === 0 && d.minute() === 0 && d.second() === 0) {
|
|
80
80
|
return d.format('DD.MM.YY');
|
|
81
81
|
}
|
|
@@ -86,6 +86,7 @@ export const shapeYagrConfig = (args) => {
|
|
|
86
86
|
var _a, _b;
|
|
87
87
|
const { data, libraryConfig, theme } = args;
|
|
88
88
|
const config = Object.assign(Object.assign({}, libraryConfig), { timeline: data.timeline, series: data.graphs });
|
|
89
|
+
const { timeZone } = data;
|
|
89
90
|
const chart = {
|
|
90
91
|
appearance: {
|
|
91
92
|
locale: settings.get('lang'),
|
|
@@ -96,7 +97,7 @@ export const shapeYagrConfig = (args) => {
|
|
|
96
97
|
config.chart = chart;
|
|
97
98
|
if ((_a = config.tooltip) === null || _a === void 0 ? void 0 : _a.show) {
|
|
98
99
|
config.tooltip = config.tooltip || {};
|
|
99
|
-
config.tooltip.render = ((_b = config.tooltip) === null || _b === void 0 ? void 0 : _b.render) ||
|
|
100
|
+
config.tooltip.render = ((_b = config.tooltip) === null || _b === void 0 ? void 0 : _b.render) || getRenderTooltip(timeZone);
|
|
100
101
|
if (!config.tooltip.className) {
|
|
101
102
|
// "className" property prevent default yagr styles adding
|
|
102
103
|
config.tooltip.className = 'chartkit-yagr-tooltip';
|
|
@@ -114,11 +115,11 @@ export const shapeYagrConfig = (args) => {
|
|
|
114
115
|
config.axes = config.axes || {};
|
|
115
116
|
const xAxis = config.axes[defaults.DEFAULT_X_SCALE];
|
|
116
117
|
if (xAxis && !xAxis.values) {
|
|
117
|
-
xAxis.values = getXAxisFormatter(config.chart.timeMultiplier);
|
|
118
|
+
xAxis.values = getXAxisFormatter(config.chart.timeMultiplier, timeZone);
|
|
118
119
|
}
|
|
119
120
|
if (!xAxis) {
|
|
120
121
|
config.axes[defaults.DEFAULT_X_SCALE] = {
|
|
121
|
-
values: getXAxisFormatter(config.chart.timeMultiplier),
|
|
122
|
+
values: getXAxisFormatter(config.chart.timeMultiplier, timeZone),
|
|
122
123
|
};
|
|
123
124
|
}
|
|
124
125
|
return config;
|
|
@@ -14,6 +14,14 @@ export type YagrWidgetData = {
|
|
|
14
14
|
data: {
|
|
15
15
|
graphs: RawSerieData[];
|
|
16
16
|
timeline: number[];
|
|
17
|
+
/**
|
|
18
|
+
* Allow to setup timezone for X axis and tooltip's header.
|
|
19
|
+
*
|
|
20
|
+
* Format example: "UTC", "Europe/Moscow".
|
|
21
|
+
*
|
|
22
|
+
* For more examples check [wiki](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List)
|
|
23
|
+
*/
|
|
24
|
+
timeZone?: string;
|
|
17
25
|
};
|
|
18
26
|
libraryConfig: Partial<YagrConfig>;
|
|
19
27
|
sources?: Record<number, {
|
package/package.json
CHANGED