@gravity-ui/charts 1.7.1 → 1.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/dist/cjs/components/Axis/AxisX.js +10 -8
- package/dist/cjs/components/Axis/AxisY.js +16 -36
- package/dist/cjs/components/ChartInner/index.js +15 -1
- package/dist/cjs/components/ChartInner/useChartInnerProps.d.ts +4 -2
- package/dist/cjs/components/ChartInner/useChartInnerProps.js +4 -1
- package/dist/cjs/components/Legend/index.d.ts +1 -0
- package/dist/cjs/components/Legend/index.js +113 -51
- package/dist/cjs/components/Legend/styles.css +13 -0
- package/dist/cjs/components/Tooltip/DefaultContent.js +6 -3
- package/dist/cjs/constants/chart-types.d.ts +12 -0
- package/dist/cjs/constants/chart-types.js +12 -0
- package/dist/cjs/constants/defaults/axis.d.ts +3 -1
- package/dist/cjs/constants/defaults/axis.js +10 -0
- package/dist/cjs/constants/index.d.ts +6 -47
- package/dist/cjs/constants/index.js +6 -72
- package/dist/cjs/constants/layout-algorithms.d.ts +7 -0
- package/dist/cjs/constants/layout-algorithms.js +8 -0
- package/dist/cjs/constants/line-styles.d.ts +20 -0
- package/dist/cjs/constants/line-styles.js +20 -0
- package/dist/cjs/constants/palette.d.ts +1 -0
- package/dist/cjs/constants/palette.js +22 -0
- package/dist/cjs/constants/symbol-types.d.ts +7 -0
- package/dist/cjs/constants/symbol-types.js +8 -0
- package/dist/cjs/constants/typography.d.ts +1 -0
- package/dist/cjs/constants/typography.js +1 -0
- package/dist/cjs/hooks/index.d.ts +1 -0
- package/dist/cjs/hooks/index.js +1 -0
- package/dist/cjs/hooks/useChartOptions/types.d.ts +4 -2
- package/dist/cjs/hooks/useChartOptions/x-axis.js +11 -2
- package/dist/cjs/hooks/useChartOptions/y-axis.js +14 -3
- package/dist/cjs/hooks/useCrosshair/index.d.ts +17 -0
- package/dist/cjs/hooks/useCrosshair/index.js +139 -0
- package/dist/cjs/hooks/useCrosshair/useCrosshairHover.d.ts +11 -0
- package/dist/cjs/hooks/useCrosshair/useCrosshairHover.js +18 -0
- package/dist/cjs/hooks/useSeries/index.d.ts +4 -2
- package/dist/cjs/hooks/useSeries/prepare-legend.d.ts +11 -9
- package/dist/cjs/hooks/useSeries/prepare-legend.js +78 -23
- package/dist/cjs/hooks/useSeries/prepare-line.d.ts +1 -2
- package/dist/cjs/hooks/useSeries/prepare-line.js +3 -3
- package/dist/cjs/hooks/useSeries/types.d.ts +7 -3
- package/dist/cjs/hooks/useShapes/waterfall/index.js +2 -2
- package/dist/cjs/types/chart/axis.d.ts +26 -21
- package/dist/cjs/types/chart/legend.d.ts +6 -0
- package/dist/cjs/types/chart/line.d.ts +1 -1
- package/dist/cjs/types/chart/series.d.ts +1 -1
- package/dist/cjs/utils/chart/axis.d.ts +1 -0
- package/dist/cjs/utils/chart/axis.js +8 -0
- package/dist/esm/components/Axis/AxisX.js +10 -8
- package/dist/esm/components/Axis/AxisY.js +16 -36
- package/dist/esm/components/ChartInner/index.js +15 -1
- package/dist/esm/components/ChartInner/useChartInnerProps.d.ts +4 -2
- package/dist/esm/components/ChartInner/useChartInnerProps.js +4 -1
- package/dist/esm/components/Legend/index.d.ts +1 -0
- package/dist/esm/components/Legend/index.js +113 -51
- package/dist/esm/components/Legend/styles.css +13 -0
- package/dist/esm/components/Tooltip/DefaultContent.js +6 -3
- package/dist/esm/constants/chart-types.d.ts +12 -0
- package/dist/esm/constants/chart-types.js +12 -0
- package/dist/esm/constants/defaults/axis.d.ts +3 -1
- package/dist/esm/constants/defaults/axis.js +10 -0
- package/dist/esm/constants/index.d.ts +6 -47
- package/dist/esm/constants/index.js +6 -72
- package/dist/esm/constants/layout-algorithms.d.ts +7 -0
- package/dist/esm/constants/layout-algorithms.js +8 -0
- package/dist/esm/constants/line-styles.d.ts +20 -0
- package/dist/esm/constants/line-styles.js +20 -0
- package/dist/esm/constants/palette.d.ts +1 -0
- package/dist/esm/constants/palette.js +22 -0
- package/dist/esm/constants/symbol-types.d.ts +7 -0
- package/dist/esm/constants/symbol-types.js +8 -0
- package/dist/esm/constants/typography.d.ts +1 -0
- package/dist/esm/constants/typography.js +1 -0
- package/dist/esm/hooks/index.d.ts +1 -0
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/useChartOptions/types.d.ts +4 -2
- package/dist/esm/hooks/useChartOptions/x-axis.js +11 -2
- package/dist/esm/hooks/useChartOptions/y-axis.js +14 -3
- package/dist/esm/hooks/useCrosshair/index.d.ts +17 -0
- package/dist/esm/hooks/useCrosshair/index.js +139 -0
- package/dist/esm/hooks/useCrosshair/useCrosshairHover.d.ts +11 -0
- package/dist/esm/hooks/useCrosshair/useCrosshairHover.js +18 -0
- package/dist/esm/hooks/useSeries/index.d.ts +4 -2
- package/dist/esm/hooks/useSeries/prepare-legend.d.ts +11 -9
- package/dist/esm/hooks/useSeries/prepare-legend.js +78 -23
- package/dist/esm/hooks/useSeries/prepare-line.d.ts +1 -2
- package/dist/esm/hooks/useSeries/prepare-line.js +3 -3
- package/dist/esm/hooks/useSeries/types.d.ts +7 -3
- package/dist/esm/hooks/useShapes/waterfall/index.js +2 -2
- package/dist/esm/types/chart/axis.d.ts +26 -21
- package/dist/esm/types/chart/legend.d.ts +6 -0
- package/dist/esm/types/chart/line.d.ts +1 -1
- package/dist/esm/types/chart/series.d.ts +1 -1
- package/dist/esm/utils/chart/axis.d.ts +1 -0
- package/dist/esm/utils/chart/axis.js +8 -0
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { line as lineGenerator, scaleLinear, select, symbol } from 'd3';
|
|
3
3
|
import { CONTINUOUS_LEGEND_SIZE } from '../../constants';
|
|
4
4
|
import { formatNumber } from '../../libs';
|
|
5
|
-
import { block, createGradientRect, getContinuesColorFn, getLabelsSize, getLineDashArray, getSymbol, } from '../../utils';
|
|
5
|
+
import { block, createGradientRect, getContinuesColorFn, getLabelsSize, getLineDashArray, getSymbol, handleOverflowingText, } from '../../utils';
|
|
6
6
|
import { axisBottom } from '../../utils/chart/axis-generators';
|
|
7
7
|
import './styles.css';
|
|
8
8
|
const b = block('legend');
|
|
@@ -18,27 +18,28 @@ const getLegendPosition = (args) => {
|
|
|
18
18
|
return { top, left: offsetWidth + width / 2 - contentWidth / 2 };
|
|
19
19
|
};
|
|
20
20
|
const appendPaginator = (args) => {
|
|
21
|
-
const { container,
|
|
21
|
+
const { container, pageIndex, legend, transform, pages, onArrowClick } = args;
|
|
22
22
|
const paginationLine = container.append('g').attr('class', b('pagination'));
|
|
23
|
+
const maxPage = pages.length;
|
|
23
24
|
let computedWidth = 0;
|
|
24
25
|
paginationLine
|
|
25
26
|
.append('text')
|
|
26
27
|
.text('▲')
|
|
27
28
|
.attr('class', function () {
|
|
28
|
-
return b('pagination-arrow', { inactive:
|
|
29
|
+
return b('pagination-arrow', { inactive: pageIndex === 0 });
|
|
29
30
|
})
|
|
30
31
|
.style('font-size', legend.itemStyle.fontSize)
|
|
31
32
|
.each(function () {
|
|
32
33
|
computedWidth += this.getComputedTextLength();
|
|
33
34
|
})
|
|
34
35
|
.on('click', function () {
|
|
35
|
-
if (
|
|
36
|
-
onArrowClick(
|
|
36
|
+
if (pageIndex - 1 >= 0) {
|
|
37
|
+
onArrowClick(pageIndex - 1);
|
|
37
38
|
}
|
|
38
39
|
});
|
|
39
40
|
paginationLine
|
|
40
41
|
.append('text')
|
|
41
|
-
.text(`${
|
|
42
|
+
.text(`${pageIndex + 1}/${maxPage}`)
|
|
42
43
|
.attr('class', b('pagination-counter'))
|
|
43
44
|
.attr('x', computedWidth)
|
|
44
45
|
.style('font-size', legend.itemStyle.fontSize)
|
|
@@ -49,13 +50,13 @@ const appendPaginator = (args) => {
|
|
|
49
50
|
.append('text')
|
|
50
51
|
.text('▼')
|
|
51
52
|
.attr('class', function () {
|
|
52
|
-
return b('pagination-arrow', { inactive:
|
|
53
|
+
return b('pagination-arrow', { inactive: pageIndex === maxPage - 1 });
|
|
53
54
|
})
|
|
54
55
|
.attr('x', computedWidth)
|
|
55
56
|
.style('font-size', legend.itemStyle.fontSize)
|
|
56
57
|
.on('click', function () {
|
|
57
|
-
if (
|
|
58
|
-
onArrowClick(
|
|
58
|
+
if (pageIndex + 1 < maxPage) {
|
|
59
|
+
onArrowClick(pageIndex + 1);
|
|
59
60
|
}
|
|
60
61
|
});
|
|
61
62
|
paginationLine.attr('transform', transform);
|
|
@@ -64,7 +65,7 @@ const legendSymbolGenerator = lineGenerator()
|
|
|
64
65
|
.x((d) => d.x)
|
|
65
66
|
.y((d) => d.y);
|
|
66
67
|
function renderLegendSymbol(args) {
|
|
67
|
-
const { selection, legend } = args;
|
|
68
|
+
const { selection, legend, legendLineHeight } = args;
|
|
68
69
|
const line = selection.data();
|
|
69
70
|
const getXPosition = (i) => {
|
|
70
71
|
return line.slice(0, i).reduce((acc, legendItem) => {
|
|
@@ -82,7 +83,7 @@ function renderLegendSymbol(args) {
|
|
|
82
83
|
const color = d.visible ? d.color : '';
|
|
83
84
|
switch (d.symbol.shape) {
|
|
84
85
|
case 'path': {
|
|
85
|
-
const y =
|
|
86
|
+
const y = legendLineHeight / 2;
|
|
86
87
|
const points = [
|
|
87
88
|
{ x: x, y },
|
|
88
89
|
{ x: x + d.symbol.width, y },
|
|
@@ -100,7 +101,7 @@ function renderLegendSymbol(args) {
|
|
|
100
101
|
break;
|
|
101
102
|
}
|
|
102
103
|
case 'rect': {
|
|
103
|
-
const y = (
|
|
104
|
+
const y = (legendLineHeight - d.symbol.height) / 2;
|
|
104
105
|
element
|
|
105
106
|
.append('rect')
|
|
106
107
|
.attr('x', x)
|
|
@@ -113,7 +114,7 @@ function renderLegendSymbol(args) {
|
|
|
113
114
|
break;
|
|
114
115
|
}
|
|
115
116
|
case 'symbol': {
|
|
116
|
-
const y =
|
|
117
|
+
const y = legendLineHeight / 2;
|
|
117
118
|
const translateX = x + d.symbol.width / 2;
|
|
118
119
|
element
|
|
119
120
|
.append('svg:path')
|
|
@@ -134,28 +135,36 @@ function renderLegendSymbol(args) {
|
|
|
134
135
|
});
|
|
135
136
|
}
|
|
136
137
|
export const Legend = (props) => {
|
|
137
|
-
const { boundsWidth, chartSeries, legend, items, config, onItemClick, onUpdate } = props;
|
|
138
|
+
const { boundsWidth, chartSeries, legend, items, config, htmlLayout, onItemClick, onUpdate } = props;
|
|
138
139
|
const ref = React.useRef(null);
|
|
139
|
-
const [
|
|
140
|
+
const [pageIndex, setPageIndex] = React.useState(0);
|
|
140
141
|
React.useEffect(() => {
|
|
141
|
-
|
|
142
|
+
setPageIndex(0);
|
|
142
143
|
}, [boundsWidth]);
|
|
143
144
|
React.useEffect(() => {
|
|
144
|
-
var _a, _b, _c, _d, _e;
|
|
145
|
-
if (!ref.current) {
|
|
145
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
146
|
+
if (!ref.current || !htmlLayout) {
|
|
146
147
|
return;
|
|
147
148
|
}
|
|
148
149
|
const svgElement = select(ref.current);
|
|
149
150
|
svgElement.selectAll('*').remove();
|
|
151
|
+
const htmlElement = select(htmlLayout);
|
|
152
|
+
htmlElement.selectAll('[data-legend]').remove();
|
|
153
|
+
const htmlContainer = legend.html
|
|
154
|
+
? htmlElement.append('div').attr('data-legend', 1).style('position', 'absolute')
|
|
155
|
+
: null;
|
|
150
156
|
let legendWidth = 0;
|
|
151
157
|
if (legend.type === 'discrete') {
|
|
152
|
-
const
|
|
153
|
-
const
|
|
154
|
-
|
|
158
|
+
const start = (_b = (_a = config.pagination) === null || _a === void 0 ? void 0 : _a.pages[pageIndex]) === null || _b === void 0 ? void 0 : _b.start;
|
|
159
|
+
const end = (_d = (_c = config.pagination) === null || _c === void 0 ? void 0 : _c.pages[pageIndex]) === null || _d === void 0 ? void 0 : _d.end;
|
|
160
|
+
const pageItems = typeof start === 'number' && typeof end === 'number'
|
|
161
|
+
? items.slice(start, end)
|
|
155
162
|
: items;
|
|
156
|
-
|
|
163
|
+
const legendLineHeights = [];
|
|
164
|
+
pageItems.forEach((line) => {
|
|
157
165
|
var _a;
|
|
158
166
|
const legendLine = svgElement.append('g').attr('class', b('line'));
|
|
167
|
+
const htmlLegendLine = htmlContainer === null || htmlContainer === void 0 ? void 0 : htmlContainer.append('div').style('position', 'absolute');
|
|
159
168
|
const legendItemTemplate = legendLine
|
|
160
169
|
.selectAll('legend-history')
|
|
161
170
|
.data(line)
|
|
@@ -175,22 +184,65 @@ export const Legend = (props) => {
|
|
|
175
184
|
legend.itemDistance);
|
|
176
185
|
}, 0);
|
|
177
186
|
};
|
|
178
|
-
|
|
179
|
-
legendItemTemplate
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
187
|
+
const legendLineHeight = Math.max(...line.map((l) => l.height));
|
|
188
|
+
renderLegendSymbol({ selection: legendItemTemplate, legend, legendLineHeight });
|
|
189
|
+
if (htmlLegendLine) {
|
|
190
|
+
htmlLegendLine
|
|
191
|
+
.selectAll('legend-item')
|
|
192
|
+
.data(line)
|
|
193
|
+
.enter()
|
|
194
|
+
.append('div')
|
|
195
|
+
.attr('class', function (d) {
|
|
196
|
+
const mods = { selected: d.visible, unselected: !d.visible };
|
|
197
|
+
return b('item-text-html', mods);
|
|
198
|
+
})
|
|
199
|
+
.style('font-size', legend.itemStyle.fontSize)
|
|
200
|
+
.style('position', 'absolute')
|
|
201
|
+
.style('max-width', function (d) {
|
|
202
|
+
return `${d.textWidth}px`;
|
|
203
|
+
})
|
|
204
|
+
.style('left', function (d, i) {
|
|
205
|
+
return `${getXPosition(i) + d.symbol.width + d.symbol.padding}px`;
|
|
206
|
+
})
|
|
207
|
+
.style('top', function (d) {
|
|
208
|
+
if (d.height < legendLineHeight) {
|
|
209
|
+
return `${(legendLineHeight - d.height) / 2}px`;
|
|
210
|
+
}
|
|
211
|
+
return '0px';
|
|
212
|
+
})
|
|
213
|
+
.on('click', function (e, d) {
|
|
214
|
+
onItemClick({ name: d.name, metaKey: e.metaKey });
|
|
215
|
+
onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate();
|
|
216
|
+
})[legend.html ? 'html' : 'text'](function (d) {
|
|
217
|
+
return d.name;
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
legendItemTemplate
|
|
222
|
+
.append('text')
|
|
223
|
+
.attr('x', function (legendItem, i) {
|
|
224
|
+
return (getXPosition(i) +
|
|
225
|
+
legendItem.symbol.width +
|
|
226
|
+
legendItem.symbol.padding);
|
|
227
|
+
})
|
|
228
|
+
.attr('height', legend.height)
|
|
229
|
+
.attr('class', function (d) {
|
|
230
|
+
const mods = { selected: d.visible, unselected: !d.visible };
|
|
231
|
+
return b('item-text', mods);
|
|
232
|
+
})
|
|
233
|
+
.html(function (d) {
|
|
234
|
+
return ('name' in d && d.name);
|
|
235
|
+
})
|
|
236
|
+
.style('font-size', legend.itemStyle.fontSize)
|
|
237
|
+
.each((d, index, nodes) => {
|
|
238
|
+
if (d.overflowed) {
|
|
239
|
+
handleOverflowingText(nodes[index], d.textWidth);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
const contentWidth = (legend.html
|
|
244
|
+
? getXPosition(line.length) - legend.itemDistance
|
|
245
|
+
: (_a = legendLine.node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width) || 0;
|
|
194
246
|
let left = 0;
|
|
195
247
|
switch (legend.justifyContent) {
|
|
196
248
|
case 'center': {
|
|
@@ -209,27 +261,26 @@ export const Legend = (props) => {
|
|
|
209
261
|
break;
|
|
210
262
|
}
|
|
211
263
|
}
|
|
212
|
-
const top =
|
|
264
|
+
const top = legendLineHeights.reduce((acc, h) => acc + h, 0);
|
|
265
|
+
legendLineHeights.push(legendLineHeight);
|
|
213
266
|
legendLine.attr('transform', `translate(${[left, top].join(',')})`);
|
|
267
|
+
htmlLegendLine === null || htmlLegendLine === void 0 ? void 0 : htmlLegendLine.style('transform', `translate(${left}px, ${top}px)`);
|
|
214
268
|
});
|
|
215
269
|
if (config.pagination) {
|
|
216
|
-
const transform = `translate(${[
|
|
217
|
-
0,
|
|
218
|
-
legend.lineHeight * config.pagination.limit + legend.lineHeight / 2,
|
|
219
|
-
].join(',')})`;
|
|
270
|
+
const transform = `translate(${[0, legend.height - legend.lineHeight / 2].join(',')})`;
|
|
220
271
|
appendPaginator({
|
|
221
272
|
container: svgElement,
|
|
222
|
-
|
|
223
|
-
maxPage: config.pagination.maxPage,
|
|
273
|
+
pageIndex: pageIndex,
|
|
224
274
|
legend,
|
|
225
275
|
transform,
|
|
226
|
-
|
|
276
|
+
pages: config.pagination.pages,
|
|
277
|
+
onArrowClick: setPageIndex,
|
|
227
278
|
});
|
|
228
279
|
}
|
|
229
280
|
}
|
|
230
281
|
else {
|
|
231
282
|
// gradient rect
|
|
232
|
-
const domain = (
|
|
283
|
+
const domain = (_e = legend.colorScale.domain) !== null && _e !== void 0 ? _e : [];
|
|
233
284
|
const rectHeight = CONTINUOUS_LEGEND_SIZE.height;
|
|
234
285
|
svgElement.call(createGradientRect, {
|
|
235
286
|
y: legend.title.height + legend.title.margin,
|
|
@@ -291,9 +342,9 @@ export const Legend = (props) => {
|
|
|
291
342
|
.attr('class', b('title'))
|
|
292
343
|
.append('text')
|
|
293
344
|
.attr('dx', dx)
|
|
294
|
-
.attr('font-weight', (
|
|
295
|
-
.attr('font-size', (
|
|
296
|
-
.attr('fill', (
|
|
345
|
+
.attr('font-weight', (_f = legend.title.style.fontWeight) !== null && _f !== void 0 ? _f : null)
|
|
346
|
+
.attr('font-size', (_g = legend.title.style.fontSize) !== null && _g !== void 0 ? _g : null)
|
|
347
|
+
.attr('fill', (_h = legend.title.style.fontColor) !== null && _h !== void 0 ? _h : null)
|
|
297
348
|
.style('dominant-baseline', 'text-before-edge')
|
|
298
349
|
.html(legend.title.text);
|
|
299
350
|
}
|
|
@@ -304,6 +355,17 @@ export const Legend = (props) => {
|
|
|
304
355
|
contentWidth: legendWidth,
|
|
305
356
|
});
|
|
306
357
|
svgElement.attr('transform', `translate(${[left, config.offset.top].join(',')})`);
|
|
307
|
-
|
|
358
|
+
htmlContainer === null || htmlContainer === void 0 ? void 0 : htmlContainer.style('transform', `translate(${left}px, ${config.offset.top}px)`);
|
|
359
|
+
}, [
|
|
360
|
+
boundsWidth,
|
|
361
|
+
chartSeries,
|
|
362
|
+
onItemClick,
|
|
363
|
+
onUpdate,
|
|
364
|
+
legend,
|
|
365
|
+
items,
|
|
366
|
+
config,
|
|
367
|
+
pageIndex,
|
|
368
|
+
htmlLayout,
|
|
369
|
+
]);
|
|
308
370
|
return React.createElement("g", { className: b(), ref: ref, width: boundsWidth, height: legend.height });
|
|
309
371
|
};
|
|
@@ -27,6 +27,19 @@
|
|
|
27
27
|
.gcharts-legend__item-text:hover {
|
|
28
28
|
fill: var(--g-color-text-complementary);
|
|
29
29
|
}
|
|
30
|
+
.gcharts-legend__item-text-html {
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
user-select: none;
|
|
34
|
+
white-space: nowrap;
|
|
35
|
+
text-overflow: ellipsis;
|
|
36
|
+
}
|
|
37
|
+
.gcharts-legend__item-text-html_unselected {
|
|
38
|
+
color: var(--g-color-text-hint);
|
|
39
|
+
}
|
|
40
|
+
.gcharts-legend__item-text-html:hover {
|
|
41
|
+
color: var(--g-color-text-complementary);
|
|
42
|
+
}
|
|
30
43
|
.gcharts-legend__pagination {
|
|
31
44
|
user-select: none;
|
|
32
45
|
fill: var(--g-color-text-primary);
|
|
@@ -135,9 +135,12 @@ export const DefaultContent = ({ hovered, xAxis, yAxis, valueFormat }) => {
|
|
|
135
135
|
});
|
|
136
136
|
return (React.createElement("div", { key: id, className: b('content-row') },
|
|
137
137
|
React.createElement("div", { className: b('color'), style: { backgroundColor: color } }),
|
|
138
|
-
React.createElement("span",
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
React.createElement("span", { dangerouslySetInnerHTML: {
|
|
139
|
+
__html: [seriesData.name || seriesData.id]
|
|
140
|
+
.flat()
|
|
141
|
+
.join('\n'),
|
|
142
|
+
} }),
|
|
143
|
+
"\u00A0",
|
|
141
144
|
React.createElement("span", null, formattedValue)));
|
|
142
145
|
}
|
|
143
146
|
case 'sankey': {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const SeriesType: {
|
|
2
|
+
readonly Area: "area";
|
|
3
|
+
readonly BarX: "bar-x";
|
|
4
|
+
readonly BarY: "bar-y";
|
|
5
|
+
readonly Line: "line";
|
|
6
|
+
readonly Pie: "pie";
|
|
7
|
+
readonly Scatter: "scatter";
|
|
8
|
+
readonly Treemap: "treemap";
|
|
9
|
+
readonly Waterfall: "waterfall";
|
|
10
|
+
readonly Sankey: "sankey";
|
|
11
|
+
readonly Radar: "radar";
|
|
12
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BaseTextStyle, ChartAxis, ChartAxisType } from '../../types';
|
|
1
|
+
import type { AxisCrosshair, BaseTextStyle, ChartAxis, ChartAxisType } from '../../types';
|
|
2
2
|
export declare const axisLabelsDefaults: {
|
|
3
3
|
margin: number;
|
|
4
4
|
padding: number;
|
|
@@ -8,6 +8,8 @@ export declare const axisLabelsDefaults: {
|
|
|
8
8
|
type AxisTitleDefaults = Required<ChartAxis['title']> & {
|
|
9
9
|
style: BaseTextStyle;
|
|
10
10
|
};
|
|
11
|
+
type AxisCrosshairDefaults = Required<AxisCrosshair>;
|
|
12
|
+
export declare const axisCrosshairDefaults: AxisCrosshairDefaults;
|
|
11
13
|
export declare const xAxisTitleDefaults: AxisTitleDefaults;
|
|
12
14
|
export declare const yAxisTitleDefaults: AxisTitleDefaults;
|
|
13
15
|
export declare const DEFAULT_AXIS_TYPE: ChartAxisType;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DASH_STYLE } from '../line-styles';
|
|
1
2
|
export const axisLabelsDefaults = {
|
|
2
3
|
margin: 10,
|
|
3
4
|
padding: 10,
|
|
@@ -13,6 +14,15 @@ const axisTitleDefaults = {
|
|
|
13
14
|
align: 'center',
|
|
14
15
|
maxRowCount: 1,
|
|
15
16
|
};
|
|
17
|
+
export const axisCrosshairDefaults = {
|
|
18
|
+
enabled: false,
|
|
19
|
+
color: 'var(--g-color-line-generic)',
|
|
20
|
+
width: 1,
|
|
21
|
+
snap: true,
|
|
22
|
+
dashStyle: DASH_STYLE.Solid,
|
|
23
|
+
opacity: 1,
|
|
24
|
+
layerPlacement: 'after',
|
|
25
|
+
};
|
|
16
26
|
export const xAxisTitleDefaults = Object.assign(Object.assign({}, axisTitleDefaults), { margin: 4 });
|
|
17
27
|
export const yAxisTitleDefaults = Object.assign(Object.assign({}, axisTitleDefaults), { margin: 8 });
|
|
18
28
|
export const DEFAULT_AXIS_TYPE = 'linear';
|
|
@@ -1,49 +1,8 @@
|
|
|
1
1
|
export * from './defaults';
|
|
2
2
|
export * from './misc';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
readonly Scatter: "scatter";
|
|
10
|
-
readonly Treemap: "treemap";
|
|
11
|
-
readonly Waterfall: "waterfall";
|
|
12
|
-
readonly Sankey: "sankey";
|
|
13
|
-
readonly Radar: "radar";
|
|
14
|
-
};
|
|
15
|
-
export declare enum DashStyle {
|
|
16
|
-
Dash = "Dash",
|
|
17
|
-
DashDot = "DashDot",
|
|
18
|
-
Dot = "Dot",
|
|
19
|
-
LongDash = "LongDash",
|
|
20
|
-
LongDashDot = "LongDashDot",
|
|
21
|
-
LongDashDotDot = "LongDashDotDot",
|
|
22
|
-
ShortDash = "ShortDash",
|
|
23
|
-
ShortDashDot = "ShortDashDot",
|
|
24
|
-
ShortDashDotDot = "ShortDashDotDot",
|
|
25
|
-
ShortDot = "ShortDot",
|
|
26
|
-
Solid = "Solid"
|
|
27
|
-
}
|
|
28
|
-
export declare enum SymbolType {
|
|
29
|
-
Circle = "circle",
|
|
30
|
-
Diamond = "diamond",
|
|
31
|
-
Square = "square",
|
|
32
|
-
Triangle = "triangle",
|
|
33
|
-
TriangleDown = "triangle-down"
|
|
34
|
-
}
|
|
35
|
-
export declare enum LineCap {
|
|
36
|
-
Butt = "butt",
|
|
37
|
-
Round = "round",
|
|
38
|
-
Square = "square",
|
|
39
|
-
None = "none"
|
|
40
|
-
}
|
|
41
|
-
export declare enum LayoutAlgorithm {
|
|
42
|
-
Binary = "binary",
|
|
43
|
-
Dice = "dice",
|
|
44
|
-
Slice = "slice",
|
|
45
|
-
SliceDice = "slice-dice",
|
|
46
|
-
Squarify = "squarify"
|
|
47
|
-
}
|
|
48
|
-
export declare const DEFAULT_PALETTE: string[];
|
|
49
|
-
export declare const DEFAULT_AXIS_LABEL_FONT_SIZE = "11px";
|
|
3
|
+
export * from './chart-types';
|
|
4
|
+
export * from './line-styles';
|
|
5
|
+
export * from './symbol-types';
|
|
6
|
+
export * from './layout-algorithms';
|
|
7
|
+
export * from './palette';
|
|
8
|
+
export * from './typography';
|
|
@@ -1,74 +1,8 @@
|
|
|
1
1
|
export * from './defaults';
|
|
2
2
|
export * from './misc';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Scatter: 'scatter',
|
|
10
|
-
Treemap: 'treemap',
|
|
11
|
-
Waterfall: 'waterfall',
|
|
12
|
-
Sankey: 'sankey',
|
|
13
|
-
Radar: 'radar',
|
|
14
|
-
};
|
|
15
|
-
export var DashStyle;
|
|
16
|
-
(function (DashStyle) {
|
|
17
|
-
DashStyle["Dash"] = "Dash";
|
|
18
|
-
DashStyle["DashDot"] = "DashDot";
|
|
19
|
-
DashStyle["Dot"] = "Dot";
|
|
20
|
-
DashStyle["LongDash"] = "LongDash";
|
|
21
|
-
DashStyle["LongDashDot"] = "LongDashDot";
|
|
22
|
-
DashStyle["LongDashDotDot"] = "LongDashDotDot";
|
|
23
|
-
DashStyle["ShortDash"] = "ShortDash";
|
|
24
|
-
DashStyle["ShortDashDot"] = "ShortDashDot";
|
|
25
|
-
DashStyle["ShortDashDotDot"] = "ShortDashDotDot";
|
|
26
|
-
DashStyle["ShortDot"] = "ShortDot";
|
|
27
|
-
DashStyle["Solid"] = "Solid";
|
|
28
|
-
})(DashStyle || (DashStyle = {}));
|
|
29
|
-
export var SymbolType;
|
|
30
|
-
(function (SymbolType) {
|
|
31
|
-
SymbolType["Circle"] = "circle";
|
|
32
|
-
SymbolType["Diamond"] = "diamond";
|
|
33
|
-
SymbolType["Square"] = "square";
|
|
34
|
-
SymbolType["Triangle"] = "triangle";
|
|
35
|
-
SymbolType["TriangleDown"] = "triangle-down";
|
|
36
|
-
})(SymbolType || (SymbolType = {}));
|
|
37
|
-
export var LineCap;
|
|
38
|
-
(function (LineCap) {
|
|
39
|
-
LineCap["Butt"] = "butt";
|
|
40
|
-
LineCap["Round"] = "round";
|
|
41
|
-
LineCap["Square"] = "square";
|
|
42
|
-
LineCap["None"] = "none";
|
|
43
|
-
})(LineCap || (LineCap = {}));
|
|
44
|
-
export var LayoutAlgorithm;
|
|
45
|
-
(function (LayoutAlgorithm) {
|
|
46
|
-
LayoutAlgorithm["Binary"] = "binary";
|
|
47
|
-
LayoutAlgorithm["Dice"] = "dice";
|
|
48
|
-
LayoutAlgorithm["Slice"] = "slice";
|
|
49
|
-
LayoutAlgorithm["SliceDice"] = "slice-dice";
|
|
50
|
-
LayoutAlgorithm["Squarify"] = "squarify";
|
|
51
|
-
})(LayoutAlgorithm || (LayoutAlgorithm = {}));
|
|
52
|
-
export const DEFAULT_PALETTE = [
|
|
53
|
-
'#4DA2F1',
|
|
54
|
-
'#FF3D64',
|
|
55
|
-
'#8AD554',
|
|
56
|
-
'#FFC636',
|
|
57
|
-
'#FFB9DD',
|
|
58
|
-
'#84D1EE',
|
|
59
|
-
'#FF91A1',
|
|
60
|
-
'#54A520',
|
|
61
|
-
'#DB9100',
|
|
62
|
-
'#BA74B3',
|
|
63
|
-
'#1F68A9',
|
|
64
|
-
'#ED65A9',
|
|
65
|
-
'#0FA08D',
|
|
66
|
-
'#FF7E00',
|
|
67
|
-
'#E8B0A4',
|
|
68
|
-
'#52A6C5',
|
|
69
|
-
'#BE2443',
|
|
70
|
-
'#70C1AF',
|
|
71
|
-
'#FFB46C',
|
|
72
|
-
'#DCA3D7',
|
|
73
|
-
];
|
|
74
|
-
export const DEFAULT_AXIS_LABEL_FONT_SIZE = '11px';
|
|
3
|
+
export * from './chart-types';
|
|
4
|
+
export * from './line-styles';
|
|
5
|
+
export * from './symbol-types';
|
|
6
|
+
export * from './layout-algorithms';
|
|
7
|
+
export * from './palette';
|
|
8
|
+
export * from './typography';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var LayoutAlgorithm;
|
|
2
|
+
(function (LayoutAlgorithm) {
|
|
3
|
+
LayoutAlgorithm["Binary"] = "binary";
|
|
4
|
+
LayoutAlgorithm["Dice"] = "dice";
|
|
5
|
+
LayoutAlgorithm["Slice"] = "slice";
|
|
6
|
+
LayoutAlgorithm["SliceDice"] = "slice-dice";
|
|
7
|
+
LayoutAlgorithm["Squarify"] = "squarify";
|
|
8
|
+
})(LayoutAlgorithm || (LayoutAlgorithm = {}));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const DASH_STYLE: {
|
|
2
|
+
readonly Dash: "Dash";
|
|
3
|
+
readonly DashDot: "DashDot";
|
|
4
|
+
readonly Dot: "Dot";
|
|
5
|
+
readonly LongDash: "LongDash";
|
|
6
|
+
readonly LongDashDot: "LongDashDot";
|
|
7
|
+
readonly LongDashDotDot: "LongDashDotDot";
|
|
8
|
+
readonly ShortDash: "ShortDash";
|
|
9
|
+
readonly ShortDashDot: "ShortDashDot";
|
|
10
|
+
readonly ShortDashDotDot: "ShortDashDotDot";
|
|
11
|
+
readonly ShortDot: "ShortDot";
|
|
12
|
+
readonly Solid: "Solid";
|
|
13
|
+
};
|
|
14
|
+
export type DashStyle = keyof typeof DASH_STYLE;
|
|
15
|
+
export declare enum LineCap {
|
|
16
|
+
Butt = "butt",
|
|
17
|
+
Round = "round",
|
|
18
|
+
Square = "square",
|
|
19
|
+
None = "none"
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const DASH_STYLE = {
|
|
2
|
+
Dash: 'Dash',
|
|
3
|
+
DashDot: 'DashDot',
|
|
4
|
+
Dot: 'Dot',
|
|
5
|
+
LongDash: 'LongDash',
|
|
6
|
+
LongDashDot: 'LongDashDot',
|
|
7
|
+
LongDashDotDot: 'LongDashDotDot',
|
|
8
|
+
ShortDash: 'ShortDash',
|
|
9
|
+
ShortDashDot: 'ShortDashDot',
|
|
10
|
+
ShortDashDotDot: 'ShortDashDotDot',
|
|
11
|
+
ShortDot: 'ShortDot',
|
|
12
|
+
Solid: 'Solid',
|
|
13
|
+
};
|
|
14
|
+
export var LineCap;
|
|
15
|
+
(function (LineCap) {
|
|
16
|
+
LineCap["Butt"] = "butt";
|
|
17
|
+
LineCap["Round"] = "round";
|
|
18
|
+
LineCap["Square"] = "square";
|
|
19
|
+
LineCap["None"] = "none";
|
|
20
|
+
})(LineCap || (LineCap = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_PALETTE: string[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const DEFAULT_PALETTE = [
|
|
2
|
+
'#4DA2F1',
|
|
3
|
+
'#FF3D64',
|
|
4
|
+
'#8AD554',
|
|
5
|
+
'#FFC636',
|
|
6
|
+
'#FFB9DD',
|
|
7
|
+
'#84D1EE',
|
|
8
|
+
'#FF91A1',
|
|
9
|
+
'#54A520',
|
|
10
|
+
'#DB9100',
|
|
11
|
+
'#BA74B3',
|
|
12
|
+
'#1F68A9',
|
|
13
|
+
'#ED65A9',
|
|
14
|
+
'#0FA08D',
|
|
15
|
+
'#FF7E00',
|
|
16
|
+
'#E8B0A4',
|
|
17
|
+
'#52A6C5',
|
|
18
|
+
'#BE2443',
|
|
19
|
+
'#70C1AF',
|
|
20
|
+
'#FFB46C',
|
|
21
|
+
'#DCA3D7',
|
|
22
|
+
];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var SymbolType;
|
|
2
|
+
(function (SymbolType) {
|
|
3
|
+
SymbolType["Circle"] = "circle";
|
|
4
|
+
SymbolType["Diamond"] = "diamond";
|
|
5
|
+
SymbolType["Square"] = "square";
|
|
6
|
+
SymbolType["Triangle"] = "triangle";
|
|
7
|
+
SymbolType["TriangleDown"] = "triangle-down";
|
|
8
|
+
})(SymbolType || (SymbolType = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_AXIS_LABEL_FONT_SIZE = "11px";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DEFAULT_AXIS_LABEL_FONT_SIZE = '11px';
|
package/dist/esm/hooks/index.js
CHANGED