@gravity-ui/chartkit 5.19.1 → 5.20.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/helpers/config/config.js +2 -2
- package/build/plugins/highcharts/renderer/helpers/highcharts/highcharts.js +2 -2
- package/build/plugins/yagr/renderer/tooltip/renderTooltip.js +4 -20
- package/build/plugins/yagr/renderer/tooltip/tooltip.js +2 -2
- package/build/plugins/yagr/types.d.ts +2 -12
- package/package.json +2 -2
|
@@ -13,7 +13,7 @@ import { i18n } from '../../../../../i18n';
|
|
|
13
13
|
import { block } from '../../../../../utils/cn';
|
|
14
14
|
import { formatNumber } from '../../../../shared';
|
|
15
15
|
import { drawComments, drawOnlyRendererComments, getCommentsOnLine, hideComments, } from '../comments/drawing';
|
|
16
|
-
import formatTooltip, { SERIES_NAME_DATA_ATTRIBUTE, TOOLTIP_CONTAINER_CLASS_NAME, TOOLTIP_FOOTER_CLASS_NAME, TOOLTIP_HEADER_CLASS_NAME, TOOLTIP_LIST_CLASS_NAME, TOOLTIP_ROW_CLASS_NAME,
|
|
16
|
+
import formatTooltip, { SERIES_NAME_DATA_ATTRIBUTE, TOOLTIP_CONTAINER_CLASS_NAME, TOOLTIP_FOOTER_CLASS_NAME, TOOLTIP_HEADER_CLASS_NAME, TOOLTIP_LIST_CLASS_NAME, TOOLTIP_ROW_CLASS_NAME, TOOLTIP_ROW_NAME_CLASS_NAME, } from '../tooltip';
|
|
17
17
|
import { handleLegendItemClick } from './handleLegendItemClick';
|
|
18
18
|
import defaultOptions from './options';
|
|
19
19
|
import { addShowInNavigatorToSeries, buildNavigatorFallback, calculatePrecision, checkTooltipPinningAvailability, concatStrings, getFormatOptionsFromLine, getSortedData, isSafari, isTooltipShared, mergeArrayWithObject, numberFormat, setNavigatorDefaultPeriod, } from './utils';
|
|
@@ -121,7 +121,7 @@ export function synchronizeTooltipTablesCellsWidth(tooltipContainer, isMobile) {
|
|
|
121
121
|
cell.setAttribute('style', `width: ${nodeWithWidesRowsCellsWidth[j]}px`);
|
|
122
122
|
}
|
|
123
123
|
if (isMobile && tooltipOverflowsViewport) {
|
|
124
|
-
const rowNamesNodes = tooltipContainer.querySelectorAll(`.${
|
|
124
|
+
const rowNamesNodes = tooltipContainer.querySelectorAll(`.${TOOLTIP_ROW_NAME_CLASS_NAME}`);
|
|
125
125
|
for (let i = 0; i < rowNamesNodes.length; i++) {
|
|
126
126
|
const node = rowNamesNodes[i];
|
|
127
127
|
node.setAttribute('style', `max-width: ${nodeWithWidesRowsCellsWidth[1]}px`);
|
|
@@ -3,7 +3,7 @@ import Highcharts from 'highcharts';
|
|
|
3
3
|
import get from 'lodash/get';
|
|
4
4
|
import { i18n } from '../../../../../i18n';
|
|
5
5
|
import { getTooltipPositioner, handleScroll, hideFixedTooltip, synchronizeTooltipTablesCellsWidth, } from '../config/config';
|
|
6
|
-
import { TOOLTIP_CONTAINER_CLASS_NAME, TOOLTIP_FOOTER_CLASS_NAME, TOOLTIP_LIST_CLASS_NAME, TOOLTIP_ROW_CLASS_NAME,
|
|
6
|
+
import { TOOLTIP_CONTAINER_CLASS_NAME, TOOLTIP_FOOTER_CLASS_NAME, TOOLTIP_LIST_CLASS_NAME, TOOLTIP_ROW_CLASS_NAME, TOOLTIP_ROW_NAME_CLASS_NAME, } from '../tooltip';
|
|
7
7
|
import colors from './colors';
|
|
8
8
|
import { calculateClosestPointManually } from './utils';
|
|
9
9
|
function formatQ(timestamp) {
|
|
@@ -276,7 +276,7 @@ function initHighcharts({ isMobile }) {
|
|
|
276
276
|
synchronizeTooltipTablesCellsWidth(this.container, isMobile);
|
|
277
277
|
}
|
|
278
278
|
if (isFixation) {
|
|
279
|
-
const rowNames = this.container.querySelectorAll(`.${
|
|
279
|
+
const rowNames = this.container.querySelectorAll(`.${TOOLTIP_ROW_NAME_CLASS_NAME}`);
|
|
280
280
|
for (let i = 0; i < rowNames.length; i++) {
|
|
281
281
|
const rowNameNode = rowNames[i];
|
|
282
282
|
if (rowNameNode.scrollWidth > rowNameNode.clientWidth) {
|
|
@@ -7,25 +7,9 @@ const calcOption = (d) => {
|
|
|
7
7
|
})
|
|
8
8
|
: d;
|
|
9
9
|
};
|
|
10
|
-
const getSeriesColorProperty = (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const userSeries = userData.graphs[rowIndex];
|
|
14
|
-
const lineColor = (_a = data.yagr.getSeriesById(row.id)) === null || _a === void 0 ? void 0 : _a.lineColor;
|
|
15
|
-
let seriesColor = row.color;
|
|
16
|
-
switch (userSeries === null || userSeries === void 0 ? void 0 : userSeries.legendColorKey) {
|
|
17
|
-
case 'lineColor': {
|
|
18
|
-
if (lineColor) {
|
|
19
|
-
seriesColor = lineColor;
|
|
20
|
-
}
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
case 'color':
|
|
24
|
-
default: {
|
|
25
|
-
seriesColor = row.color;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return seriesColor;
|
|
10
|
+
const getSeriesColorProperty = ({ data, rowId }) => {
|
|
11
|
+
const series = data.yagr.getSeriesById(rowId);
|
|
12
|
+
return data.yagr.getSerieLegendColor(series);
|
|
29
13
|
};
|
|
30
14
|
/*
|
|
31
15
|
* Default tooltip renderer.
|
|
@@ -62,7 +46,7 @@ export const getRenderTooltip = (userData) => (data) => {
|
|
|
62
46
|
activeRowAlwaysFirstInTooltip: rows.length > 1,
|
|
63
47
|
tooltipHeader: dateTime({ input: x / timeMultiplier, timeZone }).format('DD MMMM YYYY HH:mm:ss'),
|
|
64
48
|
shared: true,
|
|
65
|
-
lines: rows.map((row, i) => (Object.assign(Object.assign({}, row), { seriesName: row.name || 'Serie ' + (i + 1), seriesColor: getSeriesColorProperty({ data,
|
|
49
|
+
lines: rows.map((row, i) => (Object.assign(Object.assign({}, row), { seriesName: row.name || 'Serie ' + (i + 1), seriesColor: getSeriesColorProperty({ data, rowId: row.id }), selectedSeries: row.active, seriesIdx: row.seriesIdx, percentValue: typeof row.transformed === 'number' ? row.transformed.toFixed(1) : '' }))),
|
|
66
50
|
withPercent: calcOption(opts.percent),
|
|
67
51
|
hiddenRowsNumber: hiddenRowsNumber,
|
|
68
52
|
hiddenRowsSum,
|
|
@@ -5,7 +5,7 @@ import './tooltip.css';
|
|
|
5
5
|
const SERIES_NAME_DATA_ATTRIBUTE = 'data-series-name';
|
|
6
6
|
const SERIES_IDX_DATA_ATTRIBUTE = 'data-series-idx';
|
|
7
7
|
const TOOLTIP_CONTAINER_CLASS_NAME = '_tooltip';
|
|
8
|
-
const
|
|
8
|
+
const TOOLTIP_ROW_NAME_CLASS_NAME = '_tooltip-rows__name-td';
|
|
9
9
|
const TOOLTIP_ROW_CLASS_NAME = '_tooltip-row';
|
|
10
10
|
const TOOLTIP_HEADER_CLASS_NAME = '_tooltip-header';
|
|
11
11
|
const TOOLTIP_LIST_CLASS_NAME = '_tooltip-list';
|
|
@@ -14,7 +14,7 @@ const renderEmptyCell = () => '<td />';
|
|
|
14
14
|
const renderColorCell = (line) => `<td class="_tooltip-rows__bubble-td">
|
|
15
15
|
<div class="_tooltip-rows__bubble-div" style="background-color:${line.seriesColor};"></div>
|
|
16
16
|
</td>`;
|
|
17
|
-
const renderNameCell = (line) => `<td class="${
|
|
17
|
+
const renderNameCell = (line) => `<td class="${TOOLTIP_ROW_NAME_CLASS_NAME}">
|
|
18
18
|
${line.hideSeriesName ? '' : escapeHTML(line.seriesName)}
|
|
19
19
|
</td>`;
|
|
20
20
|
const renderPercentCell = (line) => `<td class="_tooltip-rows__percent-td">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MinimalValidConfig, RawSerieData,
|
|
1
|
+
import type { MinimalValidConfig, RawSerieData, YagrConfig } from '@gravity-ui/yagr';
|
|
2
2
|
import type Yagr from '@gravity-ui/yagr';
|
|
3
3
|
import { ChartKitProps } from 'src/types';
|
|
4
4
|
export type { default as Yagr } from '@gravity-ui/yagr';
|
|
@@ -10,19 +10,9 @@ export interface CustomTooltipProps {
|
|
|
10
10
|
export type YagrWidgetProps = ChartKitProps<'yagr'> & {
|
|
11
11
|
id: string;
|
|
12
12
|
};
|
|
13
|
-
export type YagrSeriesData<T = Omit<SeriesOptions, 'type'>> = RawSerieData<T> & {
|
|
14
|
-
/**
|
|
15
|
-
* Determines what data value should be used to get a color for tooltip series. Does not work in case of using custom tooltip rendered via `tooltip` property.
|
|
16
|
-
* - `lineColor` indicates that lineColor property should be used
|
|
17
|
-
* - `color` indicates that color property should be used
|
|
18
|
-
*
|
|
19
|
-
* @default 'color'
|
|
20
|
-
*/
|
|
21
|
-
legendColorKey?: 'color' | 'lineColor';
|
|
22
|
-
};
|
|
23
13
|
export type YagrWidgetData = {
|
|
24
14
|
data: {
|
|
25
|
-
graphs:
|
|
15
|
+
graphs: RawSerieData[];
|
|
26
16
|
timeline: number[];
|
|
27
17
|
/**
|
|
28
18
|
* Allow to setup timezone for X axis and tooltip's header.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/chartkit",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.20.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",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@gravity-ui/charts": "^0.5.0",
|
|
51
51
|
"@gravity-ui/date-utils": "^2.1.0",
|
|
52
52
|
"@gravity-ui/i18n": "^1.0.0",
|
|
53
|
-
"@gravity-ui/yagr": "^4.
|
|
53
|
+
"@gravity-ui/yagr": "^4.5.0",
|
|
54
54
|
"afterframe": "^1.0.2",
|
|
55
55
|
"lodash": "^4.17.21",
|
|
56
56
|
"tslib": "^2.6.2"
|