@gravity-ui/chartkit 2.8.0 → 2.9.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 +14 -0
- package/build/plugins/highcharts/renderer/components/HighchartsComponent.d.ts +5 -0
- package/build/plugins/highcharts/renderer/helpers/config/config.d.ts +5 -0
- package/build/plugins/highcharts/renderer/helpers/config/config.js +7 -4
- package/build/plugins/highcharts/renderer/helpers/config/options.d.ts +12 -4
- package/build/plugins/highcharts/renderer/helpers/config/options.js +5 -0
- package/build/plugins/highcharts/renderer/helpers/graph.css +9 -0
- package/build/plugins/highcharts/renderer/helpers/graph.d.ts +5 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/helpers.d.ts +2 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/helpers.js +9 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/index.js +5 -4
- package/build/plugins/highcharts/renderer/helpers/tooltip/types.d.ts +9 -0
- package/build/plugins/highcharts/types/widget.d.ts +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.9.0](https://github.com/gravity-ui/chartkit/compare/v2.8.1...v2.9.0) (2023-05-31)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **Highcharts plugin:** add `tooltip.sort` configuration ([#170](https://github.com/gravity-ui/chartkit/issues/170)) ([0825a91](https://github.com/gravity-ui/chartkit/commit/0825a91155592d9e06dbdd452547a0c31b71c07a))
|
|
9
|
+
|
|
10
|
+
## [2.8.1](https://github.com/gravity-ui/chartkit/compare/v2.8.0...v2.8.1) (2023-05-30)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **options:** fixed default options for yAxis title color ([#168](https://github.com/gravity-ui/chartkit/issues/168)) ([52bf4cc](https://github.com/gravity-ui/chartkit/commit/52bf4cca79770982e9584e89c9a408086850acd5))
|
|
16
|
+
|
|
3
17
|
## [2.8.0](https://github.com/gravity-ui/chartkit/compare/v2.7.2...v2.8.0) (2023-05-23)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -381,7 +381,7 @@ function validateCellManipulationConfig(tooltipOptions, property, item) {
|
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
383
|
function getTooltip(tooltip, options, comments, holidays) {
|
|
384
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
384
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
385
385
|
const serieType = (this.series && this.series.type) || tooltip.chart.options.chart.type;
|
|
386
386
|
const chart = tooltip.chart;
|
|
387
387
|
const xAxis = chart.xAxis[0];
|
|
@@ -411,6 +411,8 @@ function getTooltip(tooltip, options, comments, holidays) {
|
|
|
411
411
|
],
|
|
412
412
|
count: 1,
|
|
413
413
|
shared: true,
|
|
414
|
+
unsafe: Boolean(options.unsafe),
|
|
415
|
+
sort: (_b = options === null || options === void 0 ? void 0 : options.tooltip) === null || _b === void 0 ? void 0 : _b.sort,
|
|
414
416
|
};
|
|
415
417
|
if (typeof options.manageTooltipConfig === 'function') {
|
|
416
418
|
json = callManageTooltipConfig(options, json, chart);
|
|
@@ -457,6 +459,7 @@ function getTooltip(tooltip, options, comments, holidays) {
|
|
|
457
459
|
withPercent: false,
|
|
458
460
|
tooltipHeader: null,
|
|
459
461
|
unsafe: Boolean(options.unsafe),
|
|
462
|
+
sort: (_c = options === null || options === void 0 ? void 0 : options.tooltip) === null || _c === void 0 ? void 0 : _c.sort,
|
|
460
463
|
};
|
|
461
464
|
if (isDatetimeXAxis) {
|
|
462
465
|
const items = this.points || Highcharts.splat(this);
|
|
@@ -473,9 +476,9 @@ function getTooltip(tooltip, options, comments, holidays) {
|
|
|
473
476
|
}
|
|
474
477
|
json.tooltipHeader = chart.time.dateFormat(xDateFormat, this.x);
|
|
475
478
|
}
|
|
476
|
-
else if ((
|
|
477
|
-
const customTooltipHeaderFormatter = (
|
|
478
|
-
const tooltipHeaderStringValue = String((
|
|
479
|
+
else if ((_f = (_e = (_d = extendedPoint.point) === null || _d === void 0 ? void 0 : _d.options) === null || _e === void 0 ? void 0 : _e.xFormatted) !== null && _f !== void 0 ? _f : (extendedPoint.x || extendedPoint.x === 0)) {
|
|
480
|
+
const customTooltipHeaderFormatter = (_g = options === null || options === void 0 ? void 0 : options.highcharts) === null || _g === void 0 ? void 0 : _g.tooltipHeaderFormatter;
|
|
481
|
+
const tooltipHeaderStringValue = String((_k = (_j = (_h = extendedPoint.point) === null || _h === void 0 ? void 0 : _h.options) === null || _j === void 0 ? void 0 : _j.xFormatted) !== null && _k !== void 0 ? _k : extendedPoint.x);
|
|
479
482
|
json.tooltipHeader = customTooltipHeaderFormatter
|
|
480
483
|
? customTooltipHeaderFormatter(tooltipHeaderStringValue)
|
|
481
484
|
: tooltipHeaderStringValue;
|
|
@@ -86,6 +86,14 @@ declare namespace options {
|
|
|
86
86
|
}
|
|
87
87
|
export { style_3 as style };
|
|
88
88
|
}
|
|
89
|
+
export namespace title_1 {
|
|
90
|
+
export namespace style_4 {
|
|
91
|
+
const color_7: string;
|
|
92
|
+
export { color_7 as color };
|
|
93
|
+
}
|
|
94
|
+
export { style_4 as style };
|
|
95
|
+
}
|
|
96
|
+
export { title_1 as title };
|
|
89
97
|
}
|
|
90
98
|
namespace plotOptions {
|
|
91
99
|
export namespace series {
|
|
@@ -99,13 +107,13 @@ declare namespace options {
|
|
|
99
107
|
}
|
|
100
108
|
export { tooltip_1 as tooltip };
|
|
101
109
|
export namespace dataLabels {
|
|
102
|
-
export namespace
|
|
110
|
+
export namespace style_5 {
|
|
103
111
|
const textOutline_1: string;
|
|
104
112
|
export { textOutline_1 as textOutline };
|
|
105
|
-
const
|
|
106
|
-
export {
|
|
113
|
+
const color_8: string;
|
|
114
|
+
export { color_8 as color };
|
|
107
115
|
}
|
|
108
|
-
export {
|
|
116
|
+
export { style_5 as style };
|
|
109
117
|
}
|
|
110
118
|
export const turboThreshold: number;
|
|
111
119
|
}
|
|
@@ -7,6 +7,15 @@
|
|
|
7
7
|
opacity: 0.5;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
.chartkit-graph .highcharts-legend .highcharts-coloraxis-labels text {
|
|
11
|
+
fill: var(--yc-color-text-secondary) !important;
|
|
12
|
+
color: var(--yc-color-text-secondary) !important;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.chartkit-graph .highcharts-legend .highcharts-coloraxis-grid path {
|
|
16
|
+
stroke: var(--yc-color-base-background);
|
|
17
|
+
}
|
|
18
|
+
|
|
10
19
|
.chartkit-tooltip {
|
|
11
20
|
border: 1px solid var(--highcharts-grid-line);
|
|
12
21
|
border-radius: 3px;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
import orderBy from 'lodash/orderBy';
|
|
1
2
|
export const escapeHTML = (html = '') => {
|
|
2
3
|
const elem = document.createElement('span');
|
|
3
4
|
elem.innerText = html;
|
|
4
5
|
return elem.innerHTML;
|
|
5
6
|
};
|
|
7
|
+
export const getSortedLines = (lines, sort = {}) => {
|
|
8
|
+
// set eneabled to true after https://github.com/gravity-ui/chartkit/issues/171
|
|
9
|
+
const { enabled = false, order = 'desc', iteratee = 'originalValue' } = sort;
|
|
10
|
+
if (!enabled) {
|
|
11
|
+
return [...lines];
|
|
12
|
+
}
|
|
13
|
+
return orderBy(lines, iteratee, order);
|
|
14
|
+
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import _escape from 'lodash/escape';
|
|
3
3
|
import { i18n } from '../../../../../i18n';
|
|
4
4
|
import { renderShapeIcon } from './render-shape-icon';
|
|
5
|
-
import { escapeHTML } from './helpers';
|
|
5
|
+
import { escapeHTML, getSortedLines } from './helpers';
|
|
6
6
|
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';
|
|
@@ -128,9 +128,10 @@ const renderRow = (line, { isSelectedLine, cellsRenderers, isSingleLine, allowCo
|
|
|
128
128
|
export const formatTooltip = (data, tooltip, isMobile) => {
|
|
129
129
|
var _a, _b, _c;
|
|
130
130
|
const { splitTooltip, activeRowAlwaysFirstInTooltip } = data;
|
|
131
|
-
const selectedLineIndex = data.lines.findIndex(({ selectedSeries }) => selectedSeries);
|
|
132
|
-
const selectedLine = data.lines[selectedLineIndex];
|
|
133
131
|
const lines = data.lines.slice(0, (tooltip.lastVisibleRowIndex || data.lines.length) + 1);
|
|
132
|
+
const sortedLines = getSortedLines(lines, data.sort);
|
|
133
|
+
const selectedLineIndex = sortedLines.findIndex(({ selectedSeries }) => selectedSeries);
|
|
134
|
+
const selectedLine = sortedLines[selectedLineIndex];
|
|
134
135
|
const withShapes = lines.every((line) => line.seriesShape);
|
|
135
136
|
const unsafe = data.unsafe;
|
|
136
137
|
const tooltipHeaderRaw = (_a = data.tooltipHeader) === null || _a === void 0 ? void 0 : _a.trim();
|
|
@@ -212,7 +213,7 @@ export const formatTooltip = (data, tooltip, isMobile) => {
|
|
|
212
213
|
.join('')}</tr>
|
|
213
214
|
</thead>`}
|
|
214
215
|
<tbody class="${TOOLTIP_LIST_CLASS_NAME}">
|
|
215
|
-
${
|
|
216
|
+
${sortedLines
|
|
216
217
|
.map((line, index) => renderRow(line, getRowRenderConfig(index)))
|
|
217
218
|
.join('')}
|
|
218
219
|
</tbody>
|
|
@@ -38,6 +38,15 @@ export declare type TooltipData = {
|
|
|
38
38
|
/** Sum of the values of the hidden ("not fit" in the tooltip) rows */
|
|
39
39
|
hiddenRowsSum?: number | string;
|
|
40
40
|
unsafe?: boolean;
|
|
41
|
+
/** Used to manage tooltip lines sorting */
|
|
42
|
+
sort?: {
|
|
43
|
+
/** Enable tooltip lines sorting. `false` by default */
|
|
44
|
+
enabled?: boolean;
|
|
45
|
+
/** The sort orders. `'desc'` by default */
|
|
46
|
+
order?: 'asc' | 'desc';
|
|
47
|
+
/** The iteratees to sort by key(s) from `TooltipLine`. `'originalValue'` by default */
|
|
48
|
+
iteratee?: keyof TooltipLine | keyof TooltipLine[] | ((line: TooltipLine) => TooltipLine[keyof TooltipLine] | TooltipLine[keyof TooltipLine][]);
|
|
49
|
+
};
|
|
41
50
|
};
|
|
42
51
|
export declare type TooltipLine = {
|
|
43
52
|
/** Color displayed in a separate cell */
|
package/package.json
CHANGED