@oliasoft-open-source/charts-library 2.5.15 → 2.5.16-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/package.json +1 -8
- package/src/components/bar-chart/bar-chart.stories.jsx +0 -454
- package/src/components/line-chart/datalabels-alignment/__tests__/get-alignment-condition.test.js +0 -36
- package/src/components/line-chart/datalabels-alignment/__tests__/get-alignment-data.test.js +0 -29
- package/src/components/line-chart/datalabels-alignment/__tests__/get-datalabels-position.test.js +0 -21
- package/src/components/line-chart/line-chart.minor-gridlines-plugin.test.js +0 -34
- package/src/components/line-chart/line-chart.stories.jsx +0 -664
- package/src/components/pie-chart/pie-chart.stories.jsx +0 -199
- package/src/components/scatter-chart/scatter-chart.stories.jsx +0 -142
package/package.json
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oliasoft-open-source/charts-library",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.16-0",
|
|
4
4
|
"description": "React Chart Library (based on Chart.js and react-chart-js-2)",
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"files": [
|
|
7
|
-
"index.js",
|
|
8
|
-
"LICENSE",
|
|
9
|
-
"README.md",
|
|
10
|
-
"release-notes.md",
|
|
11
|
-
"src/*"
|
|
12
|
-
],
|
|
13
6
|
"scripts": {
|
|
14
7
|
"build": "yarn run build:storybook",
|
|
15
8
|
"build:storybook": "build-storybook --quiet --output-dir ./public",
|
|
@@ -1,454 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { BarChart } from './bar-chart';
|
|
3
|
-
import { getCustomLegendPlugin } from '../../helpers/get-custom-legend-plugin-example';
|
|
4
|
-
|
|
5
|
-
const labels1 = ['label 1', 'label 2', 'label 3'];
|
|
6
|
-
const dataset1_1a = { label: 'data1', data: [3, 8, 7] };
|
|
7
|
-
const dataset1_2a = { label: 'data2', data: [1, 2, 3] };
|
|
8
|
-
const dataset1_3a = { label: 'data3', data: [5, 0, 4] };
|
|
9
|
-
|
|
10
|
-
const dataset1_1b = { label: 'data1', data: [3, 8, 7], yAxisID: 'y1' };
|
|
11
|
-
const dataset1_2b = { label: 'data2', data: [1, 2, 3], yAxisID: 'y2' };
|
|
12
|
-
const dataset1_3b = { label: 'data3', data: [5, 0, 4], yAxisID: 'y2' };
|
|
13
|
-
|
|
14
|
-
const dataset1_1c = { label: 'data1', data: [3, 8, 7], stack: 1 };
|
|
15
|
-
const dataset1_2c = { label: 'data2', data: [1, 2, 3], stack: 1 };
|
|
16
|
-
const dataset1_3c = { label: 'data3', data: [5, 0, 4], stack: 2 };
|
|
17
|
-
|
|
18
|
-
const annotationDataset = { label: 'data', data: [42, 57, 64] };
|
|
19
|
-
|
|
20
|
-
const datasetNoDataLabels = {
|
|
21
|
-
label: 'data',
|
|
22
|
-
data: [210, 333, 248],
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const singleChart = {
|
|
26
|
-
data: {
|
|
27
|
-
labels: labels1,
|
|
28
|
-
datasets: [dataset1_1a],
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const multipleBarData = {
|
|
33
|
-
data: {
|
|
34
|
-
labels: labels1,
|
|
35
|
-
datasets: [dataset1_1a, dataset1_2a, dataset1_3a],
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const stakedBarData = {
|
|
40
|
-
data: {
|
|
41
|
-
labels: labels1,
|
|
42
|
-
datasets: [dataset1_1a, dataset1_2a, dataset1_3a],
|
|
43
|
-
},
|
|
44
|
-
options: {
|
|
45
|
-
title: 'Stacked',
|
|
46
|
-
additionalAxesOptions: {
|
|
47
|
-
stacked: true,
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const multipleAxisData = {
|
|
53
|
-
data: {
|
|
54
|
-
labels: labels1,
|
|
55
|
-
datasets: [dataset1_1b, dataset1_2b, dataset1_3b],
|
|
56
|
-
},
|
|
57
|
-
options: {
|
|
58
|
-
title: 'Multiple y axes',
|
|
59
|
-
axes: {
|
|
60
|
-
y: [
|
|
61
|
-
{},
|
|
62
|
-
{
|
|
63
|
-
gridLines: {
|
|
64
|
-
drawOnChartArea: false,
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const groupedStacked = {
|
|
73
|
-
data: {
|
|
74
|
-
labels: labels1,
|
|
75
|
-
datasets: [dataset1_1c, dataset1_2c, dataset1_3c],
|
|
76
|
-
},
|
|
77
|
-
options: {
|
|
78
|
-
title: 'Grouped stacked',
|
|
79
|
-
additionalAxesOptions: {
|
|
80
|
-
stacked: true,
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const reversed = {
|
|
86
|
-
data: {
|
|
87
|
-
labels: labels1,
|
|
88
|
-
datasets: [dataset1_1a],
|
|
89
|
-
},
|
|
90
|
-
options: {
|
|
91
|
-
title: 'reversed vertical',
|
|
92
|
-
additionalAxesOptions: {
|
|
93
|
-
reverse: true,
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
const horizontal = {
|
|
98
|
-
data: {
|
|
99
|
-
labels: labels1,
|
|
100
|
-
datasets: [dataset1_1a],
|
|
101
|
-
},
|
|
102
|
-
options: {
|
|
103
|
-
title: 'horizontal',
|
|
104
|
-
direction: 'horizontal',
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
const horizontalReversed = {
|
|
108
|
-
data: {
|
|
109
|
-
labels: labels1,
|
|
110
|
-
datasets: [dataset1_1a],
|
|
111
|
-
},
|
|
112
|
-
options: {
|
|
113
|
-
title: 'reversed horizontal',
|
|
114
|
-
direction: 'horizontal',
|
|
115
|
-
additionalAxesOptions: {
|
|
116
|
-
reverse: true,
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
const axesWithLabels = {
|
|
122
|
-
data: {
|
|
123
|
-
labels: labels1,
|
|
124
|
-
datasets: [dataset1_1a],
|
|
125
|
-
},
|
|
126
|
-
options: {
|
|
127
|
-
title: 'With axes labels',
|
|
128
|
-
axes: {
|
|
129
|
-
x: [
|
|
130
|
-
{
|
|
131
|
-
label: 'x axis',
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
y: [
|
|
135
|
-
{
|
|
136
|
-
label: 'y axis',
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const axisPosition = {
|
|
144
|
-
data: {
|
|
145
|
-
labels: labels1,
|
|
146
|
-
datasets: [dataset1_1a],
|
|
147
|
-
},
|
|
148
|
-
options: {
|
|
149
|
-
title: ['x axis on top', 'y axis on right'],
|
|
150
|
-
axes: {
|
|
151
|
-
x: [
|
|
152
|
-
{
|
|
153
|
-
position: 'top',
|
|
154
|
-
},
|
|
155
|
-
],
|
|
156
|
-
y: [
|
|
157
|
-
{
|
|
158
|
-
position: 'right',
|
|
159
|
-
},
|
|
160
|
-
],
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
const notBeginAtZero = {
|
|
166
|
-
data: {
|
|
167
|
-
labels: labels1,
|
|
168
|
-
datasets: [dataset1_1a],
|
|
169
|
-
},
|
|
170
|
-
options: {
|
|
171
|
-
title: 'Not beginning at zero',
|
|
172
|
-
additionalAxesOptions: {
|
|
173
|
-
beginAtZero: false,
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
const stepSizeChart = {
|
|
179
|
-
data: {
|
|
180
|
-
labels: labels1,
|
|
181
|
-
datasets: [dataset1_1a],
|
|
182
|
-
},
|
|
183
|
-
options: {
|
|
184
|
-
title: 'With step size of 2',
|
|
185
|
-
additionalAxesOptions: {
|
|
186
|
-
stepSize: 2,
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
const suggestedRange = {
|
|
192
|
-
data: {
|
|
193
|
-
labels: labels1,
|
|
194
|
-
datasets: [dataset1_1a],
|
|
195
|
-
},
|
|
196
|
-
options: {
|
|
197
|
-
title: 'With suggested range',
|
|
198
|
-
additionalAxesOptions: {
|
|
199
|
-
beginAtZero: false,
|
|
200
|
-
suggestedMin: 2,
|
|
201
|
-
suggestedMax: 12,
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
const logartihmicChart = {
|
|
207
|
-
data: {
|
|
208
|
-
labels: labels1,
|
|
209
|
-
datasets: [dataset1_1a],
|
|
210
|
-
},
|
|
211
|
-
options: {
|
|
212
|
-
title: 'With logarithmic scale',
|
|
213
|
-
additionalAxesOptions: {
|
|
214
|
-
chartScaleType: 'logarithmic',
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
const dataLabelsNumberChart = {
|
|
220
|
-
data: {
|
|
221
|
-
labels: labels1,
|
|
222
|
-
datasets: [datasetNoDataLabels],
|
|
223
|
-
},
|
|
224
|
-
options: {
|
|
225
|
-
title: 'With value as datalabels',
|
|
226
|
-
graph: {
|
|
227
|
-
showDataLabels: true,
|
|
228
|
-
},
|
|
229
|
-
},
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
const horizontalAnnotationChart = {
|
|
233
|
-
data: {
|
|
234
|
-
labels: labels1,
|
|
235
|
-
datasets: [annotationDataset],
|
|
236
|
-
},
|
|
237
|
-
options: {
|
|
238
|
-
title: 'Annotation Y Axis',
|
|
239
|
-
annotations: {
|
|
240
|
-
showAnnotations: true,
|
|
241
|
-
annotationsData: [
|
|
242
|
-
{
|
|
243
|
-
annotationAxis: 'y',
|
|
244
|
-
label: 'Horizontal Annotation',
|
|
245
|
-
value: 53,
|
|
246
|
-
color: 'rgba(96, 32, 196, 0.5)',
|
|
247
|
-
},
|
|
248
|
-
],
|
|
249
|
-
},
|
|
250
|
-
},
|
|
251
|
-
};
|
|
252
|
-
const verticalAnnotationChart = {
|
|
253
|
-
data: {
|
|
254
|
-
labels: labels1,
|
|
255
|
-
datasets: [annotationDataset],
|
|
256
|
-
},
|
|
257
|
-
options: {
|
|
258
|
-
title: 'Annotation X Axis',
|
|
259
|
-
annotations: {
|
|
260
|
-
showAnnotations: true,
|
|
261
|
-
annotationsData: [
|
|
262
|
-
{
|
|
263
|
-
annotationAxis: 'x',
|
|
264
|
-
label: 'Vertical Annotation',
|
|
265
|
-
value: 0.5,
|
|
266
|
-
color: 'green',
|
|
267
|
-
},
|
|
268
|
-
],
|
|
269
|
-
},
|
|
270
|
-
},
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
const diagonalAnnotationChart = {
|
|
274
|
-
data: {
|
|
275
|
-
labels: labels1,
|
|
276
|
-
datasets: [annotationDataset],
|
|
277
|
-
},
|
|
278
|
-
options: {
|
|
279
|
-
title: 'Diagonal Annotation',
|
|
280
|
-
annotations: {
|
|
281
|
-
showAnnotations: true,
|
|
282
|
-
annotationsData: [
|
|
283
|
-
{
|
|
284
|
-
annotationAxis: 'y',
|
|
285
|
-
label: 'Diagonal Annotation',
|
|
286
|
-
value: 40,
|
|
287
|
-
endValue: 67,
|
|
288
|
-
color: 'rgba(123, 16, 32, 0.8)',
|
|
289
|
-
},
|
|
290
|
-
],
|
|
291
|
-
},
|
|
292
|
-
},
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
const controlAnnotationChart = {
|
|
296
|
-
data: {
|
|
297
|
-
labels: labels1,
|
|
298
|
-
datasets: [annotationDataset],
|
|
299
|
-
},
|
|
300
|
-
options: {
|
|
301
|
-
title: 'Control annotations in legend',
|
|
302
|
-
annotations: {
|
|
303
|
-
showAnnotations: true,
|
|
304
|
-
controlAnnotation: true,
|
|
305
|
-
annotationsData: [
|
|
306
|
-
{
|
|
307
|
-
annotationAxis: 'y',
|
|
308
|
-
label: 'Diagonal Annotation',
|
|
309
|
-
value: 40,
|
|
310
|
-
endValue: 67,
|
|
311
|
-
color: 'rgba(123, 16, 32, 0.8)',
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
annotationAxis: 'y',
|
|
315
|
-
label: 'Horizontal Annotation',
|
|
316
|
-
value: 53,
|
|
317
|
-
color: 'rgba(96, 32, 196, 0.5)',
|
|
318
|
-
},
|
|
319
|
-
],
|
|
320
|
-
},
|
|
321
|
-
},
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
const legendRight = {
|
|
325
|
-
data: {
|
|
326
|
-
labels: labels1,
|
|
327
|
-
datasets: [dataset1_1a],
|
|
328
|
-
},
|
|
329
|
-
options: {
|
|
330
|
-
title: 'Legend to the right',
|
|
331
|
-
legend: {
|
|
332
|
-
position: 'right',
|
|
333
|
-
},
|
|
334
|
-
},
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
const animatedChart = {
|
|
338
|
-
data: {
|
|
339
|
-
labels: labels1,
|
|
340
|
-
datasets: [dataset1_1a],
|
|
341
|
-
},
|
|
342
|
-
options: {
|
|
343
|
-
chartStyling: { performanceMode: false },
|
|
344
|
-
},
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
export default {
|
|
348
|
-
title: 'BarChart',
|
|
349
|
-
component: BarChart,
|
|
350
|
-
args: {
|
|
351
|
-
chart: singleChart,
|
|
352
|
-
},
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
const Template = (args) => {
|
|
356
|
-
return (
|
|
357
|
-
<BarChart
|
|
358
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
359
|
-
{...args}
|
|
360
|
-
/>
|
|
361
|
-
);
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
const customLegendContainerID = 'custom-legend-container';
|
|
365
|
-
|
|
366
|
-
const TemplateWithCustomLegendContainer = (args) => {
|
|
367
|
-
return (
|
|
368
|
-
<>
|
|
369
|
-
<BarChart
|
|
370
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
371
|
-
{...args}
|
|
372
|
-
/>
|
|
373
|
-
<div id={customLegendContainerID}></div>
|
|
374
|
-
</>
|
|
375
|
-
);
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
export const Default = Template.bind({});
|
|
379
|
-
|
|
380
|
-
export const MultipleSets = Template.bind({});
|
|
381
|
-
MultipleSets.args = { chart: multipleBarData };
|
|
382
|
-
|
|
383
|
-
export const Stacked = Template.bind({});
|
|
384
|
-
Stacked.args = { chart: stakedBarData };
|
|
385
|
-
|
|
386
|
-
export const StackedGrouped = Template.bind({});
|
|
387
|
-
StackedGrouped.args = { chart: groupedStacked };
|
|
388
|
-
|
|
389
|
-
export const MultipleYAxes = Template.bind({});
|
|
390
|
-
MultipleYAxes.args = { chart: multipleAxisData };
|
|
391
|
-
|
|
392
|
-
export const Horizontal = Template.bind({});
|
|
393
|
-
Horizontal.args = { chart: horizontal };
|
|
394
|
-
|
|
395
|
-
export const Reversed = Template.bind({});
|
|
396
|
-
Reversed.args = { chart: reversed };
|
|
397
|
-
|
|
398
|
-
export const HorizontalReversed = Template.bind({});
|
|
399
|
-
HorizontalReversed.args = { chart: horizontalReversed };
|
|
400
|
-
|
|
401
|
-
export const AxesLabels = Template.bind({});
|
|
402
|
-
AxesLabels.args = { chart: axesWithLabels };
|
|
403
|
-
|
|
404
|
-
export const AxesPositions = Template.bind({});
|
|
405
|
-
AxesPositions.args = { chart: axisPosition };
|
|
406
|
-
|
|
407
|
-
export const NonZeroStart = Template.bind({});
|
|
408
|
-
NonZeroStart.args = { chart: notBeginAtZero };
|
|
409
|
-
|
|
410
|
-
export const CustomRange = Template.bind({});
|
|
411
|
-
CustomRange.args = { chart: suggestedRange };
|
|
412
|
-
|
|
413
|
-
export const CustomStepSize = Template.bind({});
|
|
414
|
-
CustomStepSize.args = { chart: stepSizeChart };
|
|
415
|
-
|
|
416
|
-
export const LogarithmicScale = Template.bind({});
|
|
417
|
-
LogarithmicScale.args = { chart: logartihmicChart };
|
|
418
|
-
|
|
419
|
-
export const Datalabels = Template.bind({});
|
|
420
|
-
Datalabels.args = { chart: dataLabelsNumberChart };
|
|
421
|
-
|
|
422
|
-
export const LegendOnRight = Template.bind({});
|
|
423
|
-
LegendOnRight.args = { chart: legendRight };
|
|
424
|
-
|
|
425
|
-
export const AnnotationYAxis = Template.bind({});
|
|
426
|
-
AnnotationYAxis.args = { chart: horizontalAnnotationChart };
|
|
427
|
-
|
|
428
|
-
export const AnnotationXAxis = Template.bind({});
|
|
429
|
-
AnnotationXAxis.args = { chart: verticalAnnotationChart };
|
|
430
|
-
|
|
431
|
-
export const AnnotationDiagonal = Template.bind({});
|
|
432
|
-
AnnotationDiagonal.args = { chart: diagonalAnnotationChart };
|
|
433
|
-
|
|
434
|
-
export const AnnotationsInLegend = Template.bind({});
|
|
435
|
-
AnnotationsInLegend.args = { chart: controlAnnotationChart };
|
|
436
|
-
|
|
437
|
-
export const Animated = Template.bind({});
|
|
438
|
-
Animated.args = { chart: animatedChart };
|
|
439
|
-
|
|
440
|
-
export const CustomLegend = TemplateWithCustomLegendContainer.bind({});
|
|
441
|
-
CustomLegend.args = {
|
|
442
|
-
chart: {
|
|
443
|
-
...singleChart,
|
|
444
|
-
options: {
|
|
445
|
-
title: 'Custom HTML legend',
|
|
446
|
-
legend: {
|
|
447
|
-
customLegend: {
|
|
448
|
-
customLegendPlugin: getCustomLegendPlugin(customLegendContainerID),
|
|
449
|
-
customLegendContainerID,
|
|
450
|
-
},
|
|
451
|
-
},
|
|
452
|
-
},
|
|
453
|
-
},
|
|
454
|
-
};
|
package/src/components/line-chart/datalabels-alignment/__tests__/get-alignment-condition.test.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { getCondition } from '../get-alignment-condition';
|
|
2
|
-
|
|
3
|
-
describe('Datalabels alignment condition', () => {
|
|
4
|
-
test('should return overLeftSide = true', () => {
|
|
5
|
-
const result = getCondition(36, 325, 36, 1204, 325);
|
|
6
|
-
expect(result).toStrictEqual({
|
|
7
|
-
overLeftSide: true,
|
|
8
|
-
overRightSide: false,
|
|
9
|
-
overBottomSide: true,
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
test('should return overRightSide = true', () => {
|
|
13
|
-
const result = getCondition(1200, 325, 36, 1204, 325);
|
|
14
|
-
expect(result).toStrictEqual({
|
|
15
|
-
overLeftSide: false,
|
|
16
|
-
overRightSide: true,
|
|
17
|
-
overBottomSide: false,
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
test('should return overBottomSide = true', () => {
|
|
21
|
-
const result = getCondition(457, 250, 36, 1204, 325);
|
|
22
|
-
expect(result).toStrictEqual({
|
|
23
|
-
overLeftSide: false,
|
|
24
|
-
overRightSide: false,
|
|
25
|
-
overBottomSide: true,
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
test('should return all false', () => {
|
|
29
|
-
const result = getCondition(789, 100, 36, 1204, 325);
|
|
30
|
-
expect(result).toStrictEqual({
|
|
31
|
-
overLeftSide: false,
|
|
32
|
-
overRightSide: false,
|
|
33
|
-
overBottomSide: false,
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { getAlignmentData } from '../get-alignment-data';
|
|
2
|
-
|
|
3
|
-
const mockedContext = {
|
|
4
|
-
chart: {
|
|
5
|
-
chartArea: {
|
|
6
|
-
left: 36,
|
|
7
|
-
right: 1204,
|
|
8
|
-
bottom: 325,
|
|
9
|
-
},
|
|
10
|
-
getDatasetMeta: jest.fn(),
|
|
11
|
-
},
|
|
12
|
-
dataIndex: 0,
|
|
13
|
-
datasetIndex: 0,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
describe('Datalabels alignment data', () => {
|
|
17
|
-
test('should return destructured data from context', () => {
|
|
18
|
-
const result = getAlignmentData(mockedContext);
|
|
19
|
-
expect(result).toEqual(
|
|
20
|
-
expect.objectContaining({
|
|
21
|
-
x: null,
|
|
22
|
-
y: null,
|
|
23
|
-
left: 36,
|
|
24
|
-
right: 1204,
|
|
25
|
-
bottom: 325,
|
|
26
|
-
}),
|
|
27
|
-
);
|
|
28
|
-
});
|
|
29
|
-
});
|
package/src/components/line-chart/datalabels-alignment/__tests__/get-datalabels-position.test.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { getPosition } from '../get-datalabels-position';
|
|
2
|
-
|
|
3
|
-
const mockedContext = {
|
|
4
|
-
chart: {
|
|
5
|
-
chartArea: {
|
|
6
|
-
left: 36,
|
|
7
|
-
right: 1204,
|
|
8
|
-
bottom: 325,
|
|
9
|
-
},
|
|
10
|
-
getDatasetMeta: jest.fn(),
|
|
11
|
-
},
|
|
12
|
-
dataIndex: 0,
|
|
13
|
-
datasetIndex: 0,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
describe('Datalabels alignment position', () => {
|
|
17
|
-
test('should return position', () => {
|
|
18
|
-
const result = getPosition()(mockedContext);
|
|
19
|
-
expect(result).toBe('right');
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getLargestMajorTickWidth,
|
|
3
|
-
getMinorTickPositions,
|
|
4
|
-
isValidPosition,
|
|
5
|
-
} from './line-chart.minor-gridlines-plugin';
|
|
6
|
-
|
|
7
|
-
describe('chartMinorGridlinesPlugin', () => {
|
|
8
|
-
test('getLargestMajorTickWidth', () => {
|
|
9
|
-
const even = [0, 1, 2, 3];
|
|
10
|
-
const uneven = [0.85, 1, 2, 2.25];
|
|
11
|
-
expect(getLargestMajorTickWidth(even)).toBe(1);
|
|
12
|
-
expect(getLargestMajorTickWidth(uneven)).toBe(1);
|
|
13
|
-
});
|
|
14
|
-
test('isValidPosition', () => {
|
|
15
|
-
const tickPositions = [0, 1, 2, 3];
|
|
16
|
-
const inBounds = 0.1;
|
|
17
|
-
const outOfBounds = 3.1;
|
|
18
|
-
const duplicate = 2;
|
|
19
|
-
expect(isValidPosition(inBounds, tickPositions)).toBe(true);
|
|
20
|
-
expect(isValidPosition(outOfBounds, tickPositions)).toBe(false);
|
|
21
|
-
expect(isValidPosition(duplicate, tickPositions)).toBe(false);
|
|
22
|
-
});
|
|
23
|
-
test('getMinorTickPositions', () => {
|
|
24
|
-
const even = [0, 1, 2, 3];
|
|
25
|
-
const uneven = [0.85, 1, 2, 2.25];
|
|
26
|
-
expect(getMinorTickPositions(even)).toStrictEqual([
|
|
27
|
-
0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6,
|
|
28
|
-
1.7, 1.8, 1.9, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9,
|
|
29
|
-
]);
|
|
30
|
-
expect(getMinorTickPositions(uneven)).toStrictEqual([
|
|
31
|
-
0.9, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.1, 2.2,
|
|
32
|
-
]);
|
|
33
|
-
});
|
|
34
|
-
});
|