@gravity-ui/chartkit 4.0.0-beta.4 → 4.0.0-beta.5
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/d3/index.d.ts +1 -0
- package/build/plugins/d3/index.js +1 -0
- package/build/plugins/d3/renderer/D3Widget.d.ts +1 -1
- package/build/plugins/highcharts/index.d.ts +1 -0
- package/build/plugins/highcharts/index.js +1 -0
- package/build/plugins/highcharts/renderer/HighchartsWidget.d.ts +2 -2
- package/build/plugins/indicator/index.d.ts +1 -0
- package/build/plugins/indicator/index.js +1 -0
- package/build/plugins/indicator/renderer/IndicatorWidget.d.ts +1 -1
- package/build/plugins/yagr/index.d.ts +1 -0
- package/build/plugins/yagr/index.js +1 -0
- package/build/types/index.d.ts +1 -0
- package/build/types/index.js +1 -1
- package/package.json +30 -3
- package/build/plugins/highcharts/mocks/area-range.d.ts +0 -2
- package/build/plugins/highcharts/mocks/area-range.js +0 -61
- package/build/plugins/highcharts/mocks/area-stacked.d.ts +0 -2
- package/build/plugins/highcharts/mocks/area-stacked.js +0 -256
- package/build/plugins/highcharts/mocks/column-hor-stacked.d.ts +0 -2
- package/build/plugins/highcharts/mocks/column-hor-stacked.js +0 -199
- package/build/plugins/highcharts/mocks/column-ver-stacked.d.ts +0 -2
- package/build/plugins/highcharts/mocks/column-ver-stacked.js +0 -197
- package/build/plugins/highcharts/mocks/column-ver.d.ts +0 -2
- package/build/plugins/highcharts/mocks/column-ver.js +0 -73
- package/build/plugins/highcharts/mocks/combo-chart-with-same-legend-titles.d.ts +0 -2
- package/build/plugins/highcharts/mocks/combo-chart-with-same-legend-titles.js +0 -444
- package/build/plugins/highcharts/mocks/complex.d.ts +0 -2
- package/build/plugins/highcharts/mocks/complex.js +0 -323
- package/build/plugins/highcharts/mocks/custom-error-render.d.ts +0 -3
- package/build/plugins/highcharts/mocks/custom-error-render.js +0 -69
- package/build/plugins/highcharts/mocks/holidays.d.ts +0 -7070
- package/build/plugins/highcharts/mocks/holidays.js +0 -7065
- package/build/plugins/highcharts/mocks/line.d.ts +0 -2
- package/build/plugins/highcharts/mocks/line.js +0 -134
- package/build/plugins/highcharts/mocks/no-data.d.ts +0 -3
- package/build/plugins/highcharts/mocks/no-data.js +0 -69
- package/build/plugins/highcharts/mocks/pie-with-totals.d.ts +0 -2
- package/build/plugins/highcharts/mocks/pie-with-totals.js +0 -43
- package/build/plugins/highcharts/mocks/pie.d.ts +0 -2
- package/build/plugins/highcharts/mocks/pie.js +0 -37
- package/build/plugins/index.d.ts +0 -7
- package/build/plugins/index.js +0 -6
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get the X coordinate of the intersection of the two lines 1-2 and 3-4.
|
|
3
|
-
* @param x1 {number} X-coordinate of the first point of the first line.
|
|
4
|
-
* @param y1 {number} Y-coordinate of the first point of the first line.
|
|
5
|
-
* @param x2 {number} X-coordinate of the second point of the first line.
|
|
6
|
-
* @param y2 {number} Y-coordinate of the second point of the first line.
|
|
7
|
-
* @param x3 {number} X-coordinate of the first point of the second line.
|
|
8
|
-
* @param y3 {number} Y-coordinate of the first point of the second line.
|
|
9
|
-
* @param x4 {number} X-coordinate of the second point of the second line.
|
|
10
|
-
* @param y4 {number} Y-coordinate of the second point of the second line.
|
|
11
|
-
* @returns {number} X-coordinate of the intersection.
|
|
12
|
-
*/
|
|
13
|
-
function getIntersectionX(x1, y1, x2, y2, x3, y3, x4, y4) {
|
|
14
|
-
return Math.trunc(((x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4)) /
|
|
15
|
-
((x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)));
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Get the colored zones for the area chart.
|
|
19
|
-
* @param counts {object} Area chart data.
|
|
20
|
-
* @param createdColor {string} Color (html notation) for the positive zone.
|
|
21
|
-
* @param resolvedColor {string} Color (html notation) for the negative zone.
|
|
22
|
-
* @returns {SeriesZonesOptionsObject[]} Highcharts zones for area chart.
|
|
23
|
-
*/
|
|
24
|
-
function getZones(counts, createdColor, resolvedColor) {
|
|
25
|
-
const zones = [];
|
|
26
|
-
let positive;
|
|
27
|
-
let color;
|
|
28
|
-
let prev;
|
|
29
|
-
for (const count of counts) {
|
|
30
|
-
const isPositive = count.created - count.resolved >= 0;
|
|
31
|
-
if (isPositive !== positive) {
|
|
32
|
-
if (color && prev) {
|
|
33
|
-
const value = getIntersectionX(prev.to, prev.created, count.to, count.created, prev.to, prev.resolved, count.to, count.resolved);
|
|
34
|
-
zones.push({ color, value });
|
|
35
|
-
}
|
|
36
|
-
positive = isPositive;
|
|
37
|
-
color = isPositive ? createdColor : resolvedColor;
|
|
38
|
-
}
|
|
39
|
-
prev = count;
|
|
40
|
-
}
|
|
41
|
-
if (color) {
|
|
42
|
-
zones.push({ color });
|
|
43
|
-
}
|
|
44
|
-
return zones;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Get parameters for a rectangle between two charts. This rectangle
|
|
48
|
-
* is used to visually separate the areas of the two charts.
|
|
49
|
-
* @param chart {Chart} Highcharts chart object.
|
|
50
|
-
* @returns {object} Parameters for rectangle.
|
|
51
|
-
*/
|
|
52
|
-
function getDividerRect(chart) {
|
|
53
|
-
const gridLineWidth = 1;
|
|
54
|
-
const xAxis = chart.xAxis[0];
|
|
55
|
-
const yAxis0 = chart.yAxis[0];
|
|
56
|
-
const yAxis1 = chart.yAxis[1];
|
|
57
|
-
const x = xAxis.left;
|
|
58
|
-
const y = yAxis0.top + yAxis0.height + gridLineWidth;
|
|
59
|
-
const width = xAxis.width;
|
|
60
|
-
const height = yAxis1.top - yAxis0.top - yAxis0.height - gridLineWidth * 2;
|
|
61
|
-
return { x, y, width, height };
|
|
62
|
-
}
|
|
63
|
-
const rawData = [
|
|
64
|
-
{
|
|
65
|
-
from: '2020-04-01T00:00:00Z',
|
|
66
|
-
to: '2020-05-01T00:00:00Z',
|
|
67
|
-
created: 42,
|
|
68
|
-
resolved: 10,
|
|
69
|
-
trend: 32,
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
from: '2020-05-01T00:00:00Z',
|
|
73
|
-
to: '2020-06-01T00:00:00Z',
|
|
74
|
-
created: 53,
|
|
75
|
-
resolved: 30,
|
|
76
|
-
trend: 55,
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
from: '2020-06-01T00:00:00Z',
|
|
80
|
-
to: '2020-07-01T00:00:00Z',
|
|
81
|
-
created: 35,
|
|
82
|
-
resolved: 28,
|
|
83
|
-
trend: 62,
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
from: '2020-07-01T00:00:00Z',
|
|
87
|
-
to: '2020-08-01T00:00:00Z',
|
|
88
|
-
created: 30,
|
|
89
|
-
resolved: 19,
|
|
90
|
-
trend: 73,
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
from: '2020-08-01T00:00:00Z',
|
|
94
|
-
to: '2020-09-01T00:00:00Z',
|
|
95
|
-
created: 18,
|
|
96
|
-
resolved: 23,
|
|
97
|
-
trend: 68,
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
from: '2020-09-01T00:00:00Z',
|
|
101
|
-
to: '2020-10-01T00:00:00Z',
|
|
102
|
-
created: 29,
|
|
103
|
-
resolved: 22,
|
|
104
|
-
trend: 75,
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
from: '2020-10-01T00:00:00Z',
|
|
108
|
-
to: '2020-11-01T00:00:00Z',
|
|
109
|
-
created: 24,
|
|
110
|
-
resolved: 26,
|
|
111
|
-
trend: 73,
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
from: '2020-11-01T00:00:00Z',
|
|
115
|
-
to: '2020-12-01T00:00:00Z',
|
|
116
|
-
created: 19,
|
|
117
|
-
resolved: 21,
|
|
118
|
-
trend: 71,
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
from: '2020-12-01T00:00:00Z',
|
|
122
|
-
to: '2021-01-01T00:00:00Z',
|
|
123
|
-
created: 22,
|
|
124
|
-
resolved: 22,
|
|
125
|
-
trend: 71,
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
from: '2021-01-01T00:00:00Z',
|
|
129
|
-
to: '2021-02-01T00:00:00Z',
|
|
130
|
-
created: 17,
|
|
131
|
-
resolved: 17,
|
|
132
|
-
trend: 71,
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
from: '2021-02-01T00:00:00Z',
|
|
136
|
-
to: '2021-03-01T00:00:00Z',
|
|
137
|
-
created: 30,
|
|
138
|
-
resolved: 26,
|
|
139
|
-
trend: 75,
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
from: '2021-03-01T00:00:00Z',
|
|
143
|
-
to: '2021-04-01T00:00:00Z',
|
|
144
|
-
created: 28,
|
|
145
|
-
resolved: 12,
|
|
146
|
-
trend: 91,
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
from: '2021-04-01T00:00:00Z',
|
|
150
|
-
to: '2021-05-01T00:00:00Z',
|
|
151
|
-
created: 11,
|
|
152
|
-
resolved: 15,
|
|
153
|
-
trend: 87,
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
from: '2021-05-01T00:00:00Z',
|
|
157
|
-
to: '2021-06-01T00:00:00Z',
|
|
158
|
-
created: 9,
|
|
159
|
-
resolved: 4,
|
|
160
|
-
trend: 92,
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
from: '2021-06-01T00:00:00Z',
|
|
164
|
-
to: '2021-07-01T00:00:00Z',
|
|
165
|
-
created: 12,
|
|
166
|
-
resolved: 12,
|
|
167
|
-
trend: 92,
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
from: '2021-07-01T00:00:00Z',
|
|
171
|
-
to: '2021-08-01T00:00:00Z',
|
|
172
|
-
created: 13,
|
|
173
|
-
resolved: 17,
|
|
174
|
-
trend: 88,
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
from: '2021-08-01T00:00:00Z',
|
|
178
|
-
to: '2021-09-01T00:00:00Z',
|
|
179
|
-
created: 3,
|
|
180
|
-
resolved: 14,
|
|
181
|
-
trend: 77,
|
|
182
|
-
},
|
|
183
|
-
];
|
|
184
|
-
const counts = rawData.map(({ created, resolved, trend, from, to }) => ({
|
|
185
|
-
created,
|
|
186
|
-
resolved,
|
|
187
|
-
trend,
|
|
188
|
-
from: Date.parse(from),
|
|
189
|
-
to: Date.parse(to),
|
|
190
|
-
}));
|
|
191
|
-
const arearange = counts.map(({ created, resolved, to }) => [to, resolved, created]);
|
|
192
|
-
const createdLine = counts.map(({ created, to }) => [to, created]);
|
|
193
|
-
const resolvedLine = counts.map(({ resolved, to }) => [to, resolved]);
|
|
194
|
-
const trends = counts.map(({ trend, to }) => [to, trend]);
|
|
195
|
-
export const data = {
|
|
196
|
-
data: {
|
|
197
|
-
graphs: [
|
|
198
|
-
{
|
|
199
|
-
type: 'arearange',
|
|
200
|
-
data: arearange,
|
|
201
|
-
yAxis: 0,
|
|
202
|
-
opacity: 0.5,
|
|
203
|
-
zones: getZones(counts, '#FF3D64', '#8AD554'),
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
type: 'line',
|
|
207
|
-
name: 'Resolved',
|
|
208
|
-
color: '#8AD554',
|
|
209
|
-
data: resolvedLine,
|
|
210
|
-
yAxis: 0,
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
type: 'line',
|
|
214
|
-
name: 'Created',
|
|
215
|
-
color: '#FF3D64',
|
|
216
|
-
data: createdLine,
|
|
217
|
-
yAxis: 0,
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
type: 'line',
|
|
221
|
-
name: 'Average',
|
|
222
|
-
color: '#4DA2F1',
|
|
223
|
-
data: trends,
|
|
224
|
-
yAxis: 1,
|
|
225
|
-
marker: {
|
|
226
|
-
enabled: false,
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
],
|
|
230
|
-
},
|
|
231
|
-
config: {
|
|
232
|
-
hideHolidays: false,
|
|
233
|
-
normalizeDiv: false,
|
|
234
|
-
normalizeSub: false,
|
|
235
|
-
hideHolidaysBands: true,
|
|
236
|
-
},
|
|
237
|
-
libraryConfig: {
|
|
238
|
-
chart: {
|
|
239
|
-
animation: false,
|
|
240
|
-
events: {
|
|
241
|
-
load: function (_event) {
|
|
242
|
-
const rect = getDividerRect(this);
|
|
243
|
-
this.renderer
|
|
244
|
-
.rect(rect.x, rect.y, rect.width, rect.height)
|
|
245
|
-
.addClass('highcharts-axis-grid-divider')
|
|
246
|
-
.attr({
|
|
247
|
-
fill: 'var(--yc-color-base-background)',
|
|
248
|
-
zIndex: 8,
|
|
249
|
-
})
|
|
250
|
-
.add();
|
|
251
|
-
},
|
|
252
|
-
redraw: function (_event) {
|
|
253
|
-
const rect = getDividerRect(this);
|
|
254
|
-
const element = this.container.querySelector('.highcharts-axis-grid-divider');
|
|
255
|
-
if (element) {
|
|
256
|
-
element.setAttribute('x', String(rect.x));
|
|
257
|
-
element.setAttribute('y', String(rect.y));
|
|
258
|
-
element.setAttribute('width', String(rect.width));
|
|
259
|
-
element.setAttribute('height', String(rect.height));
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
xAxis: {
|
|
265
|
-
type: 'datetime',
|
|
266
|
-
minPadding: 0.05,
|
|
267
|
-
maxPadding: 0.05,
|
|
268
|
-
},
|
|
269
|
-
yAxis: [
|
|
270
|
-
{
|
|
271
|
-
height: '70%',
|
|
272
|
-
labels: {
|
|
273
|
-
x: -14,
|
|
274
|
-
},
|
|
275
|
-
offset: 0,
|
|
276
|
-
lineWidth: 1,
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
height: '20%',
|
|
280
|
-
top: '80%',
|
|
281
|
-
labels: {
|
|
282
|
-
x: -14,
|
|
283
|
-
},
|
|
284
|
-
offset: 0,
|
|
285
|
-
lineWidth: 1,
|
|
286
|
-
},
|
|
287
|
-
],
|
|
288
|
-
plotOptions: {
|
|
289
|
-
series: {
|
|
290
|
-
states: {
|
|
291
|
-
inactive: {
|
|
292
|
-
opacity: 0.5,
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
},
|
|
296
|
-
arearange: {
|
|
297
|
-
showInLegend: false,
|
|
298
|
-
enableMouseTracking: false,
|
|
299
|
-
lineWidth: 0,
|
|
300
|
-
marker: {
|
|
301
|
-
enabled: false,
|
|
302
|
-
},
|
|
303
|
-
zoneAxis: 'x',
|
|
304
|
-
},
|
|
305
|
-
line: {
|
|
306
|
-
lineWidth: 1,
|
|
307
|
-
marker: {
|
|
308
|
-
enabled: true,
|
|
309
|
-
symbol: 'circle',
|
|
310
|
-
},
|
|
311
|
-
states: {
|
|
312
|
-
hover: {
|
|
313
|
-
lineWidth: 1,
|
|
314
|
-
lineWidthPlus: 0,
|
|
315
|
-
},
|
|
316
|
-
},
|
|
317
|
-
},
|
|
318
|
-
},
|
|
319
|
-
legend: {
|
|
320
|
-
enabled: false,
|
|
321
|
-
},
|
|
322
|
-
},
|
|
323
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
const baseData = {
|
|
2
|
-
config: {
|
|
3
|
-
hideHolidays: false,
|
|
4
|
-
normalizeDiv: false,
|
|
5
|
-
normalizeSub: false,
|
|
6
|
-
},
|
|
7
|
-
libraryConfig: {
|
|
8
|
-
chart: {
|
|
9
|
-
type: 'arearange',
|
|
10
|
-
},
|
|
11
|
-
title: {
|
|
12
|
-
text: 'Temperature variation by day',
|
|
13
|
-
},
|
|
14
|
-
xAxis: {
|
|
15
|
-
type: 'datetime',
|
|
16
|
-
},
|
|
17
|
-
tooltip: {
|
|
18
|
-
valueSuffix: '°C',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
export const noData = Object.assign(Object.assign({}, baseData), { data: {
|
|
23
|
-
graphs: [
|
|
24
|
-
{
|
|
25
|
-
name: 'Temperatures',
|
|
26
|
-
data: [],
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
} });
|
|
30
|
-
export const filledData = Object.assign(Object.assign({}, baseData), { data: {
|
|
31
|
-
graphs: [
|
|
32
|
-
{
|
|
33
|
-
name: 'Temperatures',
|
|
34
|
-
data: [
|
|
35
|
-
[1246406400000, 10.4, 17],
|
|
36
|
-
[1246492800000, 10.3, 28.6],
|
|
37
|
-
[1246579200000, 14.8, 18.4],
|
|
38
|
-
[1246665600000, 11.5, 25.8],
|
|
39
|
-
[1246752000000, 11.1, 24.4],
|
|
40
|
-
[1246838400000, 17.7, 19.6],
|
|
41
|
-
[1246924800000, 15.1, 18.1],
|
|
42
|
-
[1247011200000, 15.1, 27.2],
|
|
43
|
-
[1247097600000, 17, 17.5],
|
|
44
|
-
[1247184000000, 12.6, 18.5],
|
|
45
|
-
[1247270400000, 12.2, 26],
|
|
46
|
-
[1247356800000, 15.9, 22.9],
|
|
47
|
-
[1247443200000, 17.1, 18.1],
|
|
48
|
-
[1247529600000, 13.3, 24.2],
|
|
49
|
-
[1247616000000, 17, 28.1],
|
|
50
|
-
[1247702400000, 16.2, 22.6],
|
|
51
|
-
[1247788800000, 10.6, 19],
|
|
52
|
-
[1247875200000, 11.3, 19.7],
|
|
53
|
-
[1247961600000, 14.1, 24.6],
|
|
54
|
-
[1248048000000, 14.2, 22.5],
|
|
55
|
-
[1248134400000, 14.1, 28.5],
|
|
56
|
-
[1248220800000, 14, 27],
|
|
57
|
-
[1248307200000, 10.2, 20.6],
|
|
58
|
-
[1248393600000, 13.1, 29.9],
|
|
59
|
-
[1248480000000, 13.7, 21.1],
|
|
60
|
-
[1248566400000, 15, 28.6],
|
|
61
|
-
[1248652800000, 12, 17.5],
|
|
62
|
-
[1248739200000, 17.8, 24.4],
|
|
63
|
-
[1248825600000, 11.7, 25.9],
|
|
64
|
-
[1248912000000, 13.6, 25.6],
|
|
65
|
-
[1248998400000, 17.3, 22.2],
|
|
66
|
-
],
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
} });
|