@gravity-ui/chartkit 5.19.0 → 5.19.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/build/plugins/highcharts/renderer/helpers/config/config.js +2 -2
- package/build/plugins/highcharts/renderer/helpers/highcharts/highcharts.js +2 -2
- package/build/plugins/highcharts/renderer/helpers/tooltip/index.d.ts +1 -1
- package/build/plugins/highcharts/renderer/helpers/tooltip/index.js +15 -5
- package/build/plugins/highcharts/renderer/helpers/tooltip/types.d.ts +4 -1
- package/build/plugins/yagr/renderer/tooltip/tooltip.js +2 -2
- 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) {
|
|
@@ -4,7 +4,7 @@ import './tooltip.css';
|
|
|
4
4
|
export declare const SERIES_NAME_DATA_ATTRIBUTE = "data-series-name";
|
|
5
5
|
export declare const SERIES_IDX_DATA_ATTRIBUTE = "data-series-idx";
|
|
6
6
|
export declare const TOOLTIP_CONTAINER_CLASS_NAME = "_tooltip";
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const TOOLTIP_ROW_NAME_CLASS_NAME = "_tooltip-rows__name-td";
|
|
8
8
|
export declare const TOOLTIP_ROW_CLASS_NAME = "_tooltip-row";
|
|
9
9
|
export declare const TOOLTIP_HEADER_CLASS_NAME = "_tooltip-header";
|
|
10
10
|
export declare const TOOLTIP_LIST_CLASS_NAME = "_tooltip-list";
|
|
@@ -7,7 +7,7 @@ import './tooltip.css';
|
|
|
7
7
|
export const SERIES_NAME_DATA_ATTRIBUTE = 'data-series-name';
|
|
8
8
|
export const SERIES_IDX_DATA_ATTRIBUTE = 'data-series-idx';
|
|
9
9
|
export const TOOLTIP_CONTAINER_CLASS_NAME = '_tooltip';
|
|
10
|
-
export const
|
|
10
|
+
export const TOOLTIP_ROW_NAME_CLASS_NAME = '_tooltip-rows__name-td';
|
|
11
11
|
export const TOOLTIP_ROW_CLASS_NAME = '_tooltip-row';
|
|
12
12
|
export const TOOLTIP_HEADER_CLASS_NAME = '_tooltip-header';
|
|
13
13
|
export const TOOLTIP_LIST_CLASS_NAME = '_tooltip-list';
|
|
@@ -22,9 +22,18 @@ const renderLineShapeCell = (line) => `<td class="_tooltip-rows__shape-td">
|
|
|
22
22
|
${renderShapeIcon({ type: line.seriesShape })}
|
|
23
23
|
</div>
|
|
24
24
|
</td>`;
|
|
25
|
-
const renderNameCell = (line) =>
|
|
26
|
-
|
|
25
|
+
const renderNameCell = (line, options) => {
|
|
26
|
+
let value = '';
|
|
27
|
+
if (!line.hideSeriesName) {
|
|
28
|
+
value = line.seriesName;
|
|
29
|
+
if (!(options === null || options === void 0 ? void 0 : options.unsafe)) {
|
|
30
|
+
value = escapeHTML(value);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return `<td class="${TOOLTIP_ROW_NAME_CLASS_NAME}">
|
|
34
|
+
${value}
|
|
27
35
|
</td>`;
|
|
36
|
+
};
|
|
28
37
|
const renderPercentCell = (line) => `<td class="_tooltip-rows__percent-td">
|
|
29
38
|
${line.percentValue ? line.percentValue + '%' : ''}
|
|
30
39
|
</td>`;
|
|
@@ -61,7 +70,7 @@ const renderAdditionalSection = (data, splitTooltip = false, colspanNumber = 1)
|
|
|
61
70
|
: ''}
|
|
62
71
|
</td>`;
|
|
63
72
|
};
|
|
64
|
-
const renderRow = (line, { isSelectedLine, cellsRenderers, isSingleLine, allowComment, withDarkBackground, rowIndex, }) => {
|
|
73
|
+
const renderRow = (line, { isSelectedLine, cellsRenderers, isSingleLine, allowComment, withDarkBackground, rowIndex, unsafe, }) => {
|
|
65
74
|
const hasComment = line.commentText || line.xyCommentText;
|
|
66
75
|
const needRenderComment = allowComment && hasComment;
|
|
67
76
|
const fullCellsRenderers = cellsRenderers.slice();
|
|
@@ -106,7 +115,7 @@ const renderRow = (line, { isSelectedLine, cellsRenderers, isSingleLine, allowCo
|
|
|
106
115
|
: line.insertCellAt[index](line);
|
|
107
116
|
}
|
|
108
117
|
else {
|
|
109
|
-
return render(line);
|
|
118
|
+
return render(line, { unsafe });
|
|
110
119
|
}
|
|
111
120
|
})
|
|
112
121
|
.join('')}
|
|
@@ -155,6 +164,7 @@ export const formatTooltip = (data, tooltip, isMobile) => {
|
|
|
155
164
|
const rowRenderingConfig = {
|
|
156
165
|
isSingleLine: lines.length === 1,
|
|
157
166
|
cellsRenderers,
|
|
167
|
+
unsafe,
|
|
158
168
|
};
|
|
159
169
|
const rowRenderingConfigForSelectedLine = {
|
|
160
170
|
cellsRenderers,
|
|
@@ -76,10 +76,13 @@ export type TooltipLine = {
|
|
|
76
76
|
chartKitUnit?: FormatNumberOptions['unit'];
|
|
77
77
|
};
|
|
78
78
|
export type RowRenderingConfig = {
|
|
79
|
-
cellsRenderers: Array<(line: TooltipLine
|
|
79
|
+
cellsRenderers: Array<(line: TooltipLine, options?: {
|
|
80
|
+
unsafe?: boolean;
|
|
81
|
+
}) => string>;
|
|
80
82
|
isSelectedLine?: boolean;
|
|
81
83
|
allowComment?: boolean;
|
|
82
84
|
withDarkBackground?: boolean;
|
|
83
85
|
isSingleLine?: boolean;
|
|
84
86
|
rowIndex?: number;
|
|
87
|
+
unsafe?: boolean;
|
|
85
88
|
};
|
|
@@ -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">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/chartkit",
|
|
3
|
-
"version": "5.19.
|
|
3
|
+
"version": "5.19.2",
|
|
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.4.0",
|
|
54
54
|
"afterframe": "^1.0.2",
|
|
55
55
|
"lodash": "^4.17.21",
|
|
56
56
|
"tslib": "^2.6.2"
|