@oliasoft-open-source/charts-library 4.7.3-beta-3 → 4.7.4

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.js CHANGED
@@ -25281,15 +25281,15 @@ const getLineChartScales = (options, state) => {
25281
25281
  };
25282
25282
  const estimateDataSeriesHaveCloseValues = (generatedDatasets) => {
25283
25283
  var _a2;
25284
- if (!Array.isArray(generatedDatasets) || !generatedDatasets.length) {
25284
+ if (!Array.isArray(generatedDatasets) || !(generatedDatasets == null ? void 0 : generatedDatasets.length)) {
25285
25285
  return false;
25286
25286
  }
25287
- const axesFirstLast = generatedDatasets.reduce((acc, dataset) => {
25287
+ const axesFirstLast = generatedDatasets == null ? void 0 : generatedDatasets.reduce((acc, dataset) => {
25288
25288
  var _a3, _b2, _c2, _d2;
25289
25289
  const xAxisId = (dataset == null ? void 0 : dataset.xAxisID) ?? "defaultX";
25290
25290
  const yAxisId = (dataset == null ? void 0 : dataset.yAxisID) ?? "defaultY";
25291
25291
  const data = (dataset == null ? void 0 : dataset.data) ?? [];
25292
- if (data && data.length) {
25292
+ if (data && (data == null ? void 0 : data.length)) {
25293
25293
  const { x: xFirstCurrent, y: yFirstCurrent } = (data == null ? void 0 : data[0]) ?? {};
25294
25294
  const { x: xLastCurrent = 0, y: yLastCurrent = 0 } = (data == null ? void 0 : data.at(-1)) ?? {};
25295
25295
  const xFirstAcc = ((_a3 = acc == null ? void 0 : acc[xAxisId]) == null ? void 0 : _a3.xFirst) ?? xFirstCurrent;
@@ -25334,7 +25334,7 @@ const getSuggestedAxisRange = ({
25334
25334
  );
25335
25335
  const isNegative = Math.sign(dataMin) === -1 || Math.sign(dataMax) === -1;
25336
25336
  const isCloseToZeroWithTolerance = isCloseTo(dataMin, 0, { absoluteDiff: MAX_DECIMAL_DIFF }) && isCloseTo(dataMax, 0, { absoluteDiff: MAX_DECIMAL_DIFF });
25337
- if (!data.length || isCloseToZeroWithTolerance) {
25337
+ if (!(data == null ? void 0 : data.length) || isCloseToZeroWithTolerance) {
25338
25338
  return defaultRange;
25339
25339
  }
25340
25340
  if (isCloseTo(dataMin, dataMax, { absoluteDiff: MAX_DECIMAL_DIFF })) {
@@ -25859,7 +25859,7 @@ const useLegend = () => {
25859
25859
  return context;
25860
25860
  };
25861
25861
  const useLegendState = ({ chartRef, options }) => {
25862
- const { state, dispatch } = useLegend();
25862
+ const { state, dispatch } = useLegend() ?? {};
25863
25863
  const {
25864
25864
  annotations,
25865
25865
  interactions: { onLegendClick },
@@ -25868,16 +25868,16 @@ const useLegendState = ({ chartRef, options }) => {
25868
25868
  const legendClick = useCallback(
25869
25869
  (_2, legendItem2) => {
25870
25870
  var _a2;
25871
- const { datasetIndex = -1 } = legendItem2;
25871
+ const { datasetIndex = -1 } = legendItem2 ?? {};
25872
25872
  let annotationIndex = null;
25873
25873
  const chartInstance = chartRef == null ? void 0 : chartRef.current;
25874
25874
  const datasets = ((_a2 = chartInstance == null ? void 0 : chartInstance.data) == null ? void 0 : _a2.datasets) ?? [];
25875
- const dataset = datasets[datasetIndex] ?? {};
25875
+ const dataset = (datasets == null ? void 0 : datasets[datasetIndex]) ?? {};
25876
25876
  if ((annotations == null ? void 0 : annotations.controlAnnotation) && (dataset == null ? void 0 : dataset.isAnnotation)) {
25877
- annotationIndex = dataset.annotationIndex ?? null;
25877
+ annotationIndex = (dataset == null ? void 0 : dataset.annotationIndex) ?? null;
25878
25878
  }
25879
25879
  if (onLegendClick) {
25880
- const legendState = legendItem2.hidden ?? false;
25880
+ const legendState = (legendItem2 == null ? void 0 : legendItem2.hidden) ?? false;
25881
25881
  onLegendClick(legendItem2 == null ? void 0 : legendItem2.text, legendState);
25882
25882
  }
25883
25883
  dispatch({
@@ -25912,7 +25912,7 @@ const useLegendState = ({ chartRef, options }) => {
25912
25912
  );
25913
25913
  return {
25914
25914
  legendClick,
25915
- annotation: state.annotation,
25915
+ annotation: state == null ? void 0 : state.annotation,
25916
25916
  legend: legend2,
25917
25917
  customLegendPlugin
25918
25918
  };
@@ -25964,9 +25964,9 @@ const useChartOptions = ({
25964
25964
  dispatch,
25965
25965
  generatedDatasets
25966
25966
  });
25967
- const { legend: legend2, customLegendPlugin } = useLegendState({ chartRef, options });
25968
- const { state: legendState } = useLegend();
25969
- const { annotation: annotation2 } = legendState;
25967
+ const { legend: legend2, customLegendPlugin } = useLegendState({ chartRef, options }) ?? {};
25968
+ const { state: legendState } = useLegend() ?? {};
25969
+ const { annotation: annotation2 } = legendState ?? {};
25970
25970
  const datalabels = getLineChartDataLabels(options);
25971
25971
  const tooltip = getLineChartToolTips(options);
25972
25972
  const scales = useMemo(
@@ -26006,7 +26006,7 @@ const useChartOptions = ({
26006
26006
  const plugins = {
26007
26007
  datalabels,
26008
26008
  annotationDraggerPlugin: {
26009
- enabled: state.enableDragAnnotation
26009
+ enabled: state == null ? void 0 : state.enableDragAnnotation
26010
26010
  },
26011
26011
  annotation: toAnnotationObject(annotation2),
26012
26012
  zoom: { pan: panOptions, zoom: zoomOptions },
@@ -26030,32 +26030,35 @@ const useChartOptions = ({
26030
26030
  ...dragData
26031
26031
  };
26032
26032
  return useMemo(
26033
- () => ({
26034
- layout: {
26035
- padding: layoutPadding
26036
- },
26037
- onHover: onHover(hoveredPoint, setHoveredPoint),
26038
- maintainAspectRatio: options.chartStyling.maintainAspectRatio,
26039
- aspectRatio: options.chartStyling.squareAspectRatio ? 1 : 0,
26040
- animation: options.chartStyling.performanceMode ? false : {
26041
- duration: ANIMATION_DURATION.FAST,
26042
- onComplete: onAnimationComplete
26043
- },
26044
- hover: {
26045
- mode: ChartHoverMode.Nearest,
26046
- intersect: true
26047
- },
26048
- elements: {
26049
- line: {
26050
- pointStyle: PointStyle.Circle,
26051
- showLine: lineEnabled,
26052
- tension: 0
26053
- }
26054
- },
26055
- scales,
26056
- plugins,
26057
- events: Object.values(Events)
26058
- }),
26033
+ () => {
26034
+ var _a2, _b2, _c2;
26035
+ return {
26036
+ layout: {
26037
+ padding: layoutPadding
26038
+ },
26039
+ onHover: onHover(hoveredPoint, setHoveredPoint),
26040
+ maintainAspectRatio: (_a2 = options == null ? void 0 : options.chartStyling) == null ? void 0 : _a2.maintainAspectRatio,
26041
+ aspectRatio: ((_b2 = options == null ? void 0 : options.chartStyling) == null ? void 0 : _b2.squareAspectRatio) ? 1 : 0,
26042
+ animation: ((_c2 = options == null ? void 0 : options.chartStyling) == null ? void 0 : _c2.performanceMode) ? false : {
26043
+ duration: ANIMATION_DURATION.FAST,
26044
+ onComplete: onAnimationComplete
26045
+ },
26046
+ hover: {
26047
+ mode: ChartHoverMode.Nearest,
26048
+ intersect: true
26049
+ },
26050
+ elements: {
26051
+ line: {
26052
+ pointStyle: PointStyle.Circle,
26053
+ showLine: lineEnabled,
26054
+ tension: 0
26055
+ }
26056
+ },
26057
+ scales,
26058
+ plugins,
26059
+ events: Object.values(Events)
26060
+ };
26061
+ },
26059
26062
  [state, options, chartRef]
26060
26063
  );
26061
26064
  };
@@ -26811,7 +26814,7 @@ const config = {
26811
26814
  [INIT_KEYS.TRANSLATIONS]: getTranslations(),
26812
26815
  [INIT_KEYS.LANGUAGE_KEY]: "en"
26813
26816
  };
26814
- const getConfig = (key = "") => key ? config[key] : config;
26817
+ const getConfig = (key = "") => key ? config == null ? void 0 : config[key] : config;
26815
26818
  const setConfig = (key, newValue) => {
26816
26819
  config[key] = newValue;
26817
26820
  };
@@ -27263,7 +27266,7 @@ const LineChart = (props) => {
27263
27266
  var _a2, _b2;
27264
27267
  setDefaultTheme();
27265
27268
  const chartRef = useRef(null);
27266
- const { table: table2 } = props;
27269
+ const { table: table2 } = props ?? {};
27267
27270
  const { translations, languageKey } = getConfig();
27268
27271
  const chart2 = getDefaultProps$3(props);
27269
27272
  const {
@@ -27273,7 +27276,7 @@ const LineChart = (props) => {
27273
27276
  persistenceId,
27274
27277
  controlsPortalId
27275
27278
  } = chart2;
27276
- const { annotations, axes, chartStyling, graph } = options;
27279
+ const { annotations, axes, chartStyling, graph } = options ?? {};
27277
27280
  const showCustomLegend = !((_b2 = (_a2 = options == null ? void 0 : options.legend) == null ? void 0 : _a2.customLegend) == null ? void 0 : _b2.customLegendContainerID);
27278
27281
  const [state, dispatch] = useReducer(
27279
27282
  reducer$1,
@@ -27362,10 +27365,10 @@ const LineChart = (props) => {
27362
27365
  ]
27363
27366
  },
27364
27367
  generateKey([
27365
- state.enableDragPoints,
27366
- state.enableDragAnnotation,
27367
- state.zoomEnabled,
27368
- state.panEnabled,
27368
+ state == null ? void 0 : state.enableDragPoints,
27369
+ state == null ? void 0 : state.enableDragAnnotation,
27370
+ state == null ? void 0 : state.zoomEnabled,
27371
+ state == null ? void 0 : state.panEnabled,
27369
27372
  languageKey
27370
27373
  ])
27371
27374
  );
@@ -39990,8 +39993,8 @@ const Ht = { id: "dragdata", afterInit: function(t) {
39990
39993
  Chart.register(Ht);
39991
39994
  const useBarChartConfig = (chartRef, chart2) => {
39992
39995
  var _a2;
39993
- const { options } = chart2;
39994
- const { interactions } = options;
39996
+ const { options } = chart2 ?? {};
39997
+ const { interactions } = options ?? {};
39995
39998
  const [pointHover, setPointHover] = useState(false);
39996
39999
  const generateBarChartDatasets = ({
39997
40000
  datasets,
@@ -40003,29 +40006,30 @@ const useBarChartConfig = (chartRef, chart2) => {
40003
40006
  const annotationsDatasets = controlAnnotation && showAnnotations && (annotationsData == null ? void 0 : annotationsData.length) ? annotationsData.map(
40004
40007
  (annotation2, index2) => ({
40005
40008
  isAnnotation: true,
40006
- label: annotation2.label,
40009
+ label: annotation2 == null ? void 0 : annotation2.label,
40007
40010
  annotationIndex: index2,
40008
- backgroundColor: annotation2.color || COLORS[index2],
40009
- borderColor: annotation2.color || COLORS[index2],
40011
+ backgroundColor: (annotation2 == null ? void 0 : annotation2.color) || COLORS[index2],
40012
+ borderColor: (annotation2 == null ? void 0 : annotation2.color) || COLORS[index2],
40010
40013
  data: [],
40011
40014
  type: ChartType$1.Bar
40012
40015
  })
40013
40016
  ) : [];
40014
40017
  const barDatasetsCopy = [...datasets, ...annotationsDatasets];
40015
- const generatedDatasets2 = barDatasetsCopy.map((barDataset, index2) => {
40018
+ const generatedDatasets2 = barDatasetsCopy == null ? void 0 : barDatasetsCopy.map((barDataset, index2) => {
40019
+ var _a3;
40016
40020
  const colorSchema = COLORS;
40017
- const colors2 = barDataset.data.map((_2) => {
40018
- const colorSelectionIndex = datasets.length > 1 ? index2 : 0;
40019
- return colorSchema[colorSelectionIndex] || generateRandomColor(COLORS);
40021
+ const colors2 = (_a3 = barDataset == null ? void 0 : barDataset.data) == null ? void 0 : _a3.map((_2) => {
40022
+ const colorSelectionIndex = (datasets == null ? void 0 : datasets.length) > 1 ? index2 : 0;
40023
+ return (colorSchema == null ? void 0 : colorSchema[colorSelectionIndex]) || generateRandomColor(COLORS);
40020
40024
  });
40021
- const backgroundColors = barDataset.backgroundColor || colors2.map((color2) => color2 + ALPHA_CHANEL);
40025
+ const backgroundColors = (barDataset == null ? void 0 : barDataset.backgroundColor) || (colors2 == null ? void 0 : colors2.map((color2) => color2 + ALPHA_CHANEL));
40022
40026
  const datasetWithBorderWidth = "borderWidth" in barDatasetsCopy ? {
40023
- borderWidth: parseFloat(String(barDatasetsCopy.borderWidth)) ?? 1
40027
+ borderWidth: parseFloat(String(barDatasetsCopy == null ? void 0 : barDatasetsCopy.borderWidth)) ?? 1
40024
40028
  } : {};
40025
40029
  return {
40026
40030
  ...barDataset,
40027
40031
  ...datasetWithBorderWidth,
40028
- borderColor: barDataset.borderColor || colors2[index2],
40032
+ borderColor: (barDataset == null ? void 0 : barDataset.borderColor) || (colors2 == null ? void 0 : colors2[index2]),
40029
40033
  backgroundColor: backgroundColors
40030
40034
  };
40031
40035
  });
@@ -40041,16 +40045,16 @@ const useBarChartConfig = (chartRef, chart2) => {
40041
40045
  const onHover = (evt, hoveredItems) => {
40042
40046
  if (pointHover && !(hoveredItems == null ? void 0 : hoveredItems.length)) {
40043
40047
  setPointHover(false);
40044
- if (interactions.onUnhover) {
40045
- interactions.onUnhover(evt);
40048
+ if (interactions == null ? void 0 : interactions.onUnhover) {
40049
+ interactions == null ? void 0 : interactions.onUnhover(evt);
40046
40050
  }
40047
40051
  }
40048
40052
  if (!pointHover && (hoveredItems == null ? void 0 : hoveredItems.length)) {
40049
40053
  setPointHover(true);
40050
40054
  if (interactions.onHover) {
40051
- const { index: index2, datasetIndex } = hoveredItems[0];
40055
+ const { index: index2, datasetIndex } = (hoveredItems == null ? void 0 : hoveredItems[0]) ?? {};
40052
40056
  const generatedDataset = generatedDatasets;
40053
- interactions.onHover(evt, datasetIndex, index2, generatedDataset);
40057
+ interactions == null ? void 0 : interactions.onHover(evt, datasetIndex, index2, generatedDataset);
40054
40058
  }
40055
40059
  }
40056
40060
  };