@oliasoft-open-source/charts-library 5.9.0-beta-10 → 5.9.0-beta-12

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 CHANGED
@@ -133,7 +133,9 @@ export declare interface IBarChartData extends ICommonData {
133
133
  }
134
134
 
135
135
  export declare interface IBarChartDataInput extends Omit<IBarChartData, 'options' | 'data'> {
136
- data?: DeepPartial<IBarChartData['data']>;
136
+ data?: Omit<DeepPartial<IBarChartData['data']>, 'datasets'> & {
137
+ datasets?: Array<DeepPartial<IBarChartDataset> | object | null>;
138
+ };
137
139
  options?: IBarOptionsInput;
138
140
  }
139
141
 
@@ -194,7 +196,34 @@ export declare interface IBarOptions extends ICommonOptions {
194
196
  dragData?: ICommonDragData;
195
197
  }
196
198
 
197
- export declare type IBarOptionsInput = DeepPartial<IBarOptions>;
199
+ export declare type IBarOptionsInput = Omit<DeepPartial<IBarOptions>, 'title' | 'direction' | 'axes' | 'legend' | 'chartStyling' | 'interactions' | 'annotations'> & {
200
+ [key: string]: unknown;
201
+ title?: unknown;
202
+ direction?: string;
203
+ axes?: {
204
+ x?: ILooseBarAxis[];
205
+ y?: ILooseBarAxis[];
206
+ [key: string]: ILooseBarAxis[] | undefined;
207
+ };
208
+ legend?: Omit<DeepPartial<IBarLegend>, 'position' | 'align'> & {
209
+ position?: string;
210
+ align?: string;
211
+ [key: string]: unknown;
212
+ };
213
+ chartStyling?: DeepPartial<IBarStyling> & {
214
+ hideControls?: boolean;
215
+ minHeight?: number | string;
216
+ [key: string]: unknown;
217
+ };
218
+ interactions?: DeepPartial<ICommonInteractions> & {
219
+ enableZoom?: boolean;
220
+ enablePan?: boolean;
221
+ [key: string]: unknown;
222
+ };
223
+ annotations?: (DeepPartial<ICommonAnnotations> & {
224
+ annotationsData?: ILooseBarAnnotation[];
225
+ }) | null;
226
+ };
198
227
 
199
228
  export declare interface IBarStyling extends ICommonStyling {
200
229
  squareAspectRatio?: boolean;
@@ -617,7 +646,18 @@ export declare interface ILineChartData extends ICommonData {
617
646
  }
618
647
 
619
648
  export declare interface ILineChartDataInput extends Omit<ILineChartData, 'data' | 'options'> {
620
- data?: DeepPartial<ILineChartData['data']>;
649
+ data?: Omit<DeepPartial<ILineChartData['data']>, 'datasets'> & {
650
+ datasets?: Array<(DeepPartial<ILineChartDataset> & {
651
+ lineTension?: number | string;
652
+ fill?: boolean | string | Record<string, unknown>;
653
+ pointStyle?: unknown;
654
+ showPoint?: boolean;
655
+ showPoints?: boolean;
656
+ lineHeight?: number;
657
+ data?: Array<DeepPartial<ICommonDataValue> | null>;
658
+ [key: string]: unknown;
659
+ }) | object | null>;
660
+ };
621
661
  options?: ILineChartOptionsInput;
622
662
  }
623
663
 
@@ -658,7 +698,41 @@ export declare interface ILineChartOptions extends ICommonOptions {
658
698
  depthType?: IDepthType | object;
659
699
  }
660
700
 
661
- export declare type ILineChartOptionsInput = DeepPartial<ILineChartOptions>;
701
+ export declare type ILineChartOptionsInput = Omit<DeepPartial<ILineChartOptions>, 'title' | 'axes' | 'legend' | 'chartStyling' | 'interactions' | 'graph' | 'annotations' | 'additionalAxesOptions'> & {
702
+ [key: string]: unknown;
703
+ title?: unknown;
704
+ direction?: string;
705
+ axes?: {
706
+ x?: ILooseLineAxis[];
707
+ y?: ILooseLineAxis[];
708
+ [key: string]: ILooseLineAxis[] | undefined;
709
+ };
710
+ legend?: Omit<DeepPartial<ILineLegend>, 'position' | 'align'> & {
711
+ position?: string;
712
+ align?: string;
713
+ [key: string]: unknown;
714
+ };
715
+ chartStyling?: DeepPartial<ILineChartStyling> & {
716
+ hideControls?: boolean;
717
+ minHeight?: number | string;
718
+ [key: string]: unknown;
719
+ };
720
+ interactions?: DeepPartial<ILineInteractions> & {
721
+ enableZoom?: boolean;
722
+ enablePan?: boolean;
723
+ [key: string]: unknown;
724
+ };
725
+ graph?: DeepPartial<ILineChartGraph> & {
726
+ tooltip?: unknown;
727
+ [key: string]: unknown;
728
+ };
729
+ annotations?: (DeepPartial<ICommonAnnotations> & {
730
+ annotationsData?: ILooseLineAnnotation[];
731
+ }) | null;
732
+ additionalAxesOptions?: DeepPartial<ILineChartAdditionalAxesOptions> & {
733
+ range?: ILineRange | ILineChartRange | Record<string, ILineChartRange | undefined>;
734
+ } & Record<string, unknown>;
735
+ };
662
736
 
663
737
  export declare interface ILineChartProps {
664
738
  chart: ILineChartDataInput;
@@ -668,8 +742,8 @@ export declare interface ILineChartProps {
668
742
  }
669
743
 
670
744
  export declare interface ILineChartRange {
671
- min: number;
672
- max: number;
745
+ min?: number;
746
+ max?: number;
673
747
  }
674
748
 
675
749
  export declare interface ILineChartStyling extends ICommonStyling {
@@ -700,6 +774,48 @@ export declare interface ILineRange {
700
774
  [key: string]: ILineChartRange;
701
775
  }
702
776
 
777
+ declare type ILooseBarAnnotation = DeepPartial<ICommonAnnotationsData> & {
778
+ [key: string]: unknown;
779
+ } & {
780
+ annotationAxis?: string;
781
+ type?: string;
782
+ value?: number | string | null;
783
+ };
784
+
785
+ declare type ILooseBarAxis = DeepPartial<ICommonAxis<string>> & {
786
+ [key: string]: unknown;
787
+ };
788
+
789
+ declare type ILooseLineAnnotation = DeepPartial<ICommonAnnotationsData> & {
790
+ [key: string]: unknown;
791
+ } & {
792
+ annotationAxis?: string;
793
+ type?: string;
794
+ value?: number | string | null;
795
+ xMin?: number | string | null;
796
+ xMax?: number | string | null;
797
+ yMin?: number | string | null;
798
+ yMax?: number | string | null;
799
+ xValue?: number | string | null;
800
+ yValue?: number | string | null;
801
+ };
802
+
803
+ declare type ILooseLineAxis = DeepPartial<ILineChartAxis<string>> & {
804
+ [key: string]: unknown;
805
+ };
806
+
807
+ declare type ILooseScatterAnnotation = DeepPartial<ICommonAnnotationsData> & {
808
+ [key: string]: unknown;
809
+ } & {
810
+ annotationAxis?: string;
811
+ type?: string;
812
+ value?: number | string | null;
813
+ };
814
+
815
+ declare type ILooseScatterAxis = DeepPartial<ICommonAxis<string>> & {
816
+ [key: string]: unknown;
817
+ };
818
+
703
819
  /**
704
820
  * Initialize the charts library with the provided configurations.
705
821
  * This function will store the configuration options in a config object.
@@ -761,6 +877,8 @@ export declare type IPieLegendItemFilter = IChartLegendItemFilter;
761
877
  export declare interface IPieOptions extends ICommonOptions {
762
878
  graph?: IPieGraph;
763
879
  legend?: IPieLegend;
880
+ axes?: unknown;
881
+ [key: string]: unknown;
764
882
  }
765
883
 
766
884
  export declare type IPiesDataLabelsOptions = IChartDataLabelsOptions;
@@ -777,7 +895,9 @@ export declare interface IScatterChartData extends ICommonData {
777
895
  }
778
896
 
779
897
  export declare interface IScatterChartDataInput extends Omit<IScatterChartData, 'data' | 'options'> {
780
- data?: DeepPartial<IScatterChartData['data']>;
898
+ data?: Omit<DeepPartial<IScatterChartData['data']>, 'datasets'> & {
899
+ datasets?: Array<DeepPartial<IScatterChartDataset> | object | null>;
900
+ };
781
901
  options?: IScatterOptionsInput;
782
902
  }
783
903
 
@@ -825,7 +945,32 @@ export declare interface IScatterOptions extends ICommonOptions {
825
945
  direction?: ChartDirection;
826
946
  }
827
947
 
828
- export declare type IScatterOptionsInput = DeepPartial<IScatterOptions>;
948
+ export declare type IScatterOptionsInput = Omit<DeepPartial<IScatterOptions>, 'title' | 'direction' | 'axes' | 'legend' | 'chartStyling' | 'interactions' | 'annotations'> & {
949
+ [key: string]: unknown;
950
+ title?: unknown;
951
+ direction?: string;
952
+ axes?: {
953
+ x?: ILooseScatterAxis[];
954
+ y?: ILooseScatterAxis[];
955
+ [key: string]: ILooseScatterAxis[] | undefined;
956
+ };
957
+ legend?: Omit<DeepPartial<IScatterLegend>, 'position' | 'align'> & {
958
+ position?: string;
959
+ align?: string;
960
+ [key: string]: unknown;
961
+ };
962
+ chartStyling?: {
963
+ [key: string]: unknown;
964
+ };
965
+ interactions?: DeepPartial<ICommonOptions['interactions']> & {
966
+ enableZoom?: boolean;
967
+ enablePan?: boolean;
968
+ [key: string]: unknown;
969
+ };
970
+ annotations?: (DeepPartial<ICommonAnnotations> & {
971
+ annotationsData?: ILooseScatterAnnotation[];
972
+ }) | null;
973
+ };
829
974
 
830
975
  export declare interface IScatterTooltip {
831
976
  enabled?: boolean;
@@ -956,22 +1101,6 @@ export declare type UnusedParameter = unknown;
956
1101
  export { }
957
1102
 
958
1103
 
959
- declare module 'chart.js' {
960
- interface PluginOptionsByType<TType extends ChartType> {
961
- annotationDraggerPlugin?: AnnotationDraggerPluginOptions;
962
- }
963
- }
964
-
965
-
966
- declare module 'chart.js' {
967
- interface PluginOptionsByType<TType extends ChartType> {
968
- calloutConnectorPlugin?: {
969
- enableCalloutAnnotation?: boolean;
970
- };
971
- }
972
- }
973
-
974
-
975
1104
  /**
976
1105
  * Vertical Markers Plugin
977
1106
  *
@@ -1023,3 +1152,19 @@ declare module 'chart.js' {
1023
1152
  } | TVerticalMarkersOptions;
1024
1153
  }
1025
1154
  }
1155
+
1156
+
1157
+ declare module 'chart.js' {
1158
+ interface PluginOptionsByType<TType extends ChartType> {
1159
+ annotationDraggerPlugin?: AnnotationDraggerPluginOptions;
1160
+ }
1161
+ }
1162
+
1163
+
1164
+ declare module 'chart.js' {
1165
+ interface PluginOptionsByType<TType extends ChartType> {
1166
+ calloutConnectorPlugin?: {
1167
+ enableCalloutAnnotation?: boolean;
1168
+ };
1169
+ }
1170
+ }
package/dist/index.js CHANGED
@@ -20052,6 +20052,27 @@ var TextLabelPosition = {
20052
20052
  BOTTOM_RIGHT: "bottom-right"
20053
20053
  };
20054
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 normalizeLegendPosition = (position, fallback) => {
20066
+ return Object.values(Position).includes(String(position)) ? position : fallback;
20067
+ };
20068
+ var normalizeLegendAlign = (align, fallback) => {
20069
+ return Object.values(AlignOptions).includes(String(align)) ? align : fallback;
20070
+ };
20071
+ var normalizeDragRange = (range) => ({
20072
+ x: Array.isArray(range?.x) && range.x.length >= 2 ? [range.x[0], range.x[1]] : void 0,
20073
+ y: Array.isArray(range?.y) && range.y.length >= 2 ? [range.y[0], range.y[1]] : void 0
20074
+ });
20075
+ //#endregion
20055
20076
  //#region src/components/line-chart/line-chart-get-default-props.ts
20056
20077
  var defaultAxis = (position) => ({
20057
20078
  label: "",
@@ -20076,10 +20097,13 @@ var normalizeUnit = (unit) => {
20076
20097
  setSelectedUnit: unit.setSelectedUnit ?? (() => {})
20077
20098
  };
20078
20099
  };
20100
+ var normalizeAxisPosition = (position, fallbackPosition) => {
20101
+ return typeof position === "string" && (fallbackPosition === "bottom" || fallbackPosition === "top" ? ["bottom", "top"] : ["left", "right"]).includes(position) ? position : fallbackPosition;
20102
+ };
20079
20103
  var normalizeAxis = (axis, fallbackPosition) => ({
20080
20104
  ...defaultAxis(fallbackPosition),
20081
20105
  ...axis || {},
20082
- position: axis?.position ?? fallbackPosition,
20106
+ position: normalizeAxisPosition(axis?.position, fallbackPosition),
20083
20107
  color: axis?.color ?? "",
20084
20108
  unit: normalizeUnit(axis?.unit)
20085
20109
  });
@@ -20136,10 +20160,6 @@ var defaultGraph$3 = (graph) => ({
20136
20160
  showMinorGridlines: graph?.showMinorGridlines ?? false
20137
20161
  });
20138
20162
  var defaultAnnotationsData$2 = (annotationsData) => {
20139
- const normalizeDragRange = (range) => ({
20140
- x: Array.isArray(range?.x) && range.x.length >= 2 ? [range.x[0], range.x[1]] : void 0,
20141
- y: Array.isArray(range?.y) && range.y.length >= 2 ? [range.y[0], range.y[1]] : void 0
20142
- });
20143
20163
  const asCallback = (fn) => typeof fn === "function" ? fn : void 0;
20144
20164
  return annotationsData ? annotationsData.map((ann) => ({
20145
20165
  ...ann,
@@ -20184,8 +20204,8 @@ var defaultAnnotations$2 = (annotations) => ({
20184
20204
  });
20185
20205
  var defaultLegend$3 = (legend) => ({
20186
20206
  display: legend?.display ?? true,
20187
- position: legend?.position ?? Position.BottomLeft,
20188
- align: legend?.align ?? AlignOptions.Center,
20207
+ position: normalizeLegendPosition(legend?.position, Position.BottomLeft),
20208
+ align: normalizeLegendAlign(legend?.align, AlignOptions.Center),
20189
20209
  customLegend: {
20190
20210
  customLegendPlugin: legend?.customLegend?.customLegendPlugin && typeof legend.customLegend.customLegendPlugin === "object" && "id" in legend.customLegend.customLegendPlugin ? legend.customLegend.customLegendPlugin : null,
20191
20211
  customLegendContainerID: typeof legend?.customLegend?.customLegendContainerID === "string" ? legend.customLegend.customLegendContainerID : ""
@@ -20217,7 +20237,7 @@ var defaultDragData$1 = (dragData) => ({
20217
20237
  onDragEnd: dragData?.onDragEnd
20218
20238
  });
20219
20239
  var normalizeLineChartOptions = (options = {}) => ({
20220
- title: options?.title ?? "",
20240
+ title: normalizeTitle(options?.title),
20221
20241
  scales: options?.scales ?? {
20222
20242
  x: {},
20223
20243
  y: {}
@@ -20234,10 +20254,13 @@ var normalizeLineChartOptions = (options = {}) => ({
20234
20254
  dragData: defaultDragData$1(options?.dragData),
20235
20255
  depthType: options?.depthType ?? {}
20236
20256
  });
20237
- var normalizeLineDatasets = (datasets) => (datasets ?? []).map((dataset) => ({
20238
- ...dataset,
20239
- data: dataset?.data ?? []
20240
- }));
20257
+ var normalizeLineDatasets = (datasets) => (datasets ?? []).map((dataset) => {
20258
+ const normalizedDataset = dataset && typeof dataset === "object" ? dataset : {};
20259
+ return {
20260
+ ...normalizedDataset,
20261
+ data: Array.isArray(normalizedDataset.data) ? normalizedDataset.data : []
20262
+ };
20263
+ });
20241
20264
  var getDefaultProps$3 = (props) => {
20242
20265
  const chart = props?.chart || {};
20243
20266
  const options = chart?.options || {};
@@ -37423,10 +37446,6 @@ var defaultGraph$1 = (graph) => ({
37423
37446
  showMinorGridlines: graph?.showMinorGridlines || false
37424
37447
  });
37425
37448
  var defaultAnnotationsData$1 = (annotationsData) => {
37426
- const normalizeDragRange = (range) => ({
37427
- x: Array.isArray(range?.x) && range.x.length >= 2 ? [range.x[0], range.x[1]] : void 0,
37428
- y: Array.isArray(range?.y) && range.y.length >= 2 ? [range.y[0], range.y[1]] : void 0
37429
- });
37430
37449
  const asCallback = (fn) => typeof fn === "function" ? fn : void 0;
37431
37450
  return annotationsData ? annotationsData.map((ann) => ({
37432
37451
  ...ann,
@@ -37444,8 +37463,8 @@ var defaultAnnotations$1 = (annotations) => ({
37444
37463
  });
37445
37464
  var defaultLegend$1 = (legend) => ({
37446
37465
  display: legend?.display ?? true,
37447
- position: legend?.position || Position.TopLeft,
37448
- align: legend?.align || AlignOptions.Center,
37466
+ position: normalizeLegendPosition(legend?.position, Position.TopLeft),
37467
+ align: normalizeLegendAlign(legend?.align, AlignOptions.Center),
37449
37468
  customLegend: {
37450
37469
  customLegendPlugin: legend?.customLegend?.customLegendPlugin && typeof legend.customLegend.customLegendPlugin === "object" && "id" in legend.customLegend.customLegendPlugin ? legend.customLegend.customLegendPlugin : null,
37451
37470
  customLegendContainerID: typeof legend?.customLegend?.customLegendContainerID === "string" ? legend.customLegend.customLegendContainerID : ""
@@ -37471,8 +37490,8 @@ var defaultDragData = (dragData) => ({
37471
37490
  onDragEnd: dragData?.onDragEnd
37472
37491
  });
37473
37492
  var normalizeBarOptions = (options = {}) => ({
37474
- title: options?.title || "",
37475
- direction: options?.direction || "vertical",
37493
+ title: normalizeTitle(options?.title),
37494
+ direction: normalizeCartesianDirection(options?.direction),
37476
37495
  axes: defaultAxes$1(options?.axes),
37477
37496
  additionalAxesOptions: defaultAdditionalAxesOptions$1(options?.additionalAxesOptions),
37478
37497
  chartStyling: defaultChartStyling$1(options?.chartStyling),
@@ -37484,10 +37503,13 @@ var normalizeBarOptions = (options = {}) => ({
37484
37503
  interactions: defaultInteractions$1(options?.interactions),
37485
37504
  dragData: defaultDragData(options?.dragData)
37486
37505
  });
37487
- var normalizeBarDatasets = (datasets) => (datasets ?? []).map((dataset) => ({
37488
- ...dataset,
37489
- data: dataset?.data ?? []
37490
- }));
37506
+ var normalizeBarDatasets = (datasets) => (datasets ?? []).map((dataset) => {
37507
+ const normalizedDataset = dataset && typeof dataset === "object" ? dataset : {};
37508
+ return {
37509
+ ...normalizedDataset,
37510
+ data: Array.isArray(normalizedDataset.data) ? normalizedDataset.data : []
37511
+ };
37512
+ });
37491
37513
  var getDefaultProps$1 = (props) => {
37492
37514
  const chart = props?.chart || {};
37493
37515
  const options = chart?.options || {};
@@ -37765,8 +37787,8 @@ var defaultGraph = (graph) => ({
37765
37787
  var defaultLegend = (legend) => ({
37766
37788
  display: legend?.display ?? true,
37767
37789
  useDataset: legend?.useDataset ?? false,
37768
- position: legend?.position ?? Position.BottomLeft,
37769
- align: legend?.align ?? AlignOptions.Center
37790
+ position: normalizeLegendPosition(legend?.position, Position.BottomLeft),
37791
+ align: normalizeLegendAlign(legend?.align, AlignOptions.Center)
37770
37792
  });
37771
37793
  var defaultChartOptions = (options) => ({
37772
37794
  enableZoom: options?.enableZoom ?? false,
@@ -37780,14 +37802,13 @@ var defaultInteractions = (interactions) => ({
37780
37802
  });
37781
37803
  var defaultChartData = (data) => ({
37782
37804
  labels: data?.labels ?? [],
37783
- datasets: (data?.datasets ?? []).map((dataset) => ({
37784
- ...dataset,
37785
- data: dataset?.data ?? []
37786
- }))
37787
- });
37788
- var normalizeDragRange = (range) => ({
37789
- x: Array.isArray(range?.x) && range.x.length >= 2 ? [range.x[0], range.x[1]] : void 0,
37790
- y: Array.isArray(range?.y) && range.y.length >= 2 ? [range.y[0], range.y[1]] : void 0
37805
+ datasets: (data?.datasets ?? []).map((dataset) => {
37806
+ const normalizedDataset = dataset && typeof dataset === "object" ? dataset : {};
37807
+ return {
37808
+ ...normalizedDataset,
37809
+ data: Array.isArray(normalizedDataset.data) ? normalizedDataset.data : []
37810
+ };
37811
+ })
37791
37812
  });
37792
37813
  var defaultAnnotationsData = (annotationsData) => (annotationsData ?? []).map((ann) => ({
37793
37814
  ...ann,
@@ -37817,10 +37838,10 @@ var defaultAdditionalAxesOptions = (options) => ({
37817
37838
  max: options?.max
37818
37839
  });
37819
37840
  var normalizeScatterOptions = (options = {}) => ({
37820
- title: options?.title ?? "",
37841
+ title: normalizeTitle(options?.title),
37821
37842
  axes: defaultAxes(options?.axes),
37822
37843
  additionalAxesOptions: defaultAdditionalAxesOptions(options?.additionalAxesOptions),
37823
- direction: options?.direction ?? ChartDirection.VERTICAL,
37844
+ direction: normalizeChartDirection(options?.direction),
37824
37845
  chartStyling: defaultChartStyling(options?.chartStyling),
37825
37846
  tooltip: defaultTooltip(options?.tooltip),
37826
37847
  graph: defaultGraph(options?.graph),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/charts-library",
3
- "version": "5.9.0-beta-10",
3
+ "version": "5.9.0-beta-12",
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": {