@oliasoft-open-source/charts-library 8.0.0-beta-1 → 8.0.0-beta-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/README.md +430 -0
- package/dist/index.d.ts +995 -13
- package/dist/index.js +194 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,433 @@
|
|
|
1
1
|
# Chart Library
|
|
2
2
|
|
|
3
3
|
Reusable charts for use in React applications.
|
|
4
|
+
|
|
5
|
+
## Usage and defaults
|
|
6
|
+
|
|
7
|
+
The component JSDoc contains usage examples with sample data, labels and an explicit height.
|
|
8
|
+
Those example values are not defaults.
|
|
9
|
+
|
|
10
|
+
The sections below show the complete library-normalized configuration for `getDefaultProps({ chart: {} })`.
|
|
11
|
+
You do not need to pass these objects: omitted options receive these values automatically.
|
|
12
|
+
|
|
13
|
+
- `undefined` means the library leaves that value unspecified; it does not mean zero or false.
|
|
14
|
+
- Empty data is the default. Supply your own DS to draw a chart.
|
|
15
|
+
- These are library defaults, not a dump of Chart.js or plugin defaults. Final rendering can also depend on
|
|
16
|
+
data, container size, theme, plugin configuration and, for LineChart, persisted control state.
|
|
17
|
+
- Compatibility fields may appear in normalized output without affecting rendering; see their public type documentation.
|
|
18
|
+
- Default unit-selector callbacks are no-ops; consumers own unit selection and data conversion.
|
|
19
|
+
- The snapshots describe the initial empty configuration. Per-item defaults for supplied annotations and DS are
|
|
20
|
+
applied separately by their normalizers and renderers.
|
|
21
|
+
|
|
22
|
+
## Migrating LineChart tooltips to 8.0
|
|
23
|
+
|
|
24
|
+
Tooltip coordinate roles no longer depend on axis placement. The default title shows X and the DS row shows Y.
|
|
25
|
+
Set `options.tooltip.titleAxis` to `'y'` when the title should show Y and the DS row should show X.
|
|
26
|
+
Charts that previously relied on a top-positioned X axis must set this explicitly to preserve their tooltip order.
|
|
27
|
+
If your application swaps X/Y coordinates, update `titleAxis` to keep the intended quantity in the title.
|
|
28
|
+
This setting does not move axes, reverse scales or transpose data.
|
|
29
|
+
|
|
30
|
+
The default DS row reads units from the corresponding axis `unit` string or `unit.selectedUnit` when non-empty,
|
|
31
|
+
then falls back to units in square brackets in that axis label. The title appends its axis label.
|
|
32
|
+
Each hovered DS uses its own axis bindings, including numbered IDs such as `x10` and `y10`.
|
|
33
|
+
Time and category values retain their formatted labels. Custom `title`, `label` and `afterLabel` callbacks
|
|
34
|
+
continue to override their respective defaults independently.
|
|
35
|
+
|
|
36
|
+
## LineChart
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
const noop = () => {
|
|
40
|
+
// Default unit selection does not change consumer state.
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const defaultChart = {
|
|
44
|
+
persistenceId: '',
|
|
45
|
+
controlsPortalId: '',
|
|
46
|
+
testId: undefined,
|
|
47
|
+
data: {
|
|
48
|
+
datasets: [],
|
|
49
|
+
},
|
|
50
|
+
options: {
|
|
51
|
+
title: '',
|
|
52
|
+
scales: {
|
|
53
|
+
x: {},
|
|
54
|
+
y: {},
|
|
55
|
+
},
|
|
56
|
+
axes: {
|
|
57
|
+
x: [
|
|
58
|
+
{
|
|
59
|
+
label: '',
|
|
60
|
+
position: 'bottom',
|
|
61
|
+
color: '',
|
|
62
|
+
unit: {
|
|
63
|
+
options: [],
|
|
64
|
+
selectedUnit: '',
|
|
65
|
+
setSelectedUnit: noop,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
y: [
|
|
70
|
+
{
|
|
71
|
+
label: '',
|
|
72
|
+
position: 'left',
|
|
73
|
+
color: '',
|
|
74
|
+
unit: {
|
|
75
|
+
options: [],
|
|
76
|
+
selectedUnit: '',
|
|
77
|
+
setSelectedUnit: noop,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
additionalAxesOptions: {
|
|
83
|
+
chartScaleType: 'linear',
|
|
84
|
+
reverse: false,
|
|
85
|
+
beginAtZero: false,
|
|
86
|
+
stepSize: undefined,
|
|
87
|
+
suggestedMin: undefined,
|
|
88
|
+
suggestedMax: undefined,
|
|
89
|
+
range: undefined,
|
|
90
|
+
autoAxisPadding: false,
|
|
91
|
+
},
|
|
92
|
+
chartStyling: {
|
|
93
|
+
width: undefined,
|
|
94
|
+
height: undefined,
|
|
95
|
+
maintainAspectRatio: false,
|
|
96
|
+
staticChartHeight: false,
|
|
97
|
+
performanceMode: true,
|
|
98
|
+
squareAspectRatio: false,
|
|
99
|
+
layoutPadding: {
|
|
100
|
+
top: 0,
|
|
101
|
+
bottom: 20,
|
|
102
|
+
left: 0,
|
|
103
|
+
right: 0,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
tooltip: {
|
|
107
|
+
tooltips: true,
|
|
108
|
+
showLabelsInTooltips: false,
|
|
109
|
+
hideSimulationName: false,
|
|
110
|
+
scientificNotation: true,
|
|
111
|
+
callbacks: undefined,
|
|
112
|
+
titleAxis: 'x',
|
|
113
|
+
},
|
|
114
|
+
graph: {
|
|
115
|
+
lineTension: 0.01,
|
|
116
|
+
spanGaps: false,
|
|
117
|
+
showDataLabels: false,
|
|
118
|
+
showMinorGridlines: false,
|
|
119
|
+
},
|
|
120
|
+
annotations: {
|
|
121
|
+
labelAnnotation: {
|
|
122
|
+
showLabel: false,
|
|
123
|
+
text: '',
|
|
124
|
+
position: 'bottom-right',
|
|
125
|
+
fontSize: 12,
|
|
126
|
+
xOffset: 5,
|
|
127
|
+
yOffset: 5,
|
|
128
|
+
maxWidth: 300,
|
|
129
|
+
lineHeight: 12,
|
|
130
|
+
},
|
|
131
|
+
showAnnotations: false,
|
|
132
|
+
controlAnnotation: false,
|
|
133
|
+
enableDragAnnotation: false,
|
|
134
|
+
enableCalloutAnnotation: false,
|
|
135
|
+
lineMarkersAnnotation: {
|
|
136
|
+
enabled: false,
|
|
137
|
+
itemGapPx: 4,
|
|
138
|
+
edgePaddingPx: 8,
|
|
139
|
+
horizontalLineLengthPx: undefined,
|
|
140
|
+
lineDirection: undefined,
|
|
141
|
+
labelCollisionPx: 4,
|
|
142
|
+
labelCollisionClusterXPx: 36,
|
|
143
|
+
enableLabelCollisionResolver: true,
|
|
144
|
+
stickToEdge: true,
|
|
145
|
+
stickToGroup: false,
|
|
146
|
+
stickSide: 'right',
|
|
147
|
+
reverse: false,
|
|
148
|
+
xValue: undefined,
|
|
149
|
+
yValue: undefined,
|
|
150
|
+
yStartValue: undefined,
|
|
151
|
+
yEndValue: undefined,
|
|
152
|
+
xStartValue: undefined,
|
|
153
|
+
xEndValue: undefined,
|
|
154
|
+
lengthPx: undefined,
|
|
155
|
+
color: 'rgba(20,20,20,0.9)',
|
|
156
|
+
opacity: 1,
|
|
157
|
+
lineWidth: 1,
|
|
158
|
+
lineDash: [],
|
|
159
|
+
startTick: undefined,
|
|
160
|
+
endTick: undefined,
|
|
161
|
+
items: [],
|
|
162
|
+
},
|
|
163
|
+
annotationsData: [],
|
|
164
|
+
},
|
|
165
|
+
legend: {
|
|
166
|
+
display: true,
|
|
167
|
+
position: 'bottom-left',
|
|
168
|
+
align: 'center',
|
|
169
|
+
customLegend: {
|
|
170
|
+
customLegendPlugin: null,
|
|
171
|
+
customLegendContainerID: '',
|
|
172
|
+
},
|
|
173
|
+
usePointStyle: true,
|
|
174
|
+
},
|
|
175
|
+
chartOptions: {
|
|
176
|
+
showPoints: true,
|
|
177
|
+
showLine: true,
|
|
178
|
+
enableZoom: true,
|
|
179
|
+
enablePan: false,
|
|
180
|
+
enableDragAnnotation: false,
|
|
181
|
+
closeOnOutsideClick: false,
|
|
182
|
+
},
|
|
183
|
+
interactions: {
|
|
184
|
+
onLegendClick: undefined,
|
|
185
|
+
onHover: undefined,
|
|
186
|
+
onUnhover: undefined,
|
|
187
|
+
onAnimationComplete: undefined,
|
|
188
|
+
},
|
|
189
|
+
dragData: {
|
|
190
|
+
enableDragData: false,
|
|
191
|
+
showTooltip: true,
|
|
192
|
+
roundPoints: true,
|
|
193
|
+
dragX: true,
|
|
194
|
+
dragY: true,
|
|
195
|
+
onDragStart: undefined,
|
|
196
|
+
onDrag: undefined,
|
|
197
|
+
onDragEnd: undefined,
|
|
198
|
+
},
|
|
199
|
+
depthType: {},
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## BarChart
|
|
205
|
+
|
|
206
|
+
```ts
|
|
207
|
+
const defaultChart = {
|
|
208
|
+
testId: '',
|
|
209
|
+
controlsPortalId: '',
|
|
210
|
+
data: {
|
|
211
|
+
labels: [],
|
|
212
|
+
datasets: [],
|
|
213
|
+
},
|
|
214
|
+
options: {
|
|
215
|
+
title: '',
|
|
216
|
+
direction: 'vertical',
|
|
217
|
+
axes: {
|
|
218
|
+
x: [{}],
|
|
219
|
+
y: [{}],
|
|
220
|
+
},
|
|
221
|
+
additionalAxesOptions: {
|
|
222
|
+
chartScaleType: 'linear',
|
|
223
|
+
reverse: false,
|
|
224
|
+
stacked: false,
|
|
225
|
+
beginAtZero: true,
|
|
226
|
+
stepSize: undefined,
|
|
227
|
+
suggestedMin: undefined,
|
|
228
|
+
suggestedMax: undefined,
|
|
229
|
+
min: undefined,
|
|
230
|
+
max: undefined,
|
|
231
|
+
stackedX: undefined,
|
|
232
|
+
stackedY: undefined,
|
|
233
|
+
},
|
|
234
|
+
chartStyling: {
|
|
235
|
+
width: undefined,
|
|
236
|
+
height: undefined,
|
|
237
|
+
maintainAspectRatio: false,
|
|
238
|
+
staticChartHeight: false,
|
|
239
|
+
performanceMode: true,
|
|
240
|
+
},
|
|
241
|
+
tooltip: {
|
|
242
|
+
tooltips: true,
|
|
243
|
+
showLabelsInTooltips: false,
|
|
244
|
+
scientificNotation: true,
|
|
245
|
+
},
|
|
246
|
+
graph: {
|
|
247
|
+
showDataLabels: false,
|
|
248
|
+
showMinorGridlines: false,
|
|
249
|
+
},
|
|
250
|
+
scales: {},
|
|
251
|
+
annotations: {
|
|
252
|
+
showAnnotations: true,
|
|
253
|
+
controlAnnotation: false,
|
|
254
|
+
annotationsData: [],
|
|
255
|
+
},
|
|
256
|
+
legend: {
|
|
257
|
+
display: true,
|
|
258
|
+
position: 'top-left',
|
|
259
|
+
align: 'center',
|
|
260
|
+
customLegend: {
|
|
261
|
+
customLegendPlugin: null,
|
|
262
|
+
customLegendContainerID: '',
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
chartOptions: {
|
|
266
|
+
enableZoom: false,
|
|
267
|
+
enablePan: false,
|
|
268
|
+
},
|
|
269
|
+
interactions: {
|
|
270
|
+
onLegendClick: undefined,
|
|
271
|
+
onHover: undefined,
|
|
272
|
+
onUnhover: undefined,
|
|
273
|
+
},
|
|
274
|
+
dragData: {
|
|
275
|
+
enableDragData: false,
|
|
276
|
+
showTooltip: true,
|
|
277
|
+
roundPoints: true,
|
|
278
|
+
dragX: true,
|
|
279
|
+
dragY: true,
|
|
280
|
+
onDragStart: undefined,
|
|
281
|
+
onDrag: undefined,
|
|
282
|
+
onDragEnd: undefined,
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## PieChart
|
|
289
|
+
|
|
290
|
+
```ts
|
|
291
|
+
const defaultChart = {
|
|
292
|
+
testId: null,
|
|
293
|
+
data: {
|
|
294
|
+
labels: [],
|
|
295
|
+
datasets: [],
|
|
296
|
+
},
|
|
297
|
+
options: {
|
|
298
|
+
title: '',
|
|
299
|
+
chartStyling: {
|
|
300
|
+
width: undefined,
|
|
301
|
+
height: undefined,
|
|
302
|
+
maintainAspectRatio: false,
|
|
303
|
+
staticChartHeight: false,
|
|
304
|
+
performanceMode: true,
|
|
305
|
+
},
|
|
306
|
+
tooltip: {
|
|
307
|
+
tooltips: true,
|
|
308
|
+
showLabelsInTooltips: false,
|
|
309
|
+
scientificNotation: true,
|
|
310
|
+
},
|
|
311
|
+
graph: {
|
|
312
|
+
showDataLabels: false,
|
|
313
|
+
stacked: false,
|
|
314
|
+
cutout: 0,
|
|
315
|
+
},
|
|
316
|
+
legend: {
|
|
317
|
+
display: true,
|
|
318
|
+
useDataset: false,
|
|
319
|
+
position: 'bottom',
|
|
320
|
+
align: 'center',
|
|
321
|
+
},
|
|
322
|
+
chartOptions: {
|
|
323
|
+
enableZoom: false,
|
|
324
|
+
enablePan: false,
|
|
325
|
+
},
|
|
326
|
+
interactions: {
|
|
327
|
+
onLegendClick: undefined,
|
|
328
|
+
onHover: undefined,
|
|
329
|
+
onUnhover: undefined,
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
};
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
## ScatterChart
|
|
336
|
+
|
|
337
|
+
```ts
|
|
338
|
+
import { GradientDirection } from '@oliasoft-open-source/charts-library';
|
|
339
|
+
|
|
340
|
+
const defaultChart = {
|
|
341
|
+
testId: null,
|
|
342
|
+
data: {
|
|
343
|
+
labels: [],
|
|
344
|
+
datasets: [],
|
|
345
|
+
},
|
|
346
|
+
options: {
|
|
347
|
+
title: '',
|
|
348
|
+
axes: {
|
|
349
|
+
x: [{}],
|
|
350
|
+
y: [{}],
|
|
351
|
+
},
|
|
352
|
+
additionalAxesOptions: {
|
|
353
|
+
chartScaleType: 'linear',
|
|
354
|
+
reverse: false,
|
|
355
|
+
stacked: false,
|
|
356
|
+
beginAtZero: true,
|
|
357
|
+
stepSize: undefined,
|
|
358
|
+
suggestedMin: undefined,
|
|
359
|
+
suggestedMax: undefined,
|
|
360
|
+
min: undefined,
|
|
361
|
+
max: undefined,
|
|
362
|
+
},
|
|
363
|
+
direction: 'vertical',
|
|
364
|
+
chartStyling: {
|
|
365
|
+
width: 'auto',
|
|
366
|
+
height: 'auto',
|
|
367
|
+
maintainAspectRatio: false,
|
|
368
|
+
staticChartHeight: false,
|
|
369
|
+
performanceMode: true,
|
|
370
|
+
gradient: {
|
|
371
|
+
display: false,
|
|
372
|
+
gradientColors: [
|
|
373
|
+
{
|
|
374
|
+
offset: 0,
|
|
375
|
+
color: 'rgba(144,238,144,0.8)',
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
offset: 0.6,
|
|
379
|
+
color: 'rgba(255,255,224,0.8)',
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
offset: 0.8,
|
|
383
|
+
color: 'rgba(255,255,224,0.8)',
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
offset: 0.92,
|
|
387
|
+
color: 'rgba(255,182,193,0.5)',
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
offset: 0.99,
|
|
391
|
+
color: 'rgba(255,182,193,0.8)',
|
|
392
|
+
},
|
|
393
|
+
],
|
|
394
|
+
direction: GradientDirection.BottomLeftToTopRight,
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
tooltip: {
|
|
398
|
+
enabled: true,
|
|
399
|
+
tooltips: true,
|
|
400
|
+
showLabelsInTooltips: false,
|
|
401
|
+
backgroundColor: '#333',
|
|
402
|
+
displayColors: false,
|
|
403
|
+
scientificNotation: true,
|
|
404
|
+
},
|
|
405
|
+
graph: {
|
|
406
|
+
showMinorGridlines: false,
|
|
407
|
+
showDataLabels: false,
|
|
408
|
+
},
|
|
409
|
+
scales: {},
|
|
410
|
+
legend: {
|
|
411
|
+
display: true,
|
|
412
|
+
useDataset: false,
|
|
413
|
+
position: 'bottom-left',
|
|
414
|
+
align: 'center',
|
|
415
|
+
},
|
|
416
|
+
annotations: {
|
|
417
|
+
showAnnotations: true,
|
|
418
|
+
controlAnnotation: false,
|
|
419
|
+
annotationsData: [],
|
|
420
|
+
},
|
|
421
|
+
chartOptions: {
|
|
422
|
+
enableZoom: false,
|
|
423
|
+
enablePan: false,
|
|
424
|
+
},
|
|
425
|
+
interactions: {
|
|
426
|
+
onLegendClick: undefined,
|
|
427
|
+
onHover: undefined,
|
|
428
|
+
onUnhover: undefined,
|
|
429
|
+
onAnimationComplete: undefined,
|
|
430
|
+
},
|
|
431
|
+
},
|
|
432
|
+
};
|
|
433
|
+
```
|