@oliasoft-open-source/charts-library 5.9.0-beta-9 → 5.9.0-beta-11
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/index.d.ts +236 -60
- package/dist/index.js +213 -126
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export declare enum ChartType {
|
|
|
43
43
|
LINE = "line",
|
|
44
44
|
BAR = "bar",
|
|
45
45
|
PIE = "pie",
|
|
46
|
+
DOUGHNUT = "doughnut",
|
|
46
47
|
SCATTER = "scatter"
|
|
47
48
|
}
|
|
48
49
|
|
|
@@ -57,6 +58,10 @@ export declare enum CursorStyle {
|
|
|
57
58
|
Move = "move"
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
export declare type DeepPartial<T> = T extends (...args: unknown[]) => unknown ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends object ? {
|
|
62
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
63
|
+
} : T;
|
|
64
|
+
|
|
60
65
|
export declare enum DragAxis {
|
|
61
66
|
X = "x",
|
|
62
67
|
Y = "y",
|
|
@@ -93,6 +98,17 @@ export declare enum GradientDirection {
|
|
|
93
98
|
TopRightToBottomLeft = 7
|
|
94
99
|
}
|
|
95
100
|
|
|
101
|
+
export declare interface IAnnotationLabelConfig {
|
|
102
|
+
backgroundColor?: string;
|
|
103
|
+
display?: boolean;
|
|
104
|
+
position?: string;
|
|
105
|
+
color?: string;
|
|
106
|
+
font?: string;
|
|
107
|
+
borderColor?: string;
|
|
108
|
+
callout?: Record<string, unknown>;
|
|
109
|
+
[key: string]: unknown;
|
|
110
|
+
}
|
|
111
|
+
|
|
96
112
|
export declare interface IBarAdditionalAxesOptions extends ICommonAdditionalAxesOptions {
|
|
97
113
|
stackedX?: boolean;
|
|
98
114
|
stackedY?: boolean;
|
|
@@ -116,6 +132,13 @@ export declare interface IBarChartData extends ICommonData {
|
|
|
116
132
|
options: IBarOptions;
|
|
117
133
|
}
|
|
118
134
|
|
|
135
|
+
export declare interface IBarChartDataInput extends Omit<IBarChartData, 'options' | 'data'> {
|
|
136
|
+
data?: DeepPartial<IBarChartData['data']> & {
|
|
137
|
+
datasets?: Array<DeepPartial<IBarChartDataset> | Record<string, unknown> | null>;
|
|
138
|
+
};
|
|
139
|
+
options?: IBarOptionsInput;
|
|
140
|
+
}
|
|
141
|
+
|
|
119
142
|
export declare interface IBarChartDataset extends ICommonDataset {
|
|
120
143
|
isAnnotation?: boolean;
|
|
121
144
|
annotationIndex?: number;
|
|
@@ -129,7 +152,7 @@ export declare interface IBarChartDataset extends ICommonDataset {
|
|
|
129
152
|
}
|
|
130
153
|
|
|
131
154
|
export declare interface IBarChartProps {
|
|
132
|
-
chart:
|
|
155
|
+
chart: IBarChartDataInput;
|
|
133
156
|
}
|
|
134
157
|
|
|
135
158
|
export declare interface IBarDefaultProps {
|
|
@@ -162,7 +185,7 @@ export declare interface IBarLegend extends ICommonLegend {
|
|
|
162
185
|
}
|
|
163
186
|
|
|
164
187
|
export declare interface IBarOptions extends ICommonOptions {
|
|
165
|
-
direction
|
|
188
|
+
direction?: 'vertical' | 'horizontal';
|
|
166
189
|
axes: IBarAxes;
|
|
167
190
|
scales?: ICommonScales;
|
|
168
191
|
additionalAxesOptions?: IBarAdditionalAxesOptions;
|
|
@@ -173,6 +196,31 @@ export declare interface IBarOptions extends ICommonOptions {
|
|
|
173
196
|
dragData?: ICommonDragData;
|
|
174
197
|
}
|
|
175
198
|
|
|
199
|
+
export declare type IBarOptionsInput = DeepPartial<IBarOptions> & {
|
|
200
|
+
title?: unknown;
|
|
201
|
+
direction?: string;
|
|
202
|
+
axes?: {
|
|
203
|
+
x?: ILooseBarAxis[];
|
|
204
|
+
y?: ILooseBarAxis[];
|
|
205
|
+
[key: string]: ILooseBarAxis[] | undefined;
|
|
206
|
+
};
|
|
207
|
+
legend?: DeepPartial<IBarLegend> & {
|
|
208
|
+
position?: string;
|
|
209
|
+
align?: string;
|
|
210
|
+
} & Record<string, unknown>;
|
|
211
|
+
chartStyling?: DeepPartial<IBarStyling> & {
|
|
212
|
+
hideControls?: boolean;
|
|
213
|
+
minHeight?: number | string;
|
|
214
|
+
} & Record<string, unknown>;
|
|
215
|
+
interactions?: DeepPartial<ICommonInteractions> & {
|
|
216
|
+
enableZoom?: boolean;
|
|
217
|
+
enablePan?: boolean;
|
|
218
|
+
} & Record<string, unknown>;
|
|
219
|
+
annotations?: (DeepPartial<ICommonAnnotations> & {
|
|
220
|
+
annotationsData?: ILooseBarAnnotation[];
|
|
221
|
+
}) | null;
|
|
222
|
+
};
|
|
223
|
+
|
|
176
224
|
export declare interface IBarStyling extends ICommonStyling {
|
|
177
225
|
squareAspectRatio?: boolean;
|
|
178
226
|
layoutPadding?: string | number | {
|
|
@@ -183,11 +231,30 @@ export declare interface IBarStyling extends ICommonStyling {
|
|
|
183
231
|
};
|
|
184
232
|
}
|
|
185
233
|
|
|
234
|
+
export declare interface ICalloutLabelConfig {
|
|
235
|
+
enabled?: boolean;
|
|
236
|
+
color?: string;
|
|
237
|
+
font?: string;
|
|
238
|
+
borderColor?: string;
|
|
239
|
+
strokeStyle?: string;
|
|
240
|
+
lineWidth?: number;
|
|
241
|
+
startOffset?: number;
|
|
242
|
+
endOffset?: number;
|
|
243
|
+
margin?: number;
|
|
244
|
+
xValue?: number;
|
|
245
|
+
yValue?: number;
|
|
246
|
+
xAdjust?: number;
|
|
247
|
+
yAdjust?: number;
|
|
248
|
+
onDragStart?: (coordinates: ICoordinates, annotation: ICommonAnnotationsData) => void;
|
|
249
|
+
onDrag?: (coordinates: ICoordinates, annotation: ICommonAnnotationsData) => void;
|
|
250
|
+
onDragEnd?: (coordinates: ICoordinates, annotation: ICommonAnnotationsData) => void;
|
|
251
|
+
}
|
|
252
|
+
|
|
186
253
|
export declare interface IChartDataLabelsOptions {
|
|
187
254
|
display?: 'auto' | boolean;
|
|
188
255
|
align?: 'center';
|
|
189
256
|
anchor?: 'center';
|
|
190
|
-
formatter?: (_value:
|
|
257
|
+
formatter?: (_value: unknown, context: unknown) => unknown;
|
|
191
258
|
}
|
|
192
259
|
|
|
193
260
|
export declare interface IChartGeneratedLabel {
|
|
@@ -198,7 +265,7 @@ export declare interface IChartGeneratedLabel {
|
|
|
198
265
|
}
|
|
199
266
|
|
|
200
267
|
declare interface IChartGraph {
|
|
201
|
-
showMinorGridlines
|
|
268
|
+
showMinorGridlines?: boolean;
|
|
202
269
|
}
|
|
203
270
|
|
|
204
271
|
export declare interface IChartLegendItemFilter {
|
|
@@ -209,8 +276,8 @@ export declare interface IChartLegendItemFilter {
|
|
|
209
276
|
|
|
210
277
|
export declare interface ICommonAdditionalAxesOptions {
|
|
211
278
|
chartScaleType?: 'linear' | 'logarithmic';
|
|
212
|
-
reverse
|
|
213
|
-
beginAtZero
|
|
279
|
+
reverse?: boolean;
|
|
280
|
+
beginAtZero?: boolean;
|
|
214
281
|
stepSize?: number;
|
|
215
282
|
stacked?: boolean;
|
|
216
283
|
suggestedMin?: number;
|
|
@@ -220,14 +287,14 @@ export declare interface ICommonAdditionalAxesOptions {
|
|
|
220
287
|
}
|
|
221
288
|
|
|
222
289
|
export declare interface ICommonAnnotation {
|
|
223
|
-
showLabel
|
|
224
|
-
text
|
|
225
|
-
position
|
|
226
|
-
fontSize
|
|
227
|
-
xOffset
|
|
228
|
-
yOffset
|
|
229
|
-
maxWidth
|
|
230
|
-
lineHeight
|
|
290
|
+
showLabel?: boolean;
|
|
291
|
+
text?: string | string[];
|
|
292
|
+
position?: string;
|
|
293
|
+
fontSize?: number;
|
|
294
|
+
xOffset?: number;
|
|
295
|
+
yOffset?: number;
|
|
296
|
+
maxWidth?: number;
|
|
297
|
+
lineHeight?: number;
|
|
231
298
|
}
|
|
232
299
|
|
|
233
300
|
export declare interface ICommonAnnotationElement {
|
|
@@ -268,21 +335,21 @@ export declare interface ICommonAnnotationsData {
|
|
|
268
335
|
hideLegend?: boolean;
|
|
269
336
|
labelOffsetPx?: number;
|
|
270
337
|
id?: string;
|
|
271
|
-
adjustScaleRange
|
|
272
|
-
annotationAxis
|
|
273
|
-
rotation
|
|
274
|
-
color
|
|
275
|
-
endValue
|
|
338
|
+
adjustScaleRange?: boolean;
|
|
339
|
+
annotationAxis?: 'x' | 'y';
|
|
340
|
+
rotation?: number;
|
|
341
|
+
color?: string;
|
|
342
|
+
endValue?: number;
|
|
276
343
|
borderWidth?: number;
|
|
277
344
|
backgroundColor?: string;
|
|
278
|
-
label
|
|
279
|
-
labelConfig?:
|
|
280
|
-
type
|
|
281
|
-
value
|
|
282
|
-
xMin
|
|
283
|
-
xMax
|
|
284
|
-
yMin
|
|
285
|
-
yMax
|
|
345
|
+
label?: string;
|
|
346
|
+
labelConfig?: IAnnotationLabelConfig;
|
|
347
|
+
type?: DraggableAnnotationType;
|
|
348
|
+
value?: number;
|
|
349
|
+
xMin?: number;
|
|
350
|
+
xMax?: number;
|
|
351
|
+
yMin?: number;
|
|
352
|
+
yMax?: number;
|
|
286
353
|
xValue?: number;
|
|
287
354
|
yValue?: number;
|
|
288
355
|
radius?: number;
|
|
@@ -303,18 +370,18 @@ export declare interface ICommonAnnotationsData {
|
|
|
303
370
|
opacity?: number;
|
|
304
371
|
}
|
|
305
372
|
|
|
306
|
-
export declare interface ICommonAxis<PositionType =
|
|
307
|
-
label
|
|
308
|
-
position
|
|
309
|
-
color
|
|
373
|
+
export declare interface ICommonAxis<PositionType = string> {
|
|
374
|
+
label?: string;
|
|
375
|
+
position?: PositionType;
|
|
376
|
+
color?: string | string[];
|
|
310
377
|
unit?: string;
|
|
311
378
|
gridLines?: boolean;
|
|
312
379
|
stepSize?: number;
|
|
313
380
|
}
|
|
314
381
|
|
|
315
382
|
export declare interface ICommonChartOptions {
|
|
316
|
-
enableZoom
|
|
317
|
-
enablePan
|
|
383
|
+
enableZoom?: boolean;
|
|
384
|
+
enablePan?: boolean;
|
|
318
385
|
}
|
|
319
386
|
|
|
320
387
|
export declare interface ICommonChartPlugins {
|
|
@@ -398,8 +465,8 @@ export declare interface ICommonInteractions {
|
|
|
398
465
|
|
|
399
466
|
export declare interface ICommonLegend {
|
|
400
467
|
display: boolean;
|
|
401
|
-
position
|
|
402
|
-
align
|
|
468
|
+
position?: Position;
|
|
469
|
+
align?: AlignOptions;
|
|
403
470
|
}
|
|
404
471
|
|
|
405
472
|
export declare interface ICommonOptions {
|
|
@@ -433,9 +500,9 @@ export declare interface ICommonStyling {
|
|
|
433
500
|
}
|
|
434
501
|
|
|
435
502
|
export declare interface ICommonTooltip {
|
|
436
|
-
tooltips
|
|
437
|
-
showLabelsInTooltips
|
|
438
|
-
scientificNotation
|
|
503
|
+
tooltips?: boolean;
|
|
504
|
+
showLabelsInTooltips?: boolean;
|
|
505
|
+
scientificNotation?: boolean;
|
|
439
506
|
callbacks?: ICommonTooltipCallbacks;
|
|
440
507
|
}
|
|
441
508
|
|
|
@@ -528,21 +595,23 @@ export declare interface IGeneratedScatterChartDataset {
|
|
|
528
595
|
}
|
|
529
596
|
|
|
530
597
|
export declare interface ILChartOptions extends ICommonChartOptions {
|
|
531
|
-
showPoints
|
|
532
|
-
closeOnOutsideClick
|
|
533
|
-
showLine
|
|
598
|
+
showPoints?: boolean;
|
|
599
|
+
closeOnOutsideClick?: boolean;
|
|
600
|
+
showLine?: boolean;
|
|
601
|
+
enableZoom?: boolean;
|
|
602
|
+
enablePan?: boolean;
|
|
534
603
|
enableDragAnnotation?: boolean;
|
|
535
604
|
}
|
|
536
605
|
|
|
537
606
|
export declare interface ILineChartAdditionalAxesOptions {
|
|
538
|
-
chartScaleType
|
|
539
|
-
reverse
|
|
540
|
-
beginAtZero
|
|
607
|
+
chartScaleType?: 'linear' | 'logarithmic';
|
|
608
|
+
reverse?: boolean;
|
|
609
|
+
beginAtZero?: boolean;
|
|
541
610
|
stepSize?: number;
|
|
542
611
|
suggestedMin?: number;
|
|
543
612
|
suggestedMax?: number;
|
|
544
613
|
range?: ILineRange;
|
|
545
|
-
autoAxisPadding
|
|
614
|
+
autoAxisPadding?: boolean;
|
|
546
615
|
}
|
|
547
616
|
|
|
548
617
|
export declare interface ILineChartAxes {
|
|
@@ -551,12 +620,12 @@ export declare interface ILineChartAxes {
|
|
|
551
620
|
[key: string]: ILineChartAxis[];
|
|
552
621
|
}
|
|
553
622
|
|
|
554
|
-
export declare interface ILineChartAxis<PositionType =
|
|
623
|
+
export declare interface ILineChartAxis<PositionType = TAxisPosition> {
|
|
555
624
|
id?: string;
|
|
556
|
-
label
|
|
557
|
-
position
|
|
558
|
-
color
|
|
559
|
-
unit?: IUnitOptions;
|
|
625
|
+
label?: string;
|
|
626
|
+
position?: PositionType;
|
|
627
|
+
color?: string | string[];
|
|
628
|
+
unit?: IUnitOptions | string;
|
|
560
629
|
stepSize?: number;
|
|
561
630
|
gridLines?: ILineChartGraph;
|
|
562
631
|
min?: number | string;
|
|
@@ -572,6 +641,21 @@ export declare interface ILineChartData extends ICommonData {
|
|
|
572
641
|
controlsPortalId?: string;
|
|
573
642
|
}
|
|
574
643
|
|
|
644
|
+
export declare interface ILineChartDataInput extends Omit<ILineChartData, 'data' | 'options'> {
|
|
645
|
+
data?: DeepPartial<ILineChartData['data']> & {
|
|
646
|
+
datasets?: Array<(DeepPartial<ILineChartDataset> & {
|
|
647
|
+
lineTension?: number | string;
|
|
648
|
+
fill?: boolean | string | Record<string, unknown>;
|
|
649
|
+
pointStyle?: unknown;
|
|
650
|
+
showPoint?: boolean;
|
|
651
|
+
showPoints?: boolean;
|
|
652
|
+
lineHeight?: number;
|
|
653
|
+
data?: Array<DeepPartial<ICommonDataValue> | null>;
|
|
654
|
+
} & Record<string, unknown>) | Record<string, unknown> | null>;
|
|
655
|
+
};
|
|
656
|
+
options?: ILineChartOptionsInput;
|
|
657
|
+
}
|
|
658
|
+
|
|
575
659
|
export declare interface ILineChartDataset extends ICommonDataset {
|
|
576
660
|
lineTension?: number;
|
|
577
661
|
pointBackgroundColor?: string;
|
|
@@ -587,10 +671,10 @@ export declare interface ILineChartDataset extends ICommonDataset {
|
|
|
587
671
|
}
|
|
588
672
|
|
|
589
673
|
export declare interface ILineChartGraph {
|
|
590
|
-
lineTension
|
|
591
|
-
spanGaps
|
|
592
|
-
showDataLabels
|
|
593
|
-
showMinorGridlines
|
|
674
|
+
lineTension?: number;
|
|
675
|
+
spanGaps?: boolean;
|
|
676
|
+
showDataLabels?: boolean;
|
|
677
|
+
showMinorGridlines?: boolean;
|
|
594
678
|
}
|
|
595
679
|
|
|
596
680
|
export declare interface ILineChartOptions extends ICommonOptions {
|
|
@@ -609,8 +693,39 @@ export declare interface ILineChartOptions extends ICommonOptions {
|
|
|
609
693
|
depthType?: IDepthType | object;
|
|
610
694
|
}
|
|
611
695
|
|
|
696
|
+
export declare type ILineChartOptionsInput = DeepPartial<ILineChartOptions> & {
|
|
697
|
+
title?: unknown;
|
|
698
|
+
direction?: string;
|
|
699
|
+
axes?: {
|
|
700
|
+
x?: ILooseLineAxis[];
|
|
701
|
+
y?: ILooseLineAxis[];
|
|
702
|
+
[key: string]: ILooseLineAxis[] | undefined;
|
|
703
|
+
};
|
|
704
|
+
legend?: DeepPartial<ILineLegend> & {
|
|
705
|
+
position?: string;
|
|
706
|
+
align?: string;
|
|
707
|
+
} & Record<string, unknown>;
|
|
708
|
+
chartStyling?: DeepPartial<ILineChartStyling> & {
|
|
709
|
+
hideControls?: boolean;
|
|
710
|
+
minHeight?: number | string;
|
|
711
|
+
} & Record<string, unknown>;
|
|
712
|
+
interactions?: DeepPartial<ILineInteractions> & {
|
|
713
|
+
enableZoom?: boolean;
|
|
714
|
+
enablePan?: boolean;
|
|
715
|
+
} & Record<string, unknown>;
|
|
716
|
+
graph?: DeepPartial<ILineChartGraph> & {
|
|
717
|
+
tooltip?: unknown;
|
|
718
|
+
} & Record<string, unknown>;
|
|
719
|
+
annotations?: (DeepPartial<ICommonAnnotations> & {
|
|
720
|
+
annotationsData?: ILooseLineAnnotation[];
|
|
721
|
+
}) | null;
|
|
722
|
+
additionalAxesOptions?: DeepPartial<ILineChartAdditionalAxesOptions> & {
|
|
723
|
+
range?: ILineRange | ILineChartRange | Record<string, ILineChartRange | undefined>;
|
|
724
|
+
} & Record<string, unknown>;
|
|
725
|
+
};
|
|
726
|
+
|
|
612
727
|
export declare interface ILineChartProps {
|
|
613
|
-
chart:
|
|
728
|
+
chart: ILineChartDataInput;
|
|
614
729
|
table?: ReactNode;
|
|
615
730
|
headerComponent?: ReactNode;
|
|
616
731
|
subheaderComponent?: ReactNode;
|
|
@@ -632,8 +747,8 @@ export declare interface ILineChartStyling extends ICommonStyling {
|
|
|
632
747
|
}
|
|
633
748
|
|
|
634
749
|
export declare interface ILineChartTooltip extends ICommonTooltip {
|
|
635
|
-
hideSimulationName
|
|
636
|
-
scientificNotation
|
|
750
|
+
hideSimulationName?: boolean;
|
|
751
|
+
scientificNotation?: boolean;
|
|
637
752
|
}
|
|
638
753
|
|
|
639
754
|
export declare interface ILineInteractions extends ICommonInteractions {
|
|
@@ -649,6 +764,36 @@ export declare interface ILineRange {
|
|
|
649
764
|
[key: string]: ILineChartRange;
|
|
650
765
|
}
|
|
651
766
|
|
|
767
|
+
declare type ILooseBarAnnotation = DeepPartial<ICommonAnnotationsData> & Record<string, unknown> & {
|
|
768
|
+
annotationAxis?: string;
|
|
769
|
+
type?: string;
|
|
770
|
+
value?: number | string | null;
|
|
771
|
+
};
|
|
772
|
+
|
|
773
|
+
declare type ILooseBarAxis = DeepPartial<ICommonAxis<string>> & Record<string, unknown>;
|
|
774
|
+
|
|
775
|
+
declare type ILooseLineAnnotation = DeepPartial<ICommonAnnotations['annotationsData'] extends Array<infer T> ? T : never> & Record<string, unknown> & {
|
|
776
|
+
annotationAxis?: string;
|
|
777
|
+
type?: string;
|
|
778
|
+
value?: number | string | null;
|
|
779
|
+
xMin?: number | string | null;
|
|
780
|
+
xMax?: number | string | null;
|
|
781
|
+
yMin?: number | string | null;
|
|
782
|
+
yMax?: number | string | null;
|
|
783
|
+
xValue?: number | string | null;
|
|
784
|
+
yValue?: number | string | null;
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
declare type ILooseLineAxis = DeepPartial<ILineChartAxis<string>> & Record<string, unknown>;
|
|
788
|
+
|
|
789
|
+
declare type ILooseScatterAnnotation = DeepPartial<ICommonDataValue> & Record<string, unknown> & {
|
|
790
|
+
annotationAxis?: string;
|
|
791
|
+
type?: string;
|
|
792
|
+
value?: number | string | null;
|
|
793
|
+
};
|
|
794
|
+
|
|
795
|
+
declare type ILooseScatterAxis = DeepPartial<ICommonAxis<string>> & Record<string, unknown>;
|
|
796
|
+
|
|
652
797
|
/**
|
|
653
798
|
* Initialize the charts library with the provided configurations.
|
|
654
799
|
* This function will store the configuration options in a config object.
|
|
@@ -710,6 +855,8 @@ export declare type IPieLegendItemFilter = IChartLegendItemFilter;
|
|
|
710
855
|
export declare interface IPieOptions extends ICommonOptions {
|
|
711
856
|
graph?: IPieGraph;
|
|
712
857
|
legend?: IPieLegend;
|
|
858
|
+
axes?: unknown;
|
|
859
|
+
[key: string]: unknown;
|
|
713
860
|
}
|
|
714
861
|
|
|
715
862
|
export declare type IPiesDataLabelsOptions = IChartDataLabelsOptions;
|
|
@@ -725,13 +872,20 @@ export declare interface IScatterChartData extends ICommonData {
|
|
|
725
872
|
options: IScatterOptions;
|
|
726
873
|
}
|
|
727
874
|
|
|
875
|
+
export declare interface IScatterChartDataInput extends Omit<IScatterChartData, 'data' | 'options'> {
|
|
876
|
+
data?: DeepPartial<IScatterChartData['data']> & {
|
|
877
|
+
datasets?: Array<DeepPartial<IScatterChartDataset> | Record<string, unknown> | null>;
|
|
878
|
+
};
|
|
879
|
+
options?: IScatterOptionsInput;
|
|
880
|
+
}
|
|
881
|
+
|
|
728
882
|
export declare interface IScatterChartDataset extends ICommonDataset {
|
|
729
883
|
data: IScatterDataValue[];
|
|
730
884
|
hideLegend?: boolean;
|
|
731
885
|
}
|
|
732
886
|
|
|
733
887
|
export declare interface IScatterChartProps {
|
|
734
|
-
chart:
|
|
888
|
+
chart: IScatterChartDataInput;
|
|
735
889
|
testId?: string | null;
|
|
736
890
|
}
|
|
737
891
|
|
|
@@ -766,9 +920,31 @@ export declare interface IScatterOptions extends ICommonOptions {
|
|
|
766
920
|
legend?: IScatterLegend;
|
|
767
921
|
axes?: IScatterAxes;
|
|
768
922
|
additionalAxesOptions?: ICommonAdditionalAxesOptions;
|
|
769
|
-
direction
|
|
923
|
+
direction?: ChartDirection;
|
|
770
924
|
}
|
|
771
925
|
|
|
926
|
+
export declare type IScatterOptionsInput = DeepPartial<IScatterOptions> & {
|
|
927
|
+
title?: unknown;
|
|
928
|
+
direction?: string;
|
|
929
|
+
axes?: {
|
|
930
|
+
x?: ILooseScatterAxis[];
|
|
931
|
+
y?: ILooseScatterAxis[];
|
|
932
|
+
[key: string]: ILooseScatterAxis[] | undefined;
|
|
933
|
+
};
|
|
934
|
+
legend?: DeepPartial<IScatterLegend> & {
|
|
935
|
+
position?: string;
|
|
936
|
+
align?: string;
|
|
937
|
+
} & Record<string, unknown>;
|
|
938
|
+
chartStyling?: Record<string, unknown>;
|
|
939
|
+
interactions?: DeepPartial<ICommonOptions['interactions']> & {
|
|
940
|
+
enableZoom?: boolean;
|
|
941
|
+
enablePan?: boolean;
|
|
942
|
+
} & Record<string, unknown>;
|
|
943
|
+
annotations?: (DeepPartial<ICommonOptions['annotations']> & {
|
|
944
|
+
annotationsData?: ILooseScatterAnnotation[];
|
|
945
|
+
}) | null;
|
|
946
|
+
};
|
|
947
|
+
|
|
772
948
|
export declare interface IScatterTooltip {
|
|
773
949
|
enabled?: boolean;
|
|
774
950
|
tooltips?: boolean;
|
|
@@ -893,7 +1069,7 @@ export declare type TVerticalMarkerTick = {
|
|
|
893
1069
|
labelOffsetPx?: number;
|
|
894
1070
|
};
|
|
895
1071
|
|
|
896
|
-
export declare type UnusedParameter = unknown
|
|
1072
|
+
export declare type UnusedParameter = unknown;
|
|
897
1073
|
|
|
898
1074
|
export { }
|
|
899
1075
|
|
package/dist/index.js
CHANGED
|
@@ -18682,6 +18682,7 @@ var ChartType = /* @__PURE__ */ function(ChartType) {
|
|
|
18682
18682
|
ChartType["LINE"] = "line";
|
|
18683
18683
|
ChartType["BAR"] = "bar";
|
|
18684
18684
|
ChartType["PIE"] = "pie";
|
|
18685
|
+
ChartType["DOUGHNUT"] = "doughnut";
|
|
18685
18686
|
ChartType["SCATTER"] = "scatter";
|
|
18686
18687
|
return ChartType;
|
|
18687
18688
|
}({});
|
|
@@ -20051,6 +20052,21 @@ var TextLabelPosition = {
|
|
|
20051
20052
|
BOTTOM_RIGHT: "bottom-right"
|
|
20052
20053
|
};
|
|
20053
20054
|
//#endregion
|
|
20055
|
+
//#region src/components/common/helpers/input-normalizers.ts
|
|
20056
|
+
var normalizeTitle = (title) => {
|
|
20057
|
+
return typeof title === "string" || Array.isArray(title) ? title : "";
|
|
20058
|
+
};
|
|
20059
|
+
var normalizeCartesianDirection = (direction) => {
|
|
20060
|
+
return typeof direction === "string" && direction.toLowerCase() === "horizontal" ? "horizontal" : "vertical";
|
|
20061
|
+
};
|
|
20062
|
+
var normalizeChartDirection = (direction) => {
|
|
20063
|
+
return normalizeCartesianDirection(direction) === "horizontal" ? ChartDirection.HORIZONTAL : ChartDirection.VERTICAL;
|
|
20064
|
+
};
|
|
20065
|
+
var normalizeDragRange = (range) => ({
|
|
20066
|
+
x: Array.isArray(range?.x) && range.x.length >= 2 ? [range.x[0], range.x[1]] : void 0,
|
|
20067
|
+
y: Array.isArray(range?.y) && range.y.length >= 2 ? [range.y[0], range.y[1]] : void 0
|
|
20068
|
+
});
|
|
20069
|
+
//#endregion
|
|
20054
20070
|
//#region src/components/line-chart/line-chart-get-default-props.ts
|
|
20055
20071
|
var defaultAxis = (position) => ({
|
|
20056
20072
|
label: "",
|
|
@@ -20062,10 +20078,34 @@ var defaultAxis = (position) => ({
|
|
|
20062
20078
|
setSelectedUnit: () => {}
|
|
20063
20079
|
}
|
|
20064
20080
|
});
|
|
20065
|
-
var
|
|
20066
|
-
|
|
20067
|
-
|
|
20081
|
+
var normalizeUnit = (unit) => {
|
|
20082
|
+
if (!unit) return {
|
|
20083
|
+
options: [],
|
|
20084
|
+
selectedUnit: "",
|
|
20085
|
+
setSelectedUnit: () => {}
|
|
20086
|
+
};
|
|
20087
|
+
if (typeof unit === "string") return unit;
|
|
20088
|
+
return {
|
|
20089
|
+
options: unit.options ?? [],
|
|
20090
|
+
selectedUnit: unit.selectedUnit ?? "",
|
|
20091
|
+
setSelectedUnit: unit.setSelectedUnit ?? (() => {})
|
|
20092
|
+
};
|
|
20093
|
+
};
|
|
20094
|
+
var normalizeAxis = (axis, fallbackPosition) => ({
|
|
20095
|
+
...defaultAxis(fallbackPosition),
|
|
20096
|
+
...axis || {},
|
|
20097
|
+
position: axis?.position ?? fallbackPosition,
|
|
20098
|
+
color: axis?.color ?? "",
|
|
20099
|
+
unit: normalizeUnit(axis?.unit)
|
|
20068
20100
|
});
|
|
20101
|
+
var defaultAxes$2 = (axes) => {
|
|
20102
|
+
const xAxes = Array.isArray(axes?.x) ? axes.x : [];
|
|
20103
|
+
const yAxes = Array.isArray(axes?.y) ? axes.y : [];
|
|
20104
|
+
return {
|
|
20105
|
+
x: xAxes.length > 0 ? xAxes.map((axis, index) => normalizeAxis(axis, index % 2 === 0 ? "bottom" : "top")) : [defaultAxis("bottom")],
|
|
20106
|
+
y: yAxes.length > 0 ? yAxes.map((axis, index) => normalizeAxis(axis, index % 2 === 0 ? "left" : "right")) : [defaultAxis("left")]
|
|
20107
|
+
};
|
|
20108
|
+
};
|
|
20069
20109
|
var defaultAdditionalAxesOptions$2 = (options) => ({
|
|
20070
20110
|
chartScaleType: options?.chartScaleType || "linear",
|
|
20071
20111
|
reverse: options?.reverse || false,
|
|
@@ -20073,23 +20113,30 @@ var defaultAdditionalAxesOptions$2 = (options) => ({
|
|
|
20073
20113
|
stepSize: options?.stepSize,
|
|
20074
20114
|
suggestedMin: options?.suggestedMin,
|
|
20075
20115
|
suggestedMax: options?.suggestedMax,
|
|
20076
|
-
range: options?.range,
|
|
20116
|
+
range: options?.range ? Object.fromEntries(Object.entries(options.range).map(([key, value]) => [key, {
|
|
20117
|
+
min: value?.min ?? 0,
|
|
20118
|
+
max: value?.max ?? 0
|
|
20119
|
+
}])) : void 0,
|
|
20077
20120
|
autoAxisPadding: options?.autoAxisPadding ?? false
|
|
20078
20121
|
});
|
|
20079
|
-
var defaultChartStyling$3 = (options) =>
|
|
20080
|
-
|
|
20081
|
-
|
|
20082
|
-
|
|
20083
|
-
|
|
20084
|
-
|
|
20085
|
-
|
|
20086
|
-
|
|
20087
|
-
|
|
20088
|
-
|
|
20089
|
-
|
|
20090
|
-
|
|
20091
|
-
|
|
20092
|
-
|
|
20122
|
+
var defaultChartStyling$3 = (options) => {
|
|
20123
|
+
const layoutPadding = options?.layoutPadding;
|
|
20124
|
+
const normalizedLayoutPadding = typeof layoutPadding === "number" ? layoutPadding : {
|
|
20125
|
+
top: layoutPadding?.top ?? 0,
|
|
20126
|
+
bottom: layoutPadding?.bottom ?? 20,
|
|
20127
|
+
left: layoutPadding?.left ?? 0,
|
|
20128
|
+
right: layoutPadding?.right ?? 0
|
|
20129
|
+
};
|
|
20130
|
+
return {
|
|
20131
|
+
width: options?.width,
|
|
20132
|
+
height: options?.height,
|
|
20133
|
+
maintainAspectRatio: options?.maintainAspectRatio ?? false,
|
|
20134
|
+
staticChartHeight: options?.staticChartHeight ?? false,
|
|
20135
|
+
performanceMode: options?.performanceMode ?? true,
|
|
20136
|
+
squareAspectRatio: options?.squareAspectRatio ?? false,
|
|
20137
|
+
layoutPadding: normalizedLayoutPadding
|
|
20138
|
+
};
|
|
20139
|
+
};
|
|
20093
20140
|
var defaultTooltip$3 = (tooltip) => ({
|
|
20094
20141
|
tooltips: tooltip?.tooltips ?? true,
|
|
20095
20142
|
showLabelsInTooltips: tooltip?.showLabelsInTooltips ?? false,
|
|
@@ -20104,9 +20151,14 @@ var defaultGraph$3 = (graph) => ({
|
|
|
20104
20151
|
showMinorGridlines: graph?.showMinorGridlines ?? false
|
|
20105
20152
|
});
|
|
20106
20153
|
var defaultAnnotationsData$2 = (annotationsData) => {
|
|
20154
|
+
const asCallback = (fn) => typeof fn === "function" ? fn : void 0;
|
|
20107
20155
|
return annotationsData ? annotationsData.map((ann) => ({
|
|
20108
20156
|
...ann,
|
|
20109
|
-
display: ann?.display ?? true
|
|
20157
|
+
display: ann?.display ?? true,
|
|
20158
|
+
onDragStart: asCallback(ann?.onDragStart),
|
|
20159
|
+
onDrag: asCallback(ann?.onDrag),
|
|
20160
|
+
onDragEnd: asCallback(ann?.onDragEnd),
|
|
20161
|
+
dragRange: normalizeDragRange(ann?.dragRange)
|
|
20110
20162
|
})) : [];
|
|
20111
20163
|
};
|
|
20112
20164
|
var defaultAnnotations$2 = (annotations) => ({
|
|
@@ -20145,9 +20197,9 @@ var defaultLegend$3 = (legend) => ({
|
|
|
20145
20197
|
display: legend?.display ?? true,
|
|
20146
20198
|
position: legend?.position ?? Position.BottomLeft,
|
|
20147
20199
|
align: legend?.align ?? AlignOptions.Center,
|
|
20148
|
-
customLegend:
|
|
20149
|
-
customLegendPlugin: null,
|
|
20150
|
-
customLegendContainerID: ""
|
|
20200
|
+
customLegend: {
|
|
20201
|
+
customLegendPlugin: legend?.customLegend?.customLegendPlugin && typeof legend.customLegend.customLegendPlugin === "object" && "id" in legend.customLegend.customLegendPlugin ? legend.customLegend.customLegendPlugin : null,
|
|
20202
|
+
customLegendContainerID: typeof legend?.customLegend?.customLegendContainerID === "string" ? legend.customLegend.customLegendContainerID : ""
|
|
20151
20203
|
},
|
|
20152
20204
|
usePointStyle: legend?.usePointStyle ?? true
|
|
20153
20205
|
});
|
|
@@ -20160,9 +20212,9 @@ var defaultChartOptions$3 = (options) => ({
|
|
|
20160
20212
|
closeOnOutsideClick: options?.closeOnOutsideClick ?? false
|
|
20161
20213
|
});
|
|
20162
20214
|
var defaultInteractions$3 = (interactions) => ({
|
|
20163
|
-
onLegendClick: interactions?.onLegendClick,
|
|
20164
|
-
onHover: interactions?.onHover,
|
|
20165
|
-
onUnhover: interactions?.onUnhover,
|
|
20215
|
+
onLegendClick: typeof interactions?.onLegendClick === "function" ? interactions.onLegendClick : void 0,
|
|
20216
|
+
onHover: typeof interactions?.onHover === "function" ? interactions.onHover : void 0,
|
|
20217
|
+
onUnhover: typeof interactions?.onUnhover === "function" ? interactions.onUnhover : void 0,
|
|
20166
20218
|
onAnimationComplete: interactions?.onAnimationComplete
|
|
20167
20219
|
});
|
|
20168
20220
|
var defaultDragData$1 = (dragData) => ({
|
|
@@ -20175,6 +20227,28 @@ var defaultDragData$1 = (dragData) => ({
|
|
|
20175
20227
|
onDrag: dragData?.onDrag,
|
|
20176
20228
|
onDragEnd: dragData?.onDragEnd
|
|
20177
20229
|
});
|
|
20230
|
+
var normalizeLineChartOptions = (options = {}) => ({
|
|
20231
|
+
title: normalizeTitle(options?.title),
|
|
20232
|
+
scales: options?.scales ?? {
|
|
20233
|
+
x: {},
|
|
20234
|
+
y: {}
|
|
20235
|
+
},
|
|
20236
|
+
axes: defaultAxes$2(options?.axes),
|
|
20237
|
+
additionalAxesOptions: defaultAdditionalAxesOptions$2(options?.additionalAxesOptions),
|
|
20238
|
+
chartStyling: defaultChartStyling$3(options?.chartStyling),
|
|
20239
|
+
tooltip: defaultTooltip$3(options?.tooltip),
|
|
20240
|
+
graph: defaultGraph$3(options?.graph),
|
|
20241
|
+
annotations: defaultAnnotations$2(options?.annotations),
|
|
20242
|
+
legend: defaultLegend$3(options?.legend),
|
|
20243
|
+
chartOptions: defaultChartOptions$3(options?.chartOptions),
|
|
20244
|
+
interactions: defaultInteractions$3(options?.interactions),
|
|
20245
|
+
dragData: defaultDragData$1(options?.dragData),
|
|
20246
|
+
depthType: options?.depthType ?? {}
|
|
20247
|
+
});
|
|
20248
|
+
var normalizeLineDatasets = (datasets) => (datasets ?? []).map((dataset) => ({
|
|
20249
|
+
...dataset,
|
|
20250
|
+
data: dataset?.data ?? []
|
|
20251
|
+
}));
|
|
20178
20252
|
var getDefaultProps$3 = (props) => {
|
|
20179
20253
|
const chart = props?.chart || {};
|
|
20180
20254
|
const options = chart?.options || {};
|
|
@@ -20182,22 +20256,8 @@ var getDefaultProps$3 = (props) => {
|
|
|
20182
20256
|
persistenceId: chart?.persistenceId ?? "",
|
|
20183
20257
|
controlsPortalId: chart?.controlsPortalId ?? "",
|
|
20184
20258
|
testId: chart?.testId ?? void 0,
|
|
20185
|
-
data:
|
|
20186
|
-
options:
|
|
20187
|
-
title: options?.title ?? "",
|
|
20188
|
-
scales: options?.scales ?? {},
|
|
20189
|
-
axes: defaultAxes$2(options?.axes),
|
|
20190
|
-
additionalAxesOptions: defaultAdditionalAxesOptions$2(options?.additionalAxesOptions),
|
|
20191
|
-
chartStyling: defaultChartStyling$3(options?.chartStyling),
|
|
20192
|
-
tooltip: defaultTooltip$3(options?.tooltip),
|
|
20193
|
-
graph: defaultGraph$3(options?.graph),
|
|
20194
|
-
annotations: defaultAnnotations$2(options?.annotations),
|
|
20195
|
-
legend: defaultLegend$3(options?.legend),
|
|
20196
|
-
chartOptions: defaultChartOptions$3(options?.chartOptions),
|
|
20197
|
-
interactions: defaultInteractions$3(options?.interactions),
|
|
20198
|
-
dragData: defaultDragData$1(options?.dragData),
|
|
20199
|
-
depthType: options?.depthType ?? {}
|
|
20200
|
-
}
|
|
20259
|
+
data: { datasets: normalizeLineDatasets(chart?.data?.datasets) },
|
|
20260
|
+
options: normalizeLineChartOptions(options)
|
|
20201
20261
|
};
|
|
20202
20262
|
};
|
|
20203
20263
|
//#endregion
|
|
@@ -20537,6 +20597,7 @@ var getAxesDataFromMetasets = (generatedDatasets, scalesKeys, annotationsData) =
|
|
|
20537
20597
|
};
|
|
20538
20598
|
//#endregion
|
|
20539
20599
|
//#region src/components/line-chart/utils/axis-scales/axis-scales.ts
|
|
20600
|
+
var toScalesMap = (scales) => scales ?? {};
|
|
20540
20601
|
var shouldCalculate = (min, max) => !isNil(min) || !isNil(max);
|
|
20541
20602
|
/**
|
|
20542
20603
|
* Auto scales axis ranges (mix, max) if no explicit range is set
|
|
@@ -20546,7 +20607,7 @@ var shouldCalculate = (min, max) => !isNil(min) || !isNil(max);
|
|
|
20546
20607
|
*/
|
|
20547
20608
|
var autoScale = (options, state, generatedDatasets) => {
|
|
20548
20609
|
const { additionalAxesOptions, annotations: { annotationsData = [], controlAnnotation = false } = {} } = options || {};
|
|
20549
|
-
const scales = getLineChartScales(options, state)
|
|
20610
|
+
const scales = toScalesMap(getLineChartScales(options, state));
|
|
20550
20611
|
const datasets = controlAnnotation ? generatedDatasets.filter(({ isAnnotation }) => !isAnnotation) : generatedDatasets;
|
|
20551
20612
|
if (!additionalAxesOptions?.autoAxisPadding && !estimateDataSeriesHaveCloseValues(datasets)) return scales;
|
|
20552
20613
|
const scalesKeys = Object.keys(scales) ?? [];
|
|
@@ -20555,9 +20616,9 @@ var autoScale = (options, state, generatedDatasets) => {
|
|
|
20555
20616
|
const scale = scales[key];
|
|
20556
20617
|
const { min: propMin = void 0, max: propMax = void 0 } = scale;
|
|
20557
20618
|
const { min: suggestedMin, max: suggestedMax } = getSuggestedAxisRange({
|
|
20558
|
-
data: data[key],
|
|
20559
|
-
beginAtZero: additionalAxesOptions?.beginAtZero,
|
|
20560
|
-
autoAxisPadding: additionalAxesOptions?.autoAxisPadding
|
|
20619
|
+
data: (data[key] ?? []).filter((value) => typeof value === "number"),
|
|
20620
|
+
beginAtZero: additionalAxesOptions?.beginAtZero ?? false,
|
|
20621
|
+
autoAxisPadding: additionalAxesOptions?.autoAxisPadding ?? false
|
|
20561
20622
|
});
|
|
20562
20623
|
const res = { [key]: {
|
|
20563
20624
|
...scale,
|
|
@@ -20657,7 +20718,7 @@ var getLineChartToolTips = (options) => {
|
|
|
20657
20718
|
callbacks: {}
|
|
20658
20719
|
};
|
|
20659
20720
|
}
|
|
20660
|
-
const { scientificNotation } = options?.tooltip ?? {};
|
|
20721
|
+
const { scientificNotation = true } = options?.tooltip ?? {};
|
|
20661
20722
|
const getTooltipLabels = ({ xAxisID = "", yAxisID = "" }) => {
|
|
20662
20723
|
const xIndex = xAxisID?.length > 1 ? Number(xAxisID?.[1]) - 1 : 0;
|
|
20663
20724
|
const yIndex = yAxisID?.length > 1 ? Number(yAxisID?.[1]) - 1 : 0;
|
|
@@ -20682,7 +20743,7 @@ var getLineChartToolTips = (options) => {
|
|
|
20682
20743
|
return `${customFormatNumber$1(titleLabel === TooltipLabel.Y ? tooltipItem?.[0]?.parsed?.y : tooltipItem?.[0]?.parsed?.x, scientificNotation)} ${titleAxisLabel}`;
|
|
20683
20744
|
};
|
|
20684
20745
|
const labelCallback = (tooltipItem) => {
|
|
20685
|
-
const { showLabelsInTooltips } = options?.tooltip ?? {};
|
|
20746
|
+
const { showLabelsInTooltips = false } = options?.tooltip ?? {};
|
|
20686
20747
|
let label = tooltipItem?.dataset?.label || "";
|
|
20687
20748
|
const { valueLabel = "", valueAxisLabel = "" } = getTooltipLabels(tooltipItem?.dataset) ?? {};
|
|
20688
20749
|
const getTooltipItemValue = () => {
|
|
@@ -21185,6 +21246,9 @@ var getCalloutAnnotation = (refAnnotation, index) => {
|
|
|
21185
21246
|
const color = calloutCfg?.color ?? "hsl(60, 10.34482759%, 12.5%)";
|
|
21186
21247
|
const font = calloutCfg?.font ?? `12px "Roobert", "Noto Sans", sans-serif`;
|
|
21187
21248
|
const borderColor = calloutCfg?.borderColor ?? "transparent";
|
|
21249
|
+
const onCalloutDragStart = typeof calloutCfg?.onDragStart === "function" ? calloutCfg.onDragStart : void 0;
|
|
21250
|
+
const onCalloutDrag = typeof calloutCfg?.onDrag === "function" ? calloutCfg.onDrag : void 0;
|
|
21251
|
+
const onCalloutDragEnd = typeof calloutCfg?.onDragEnd === "function" ? calloutCfg.onDragEnd : void 0;
|
|
21188
21252
|
const strokeStyle = calloutCfg.strokeStyle ?? baseAnnotation.borderColor;
|
|
21189
21253
|
const lineWidth = typeof calloutCfg.lineWidth === "number" ? calloutCfg.lineWidth : 1;
|
|
21190
21254
|
const startOffset = typeof calloutCfg.startOffset === "number" ? calloutCfg.startOffset : 6;
|
|
@@ -21227,14 +21291,14 @@ var getCalloutAnnotation = (refAnnotation, index) => {
|
|
|
21227
21291
|
leave: ({ element }, { chart }) => {
|
|
21228
21292
|
return handleLabelLeave(element, chart, { enableDrag: true });
|
|
21229
21293
|
},
|
|
21230
|
-
onDragStart:
|
|
21231
|
-
return
|
|
21294
|
+
onDragStart: onCalloutDragStart ? () => (coords) => {
|
|
21295
|
+
return onCalloutDragStart(coords, refAnnotation);
|
|
21232
21296
|
} : void 0,
|
|
21233
|
-
onDrag:
|
|
21234
|
-
return
|
|
21297
|
+
onDrag: onCalloutDrag ? () => (coords) => {
|
|
21298
|
+
return onCalloutDrag(coords, refAnnotation);
|
|
21235
21299
|
} : void 0,
|
|
21236
|
-
onDragEnd:
|
|
21237
|
-
return
|
|
21300
|
+
onDragEnd: onCalloutDragEnd ? () => (coords) => {
|
|
21301
|
+
return onCalloutDragEnd(coords, refAnnotation);
|
|
21238
21302
|
} : void 0,
|
|
21239
21303
|
calloutConnector: {
|
|
21240
21304
|
enabled: true,
|
|
@@ -21580,8 +21644,9 @@ var useChartPlugins = ({ options, resetZoom }) => {
|
|
|
21580
21644
|
*/
|
|
21581
21645
|
var useToggleCustomLegendVisibility = (memoState, memoOptions) => {
|
|
21582
21646
|
useEffect(() => {
|
|
21583
|
-
|
|
21584
|
-
|
|
21647
|
+
const containerId = memoOptions?.legend?.customLegend?.customLegendContainerID;
|
|
21648
|
+
if (memoOptions?.legend?.customLegend?.customLegendPlugin && typeof containerId === "string") {
|
|
21649
|
+
const parent = document.getElementById(containerId);
|
|
21585
21650
|
if (parent !== null) parent.style.visibility = memoState.legendEnabled ? "visible" : "hidden";
|
|
21586
21651
|
}
|
|
21587
21652
|
}, [
|
|
@@ -22557,7 +22622,8 @@ var renderLegendItemSymbol = (dataset, chartType, index) => {
|
|
|
22557
22622
|
children: /* @__PURE__ */ jsx(TbSquareFilled, { color })
|
|
22558
22623
|
});
|
|
22559
22624
|
}
|
|
22560
|
-
case ChartType.PIE:
|
|
22625
|
+
case ChartType.PIE:
|
|
22626
|
+
case ChartType.DOUGHNUT: return /* @__PURE__ */ jsx("span", {
|
|
22561
22627
|
className: legend_module_default.legendItemPoint,
|
|
22562
22628
|
children: /* @__PURE__ */ jsx(Icon, { icon: /* @__PURE__ */ jsx(SvgCircle, {}) })
|
|
22563
22629
|
});
|
|
@@ -37217,7 +37283,7 @@ var getBarChartDataLabels = (options) => {
|
|
|
37217
37283
|
*/
|
|
37218
37284
|
var getBarChartToolTips = (options) => {
|
|
37219
37285
|
const getTooltipLabels = (dataset) => {
|
|
37220
|
-
const isDirectionVertical = isVertical(options.direction);
|
|
37286
|
+
const isDirectionVertical = isVertical(options.direction ?? "vertical");
|
|
37221
37287
|
const x = Array.isArray(options.axes?.x) ? options.axes.x : [];
|
|
37222
37288
|
const y = Array.isArray(options.axes?.y) ? options.axes.y : [];
|
|
37223
37289
|
const getAxisIndex = (axisID) => {
|
|
@@ -37335,8 +37401,8 @@ var bar_chart_module_default = {
|
|
|
37335
37401
|
//#endregion
|
|
37336
37402
|
//#region src/components/bar-chart/bar-chart-default-props.ts
|
|
37337
37403
|
var defaultAxes$1 = (axes) => ({
|
|
37338
|
-
x: axes?.x
|
|
37339
|
-
y: axes?.y
|
|
37404
|
+
x: axes?.x ?? [{}],
|
|
37405
|
+
y: axes?.y ?? [{}]
|
|
37340
37406
|
});
|
|
37341
37407
|
var defaultAdditionalAxesOptions$1 = (options) => ({
|
|
37342
37408
|
chartScaleType: options?.chartScaleType || "linear",
|
|
@@ -37368,9 +37434,14 @@ var defaultGraph$1 = (graph) => ({
|
|
|
37368
37434
|
showMinorGridlines: graph?.showMinorGridlines || false
|
|
37369
37435
|
});
|
|
37370
37436
|
var defaultAnnotationsData$1 = (annotationsData) => {
|
|
37437
|
+
const asCallback = (fn) => typeof fn === "function" ? fn : void 0;
|
|
37371
37438
|
return annotationsData ? annotationsData.map((ann) => ({
|
|
37372
37439
|
...ann,
|
|
37373
|
-
display: ann?.display ?? true
|
|
37440
|
+
display: ann?.display ?? true,
|
|
37441
|
+
onDragStart: asCallback(ann?.onDragStart),
|
|
37442
|
+
onDrag: asCallback(ann?.onDrag),
|
|
37443
|
+
onDragEnd: asCallback(ann?.onDragEnd),
|
|
37444
|
+
dragRange: normalizeDragRange(ann?.dragRange)
|
|
37374
37445
|
})) : [];
|
|
37375
37446
|
};
|
|
37376
37447
|
var defaultAnnotations$1 = (annotations) => ({
|
|
@@ -37382,9 +37453,9 @@ var defaultLegend$1 = (legend) => ({
|
|
|
37382
37453
|
display: legend?.display ?? true,
|
|
37383
37454
|
position: legend?.position || Position.TopLeft,
|
|
37384
37455
|
align: legend?.align || AlignOptions.Center,
|
|
37385
|
-
customLegend:
|
|
37386
|
-
customLegendPlugin: null,
|
|
37387
|
-
customLegendContainerID: ""
|
|
37456
|
+
customLegend: {
|
|
37457
|
+
customLegendPlugin: legend?.customLegend?.customLegendPlugin && typeof legend.customLegend.customLegendPlugin === "object" && "id" in legend.customLegend.customLegendPlugin ? legend.customLegend.customLegendPlugin : null,
|
|
37458
|
+
customLegendContainerID: typeof legend?.customLegend?.customLegendContainerID === "string" ? legend.customLegend.customLegendContainerID : ""
|
|
37388
37459
|
}
|
|
37389
37460
|
});
|
|
37390
37461
|
var defaultChartOptions$1 = (options) => ({
|
|
@@ -37392,9 +37463,9 @@ var defaultChartOptions$1 = (options) => ({
|
|
|
37392
37463
|
enablePan: options?.enablePan || false
|
|
37393
37464
|
});
|
|
37394
37465
|
var defaultInteractions$1 = (interactions) => ({
|
|
37395
|
-
onLegendClick: interactions?.onLegendClick,
|
|
37396
|
-
onHover: interactions?.onHover,
|
|
37397
|
-
onUnhover: interactions?.onUnhover
|
|
37466
|
+
onLegendClick: typeof interactions?.onLegendClick === "function" ? interactions.onLegendClick : void 0,
|
|
37467
|
+
onHover: typeof interactions?.onHover === "function" ? interactions.onHover : void 0,
|
|
37468
|
+
onUnhover: typeof interactions?.onUnhover === "function" ? interactions.onUnhover : void 0
|
|
37398
37469
|
});
|
|
37399
37470
|
var defaultDragData = (dragData) => ({
|
|
37400
37471
|
enableDragData: dragData?.enableDragData ?? false,
|
|
@@ -37406,27 +37477,35 @@ var defaultDragData = (dragData) => ({
|
|
|
37406
37477
|
onDrag: dragData?.onDrag,
|
|
37407
37478
|
onDragEnd: dragData?.onDragEnd
|
|
37408
37479
|
});
|
|
37480
|
+
var normalizeBarOptions = (options = {}) => ({
|
|
37481
|
+
title: normalizeTitle(options?.title),
|
|
37482
|
+
direction: normalizeCartesianDirection(options?.direction),
|
|
37483
|
+
axes: defaultAxes$1(options?.axes),
|
|
37484
|
+
additionalAxesOptions: defaultAdditionalAxesOptions$1(options?.additionalAxesOptions),
|
|
37485
|
+
chartStyling: defaultChartStyling$1(options?.chartStyling),
|
|
37486
|
+
tooltip: defaultTooltip$1(options?.tooltip),
|
|
37487
|
+
graph: defaultGraph$1(options?.graph),
|
|
37488
|
+
annotations: defaultAnnotations$1(options?.annotations),
|
|
37489
|
+
legend: defaultLegend$1(options?.legend),
|
|
37490
|
+
chartOptions: defaultChartOptions$1(options?.chartOptions),
|
|
37491
|
+
interactions: defaultInteractions$1(options?.interactions),
|
|
37492
|
+
dragData: defaultDragData(options?.dragData)
|
|
37493
|
+
});
|
|
37494
|
+
var normalizeBarDatasets = (datasets) => (datasets ?? []).map((dataset) => ({
|
|
37495
|
+
...dataset,
|
|
37496
|
+
data: dataset?.data ?? []
|
|
37497
|
+
}));
|
|
37409
37498
|
var getDefaultProps$1 = (props) => {
|
|
37410
37499
|
const chart = props?.chart || {};
|
|
37411
37500
|
const options = chart?.options || {};
|
|
37412
37501
|
return {
|
|
37413
37502
|
testId: chart?.testId ?? "",
|
|
37414
37503
|
controlsPortalId: chart?.controlsPortalId ?? "",
|
|
37415
|
-
data:
|
|
37416
|
-
|
|
37417
|
-
|
|
37418
|
-
|
|
37419
|
-
|
|
37420
|
-
additionalAxesOptions: defaultAdditionalAxesOptions$1(options?.additionalAxesOptions),
|
|
37421
|
-
chartStyling: defaultChartStyling$1(options?.chartStyling),
|
|
37422
|
-
tooltip: defaultTooltip$1(options?.tooltip),
|
|
37423
|
-
graph: defaultGraph$1(options?.graph),
|
|
37424
|
-
annotations: defaultAnnotations$1(options?.annotations),
|
|
37425
|
-
legend: defaultLegend$1(options?.legend),
|
|
37426
|
-
chartOptions: defaultChartOptions$1(options?.chartOptions),
|
|
37427
|
-
interactions: defaultInteractions$1(options?.interactions),
|
|
37428
|
-
dragData: defaultDragData(options?.dragData)
|
|
37429
|
-
}
|
|
37504
|
+
data: {
|
|
37505
|
+
labels: chart?.data?.labels ?? [],
|
|
37506
|
+
datasets: normalizeBarDatasets(chart?.data?.datasets)
|
|
37507
|
+
},
|
|
37508
|
+
options: normalizeBarOptions(options)
|
|
37430
37509
|
};
|
|
37431
37510
|
};
|
|
37432
37511
|
//#endregion
|
|
@@ -37661,25 +37740,29 @@ var useScatterChartConfig = (chart, chartRef) => {
|
|
|
37661
37740
|
};
|
|
37662
37741
|
//#endregion
|
|
37663
37742
|
//#region src/components/scatter-chart/scatter-chart-get-default-props.ts
|
|
37743
|
+
var normalizeGradientColors = (colors) => (colors ?? GRADIENT_COLORS).map((item, index) => ({
|
|
37744
|
+
offset: item.offset ?? index / Math.max((colors?.length ?? 2) - 1, 1),
|
|
37745
|
+
color: item.color ?? GRADIENT_COLORS[index % GRADIENT_COLORS.length].color
|
|
37746
|
+
}));
|
|
37664
37747
|
var defaultChartGradient = (gradient) => ({
|
|
37665
37748
|
display: gradient?.display ?? false,
|
|
37666
|
-
gradientColors: gradient?.gradientColors
|
|
37749
|
+
gradientColors: normalizeGradientColors(gradient?.gradientColors),
|
|
37667
37750
|
direction: gradient?.direction ?? GradientDirection.BottomLeftToTopRight
|
|
37668
37751
|
});
|
|
37669
37752
|
var defaultChartStyling = (styling) => ({
|
|
37670
37753
|
width: styling?.width ?? "auto",
|
|
37671
37754
|
height: styling?.height ?? "auto",
|
|
37672
|
-
maintainAspectRatio: styling?.maintainAspectRatio
|
|
37673
|
-
staticChartHeight: styling?.staticChartHeight
|
|
37755
|
+
maintainAspectRatio: styling?.maintainAspectRatio ?? false,
|
|
37756
|
+
staticChartHeight: styling?.staticChartHeight ?? false,
|
|
37674
37757
|
performanceMode: styling?.performanceMode ?? true,
|
|
37675
37758
|
gradient: defaultChartGradient(styling?.gradient)
|
|
37676
37759
|
});
|
|
37677
37760
|
var defaultTooltip = (tooltip) => ({
|
|
37678
37761
|
enabled: tooltip?.enabled ?? true,
|
|
37679
37762
|
tooltips: tooltip?.tooltips ?? true,
|
|
37680
|
-
showLabelsInTooltips: tooltip?.showLabelsInTooltips
|
|
37681
|
-
backgroundColor: tooltip?.backgroundColor
|
|
37682
|
-
displayColors: tooltip?.displayColors
|
|
37763
|
+
showLabelsInTooltips: tooltip?.showLabelsInTooltips ?? false,
|
|
37764
|
+
backgroundColor: tooltip?.backgroundColor ?? "#333",
|
|
37765
|
+
displayColors: tooltip?.displayColors ?? false,
|
|
37683
37766
|
scientificNotation: tooltip?.scientificNotation ?? true
|
|
37684
37767
|
});
|
|
37685
37768
|
var defaultGraph = (graph) => ({
|
|
@@ -37688,44 +37771,47 @@ var defaultGraph = (graph) => ({
|
|
|
37688
37771
|
});
|
|
37689
37772
|
var defaultLegend = (legend) => ({
|
|
37690
37773
|
display: legend?.display ?? true,
|
|
37691
|
-
useDataset: legend?.useDataset
|
|
37692
|
-
position: legend?.position
|
|
37693
|
-
align: legend?.align
|
|
37774
|
+
useDataset: legend?.useDataset ?? false,
|
|
37775
|
+
position: legend?.position ?? Position.BottomLeft,
|
|
37776
|
+
align: legend?.align ?? AlignOptions.Center
|
|
37694
37777
|
});
|
|
37695
37778
|
var defaultChartOptions = (options) => ({
|
|
37696
|
-
enableZoom: options?.enableZoom
|
|
37697
|
-
enablePan: options?.enablePan
|
|
37779
|
+
enableZoom: options?.enableZoom ?? false,
|
|
37780
|
+
enablePan: options?.enablePan ?? false
|
|
37698
37781
|
});
|
|
37699
37782
|
var defaultInteractions = (interactions) => ({
|
|
37700
|
-
onLegendClick: interactions?.onLegendClick,
|
|
37701
|
-
onHover: interactions?.onHover,
|
|
37702
|
-
onUnhover: interactions?.onUnhover,
|
|
37703
|
-
onAnimationComplete:
|
|
37783
|
+
onLegendClick: typeof interactions?.onLegendClick === "function" ? interactions.onLegendClick : void 0,
|
|
37784
|
+
onHover: typeof interactions?.onHover === "function" ? interactions.onHover : void 0,
|
|
37785
|
+
onUnhover: typeof interactions?.onUnhover === "function" ? interactions.onUnhover : void 0,
|
|
37786
|
+
onAnimationComplete: void 0
|
|
37704
37787
|
});
|
|
37705
|
-
var defaultChartData = (data) => {
|
|
37706
|
-
|
|
37707
|
-
|
|
37708
|
-
|
|
37709
|
-
|
|
37710
|
-
}
|
|
37711
|
-
|
|
37712
|
-
|
|
37713
|
-
|
|
37714
|
-
|
|
37715
|
-
|
|
37716
|
-
|
|
37788
|
+
var defaultChartData = (data) => ({
|
|
37789
|
+
labels: data?.labels ?? [],
|
|
37790
|
+
datasets: (data?.datasets ?? []).map((dataset) => ({
|
|
37791
|
+
...dataset,
|
|
37792
|
+
data: dataset?.data ?? []
|
|
37793
|
+
}))
|
|
37794
|
+
});
|
|
37795
|
+
var defaultAnnotationsData = (annotationsData) => (annotationsData ?? []).map((ann) => ({
|
|
37796
|
+
...ann,
|
|
37797
|
+
display: ann.display ?? true,
|
|
37798
|
+
onDragStart: typeof ann.onDragStart === "function" ? ann.onDragStart : void 0,
|
|
37799
|
+
onDrag: typeof ann.onDrag === "function" ? ann.onDrag : void 0,
|
|
37800
|
+
onDragEnd: typeof ann.onDragEnd === "function" ? ann.onDragEnd : void 0,
|
|
37801
|
+
dragRange: normalizeDragRange(ann.dragRange)
|
|
37802
|
+
}));
|
|
37717
37803
|
var defaultAnnotations = (annotations) => ({
|
|
37718
37804
|
showAnnotations: annotations?.showAnnotations ?? true,
|
|
37719
|
-
controlAnnotation: annotations?.controlAnnotation
|
|
37805
|
+
controlAnnotation: annotations?.controlAnnotation ?? false,
|
|
37720
37806
|
annotationsData: defaultAnnotationsData(annotations?.annotationsData)
|
|
37721
37807
|
});
|
|
37722
37808
|
var defaultAxes = (axes) => ({
|
|
37723
|
-
x: axes?.x
|
|
37724
|
-
y: axes?.y
|
|
37809
|
+
x: axes?.x ?? [{}],
|
|
37810
|
+
y: axes?.y ?? [{}]
|
|
37725
37811
|
});
|
|
37726
37812
|
var defaultAdditionalAxesOptions = (options) => ({
|
|
37727
|
-
reverse: options?.reverse
|
|
37728
|
-
stacked: options?.stacked
|
|
37813
|
+
reverse: options?.reverse ?? false,
|
|
37814
|
+
stacked: options?.stacked ?? false,
|
|
37729
37815
|
beginAtZero: options?.beginAtZero ?? true,
|
|
37730
37816
|
stepSize: options?.stepSize,
|
|
37731
37817
|
suggestedMin: options?.suggestedMin,
|
|
@@ -37733,25 +37819,26 @@ var defaultAdditionalAxesOptions = (options) => ({
|
|
|
37733
37819
|
min: options?.min,
|
|
37734
37820
|
max: options?.max
|
|
37735
37821
|
});
|
|
37822
|
+
var normalizeScatterOptions = (options = {}) => ({
|
|
37823
|
+
title: normalizeTitle(options?.title),
|
|
37824
|
+
axes: defaultAxes(options?.axes),
|
|
37825
|
+
additionalAxesOptions: defaultAdditionalAxesOptions(options?.additionalAxesOptions),
|
|
37826
|
+
direction: normalizeChartDirection(options?.direction),
|
|
37827
|
+
chartStyling: defaultChartStyling(options?.chartStyling),
|
|
37828
|
+
tooltip: defaultTooltip(options?.tooltip),
|
|
37829
|
+
graph: defaultGraph(options?.graph),
|
|
37830
|
+
legend: defaultLegend(options?.legend),
|
|
37831
|
+
annotations: defaultAnnotations(options?.annotations),
|
|
37832
|
+
chartOptions: defaultChartOptions(options?.chartOptions),
|
|
37833
|
+
interactions: defaultInteractions(options?.interactions)
|
|
37834
|
+
});
|
|
37736
37835
|
var getDefaultProps = (props) => {
|
|
37737
37836
|
const chart = props?.chart || {};
|
|
37738
37837
|
const options = chart?.options || {};
|
|
37739
37838
|
return {
|
|
37740
37839
|
testId: chart?.testId ?? null,
|
|
37741
37840
|
data: defaultChartData(chart?.data),
|
|
37742
|
-
options:
|
|
37743
|
-
title: options?.title || "",
|
|
37744
|
-
axes: defaultAxes(options?.axes),
|
|
37745
|
-
additionalAxesOptions: defaultAdditionalAxesOptions(options?.additionalAxesOptions),
|
|
37746
|
-
direction: options?.direction || ChartDirection.VERTICAL,
|
|
37747
|
-
chartStyling: defaultChartStyling(options?.chartStyling),
|
|
37748
|
-
tooltip: defaultTooltip(options?.tooltip),
|
|
37749
|
-
graph: defaultGraph(options?.graph),
|
|
37750
|
-
legend: defaultLegend(options?.legend),
|
|
37751
|
-
annotations: defaultAnnotations(options?.annotations),
|
|
37752
|
-
chartOptions: defaultChartOptions(options?.chartOptions),
|
|
37753
|
-
interactions: defaultInteractions(options?.interactions)
|
|
37754
|
-
}
|
|
37841
|
+
options: normalizeScatterOptions(options)
|
|
37755
37842
|
};
|
|
37756
37843
|
};
|
|
37757
37844
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oliasoft-open-source/charts-library",
|
|
3
|
-
"version": "5.9.0-beta-
|
|
3
|
+
"version": "5.9.0-beta-11",
|
|
4
4
|
"description": "React Chart Library (based on Chart.js and react-chart-js-2)",
|
|
5
5
|
"homepage": "https://gitlab.com/oliasoft-open-source/charts-library",
|
|
6
6
|
"bugs": {
|
|
@@ -94,14 +94,14 @@
|
|
|
94
94
|
},
|
|
95
95
|
"scripts": {
|
|
96
96
|
"build:package": "tsc && vite build",
|
|
97
|
-
"build:storybook": "storybook build --quiet --output-dir ./
|
|
97
|
+
"build:storybook": "storybook build --quiet --output-dir ./public",
|
|
98
98
|
"build": "pnpm build:package && pnpm build:storybook",
|
|
99
99
|
"dev:storybook": "storybook dev -p 6006",
|
|
100
100
|
"lint:check": "oxlint -c .oxlintrc.json .",
|
|
101
101
|
"lint:fix": "oxlint -c .oxlintrc.json --fix .",
|
|
102
102
|
"prettier:check": "prettier --check \"**/*.{ts,tsx,js,jsx,json,css,less}\"",
|
|
103
103
|
"prettier:fix": "prettier --write \"**/*.{ts,tsx,js,jsx,json,css,less}\"",
|
|
104
|
-
"preview:storybook": "pnpm exec http-server ./
|
|
104
|
+
"preview:storybook": "pnpm exec http-server ./public -o -p 9005 -c-1",
|
|
105
105
|
"test": "pnpm run prettier:check && pnpm run lint:check && pnpm run test:unit",
|
|
106
106
|
"test:unit": "vitest run",
|
|
107
107
|
"test:unit:coverage": "vitest run --coverage"
|