@oliasoft-open-source/charts-library 5.0.2 → 5.0.3-beta-1

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.
Files changed (30) hide show
  1. package/dist/assets/{Color-YHDXOIA2-DvkV04os.js → Color-YHDXOIA2-BvfhVAjI.js} +1 -1
  2. package/dist/assets/{DocsRenderer-CFRXHY34-cMkmi-tX.js → DocsRenderer-CFRXHY34-CliORq5_.js} +3 -3
  3. package/dist/assets/{bar-chart.stories-Eq_jQ19D.js → bar-chart.stories-BMExUqt4.js} +1 -1
  4. package/dist/assets/{entry-preview-Cgd6khWs.js → entry-preview-Bqd2U7mX.js} +1 -1
  5. package/dist/assets/{get-draggableData-CQpLHCdg.js → get-draggableData-DS0HhINp.js} +1 -1
  6. package/dist/assets/{iframe-Bj1sRZW3.js → iframe-CB3H5nUS.js} +2 -2
  7. package/dist/assets/{legend-krJw8Ykb.js → legend-CD8XU7nW.js} +1 -1
  8. package/dist/assets/line-chart-D3YG7EEV.js +1 -0
  9. package/dist/assets/line-chart.stories-DY8ALwMk.js +1155 -0
  10. package/dist/assets/line-chart.test-case.stories-BXMQ2TyL.js +428 -0
  11. package/dist/assets/{preview-BNebtty_.js → preview-CiEdDnYv.js} +2 -2
  12. package/dist/assets/{preview-CASZ8WNA.js → preview-y81lG200.js} +1 -1
  13. package/dist/assets/{scatter-chart.stories-BCbRBdJY.js → scatter-chart.stories-sl5FPoGH.js} +1 -1
  14. package/dist/iframe.html +1 -1
  15. package/dist/index.js.js +64 -34
  16. package/dist/index.js.js.map +1 -1
  17. package/dist/index.json +1 -1
  18. package/dist/line-chart/controls/axes-options/axes-options-interfaces.d.ts +1 -0
  19. package/dist/line-chart/hooks/use-chart-functions.d.ts +2 -1
  20. package/dist/line-chart/state/action-types.d.ts +1 -0
  21. package/dist/line-chart/state/state.interfaces.d.ts +1 -0
  22. package/dist/project.json +1 -1
  23. package/dist/src/components/line-chart/controls/axes-options/axes-options-interfaces.d.ts +1 -0
  24. package/dist/src/components/line-chart/hooks/use-chart-functions.d.ts +1 -0
  25. package/dist/src/components/line-chart/state/action-types.d.ts +1 -0
  26. package/dist/src/components/line-chart/state/state.interfaces.d.ts +1 -0
  27. package/package.json +1 -1
  28. package/dist/assets/line-chart-TEIxShHM.js +0 -1
  29. package/dist/assets/line-chart.stories-CRpxf_tv.js +0 -1130
  30. package/dist/assets/line-chart.test-case.stories-Cb2jns7e.js +0 -142
package/dist/index.js.js CHANGED
@@ -22803,6 +22803,7 @@ const UPDATE_AXES_RANGES = "UPDATE_AXES_RANGES";
22803
22803
  const TOGGLE_DRAG_POINTS = "TOGGLE_DRAG_POINTS";
22804
22804
  const TOGGLE_DRAG_ANNOTATION = "TOGGLE_DRAG_ANNOTATION";
22805
22805
  const DISABLE_DRAG_OPTIONS = "DISABLE_DRAG_OPTIONS";
22806
+ const UPDATE_EDITED = "UPDATE_EDITED";
22806
22807
  const reducer = (state, action) => {
22807
22808
  return produce(state, (draft) => {
22808
22809
  switch (action.type) {
@@ -22890,6 +22891,10 @@ const reducer = (state, action) => {
22890
22891
  }
22891
22892
  break;
22892
22893
  }
22894
+ case UPDATE_EDITED: {
22895
+ draft.edited = action.payload;
22896
+ break;
22897
+ }
22893
22898
  }
22894
22899
  });
22895
22900
  };
@@ -22964,7 +22969,8 @@ const initialState = ({ options, persistenceId }) => {
22964
22969
  axes: [],
22965
22970
  showTable: false,
22966
22971
  enableDragPoints: (dragData == null ? void 0 : dragData.enableDragData) && enableDragPoints,
22967
- enableDragAnnotation: enableDragAnnotation ?? enableDragAnnotationStorage
22972
+ enableDragAnnotation: enableDragAnnotation ?? enableDragAnnotationStorage,
22973
+ edited: false
22968
22974
  };
22969
22975
  };
22970
22976
  const ControlsPortal = ({
@@ -23291,7 +23297,7 @@ const useToggleHandlers = (dispatch) => {
23291
23297
  },
23292
23298
  [dispatch]
23293
23299
  );
23294
- const toggleHandlers = {
23300
+ return {
23295
23301
  onToggleLegend: createToggleHandler(TOGGLE_LEGEND),
23296
23302
  onToggleLine: createToggleHandler(TOGGLE_LINE),
23297
23303
  onTogglePan: createToggleHandler(TOGGLE_PAN),
@@ -23302,7 +23308,6 @@ const useToggleHandlers = (dispatch) => {
23302
23308
  onToggleDragAnnotation: createToggleHandler(TOGGLE_DRAG_ANNOTATION),
23303
23309
  onDisableDragOptions: createToggleHandler(DISABLE_DRAG_OPTIONS)
23304
23310
  };
23305
- return toggleHandlers;
23306
23311
  };
23307
23312
  function resolveUrl(url, baseUrl) {
23308
23313
  if (url.match(/^[a-z]+:\/\//i)) {
@@ -24329,11 +24334,16 @@ const useChartFunctions = ({
24329
24334
  axes
24330
24335
  } = options;
24331
24336
  const resetZoom2 = useCallback(() => {
24337
+ var _a2, _b2, _c2;
24332
24338
  const chartInstance = chartRef == null ? void 0 : chartRef.current;
24333
- chartInstance == null ? void 0 : chartInstance.resetZoom();
24334
- chartInstance == null ? void 0 : chartInstance.reset();
24335
- dispatch({ type: "RESET_AXES_RANGES", payload: { axes: [] } });
24336
- }, [chartRef == null ? void 0 : chartRef.current, dispatch]);
24339
+ if (chartInstance && (state == null ? void 0 : state.edited)) {
24340
+ (_a2 = chartInstance == null ? void 0 : chartInstance.resetZoom) == null ? void 0 : _a2.call(chartInstance);
24341
+ (_b2 = chartInstance == null ? void 0 : chartInstance.reset) == null ? void 0 : _b2.call(chartInstance);
24342
+ dispatch({ type: RESET_AXES_RANGES, payload: { axes: [] } });
24343
+ dispatch({ type: UPDATE_EDITED, payload: false });
24344
+ (_c2 = chartInstance == null ? void 0 : chartInstance.update) == null ? void 0 : _c2.call(chartInstance);
24345
+ }
24346
+ }, [chartRef == null ? void 0 : chartRef.current, dispatch, state]);
24337
24347
  const onHover = useCallback(
24338
24348
  (hoveredPoint, setHoveredPoint, datasets) => {
24339
24349
  return (evt, hoveredItems) => {
@@ -24433,14 +24443,25 @@ const useChartFunctions = ({
24433
24443
  });
24434
24444
  }, [axes]);
24435
24445
  const onResetAxes = useCallback(() => {
24446
+ var _a2, _b2, _c2;
24436
24447
  const chartInstance = chartRef == null ? void 0 : chartRef.current;
24437
- chartInstance == null ? void 0 : chartInstance.resetZoom();
24438
- chartInstance == null ? void 0 : chartInstance.reset();
24439
- dispatch({ type: RESET_AXES_RANGES, payload: { axes: [] } });
24448
+ if (chartInstance && state.edited) {
24449
+ (_a2 = chartInstance == null ? void 0 : chartInstance.resetZoom) == null ? void 0 : _a2.call(chartInstance);
24450
+ (_b2 = chartInstance == null ? void 0 : chartInstance.reset) == null ? void 0 : _b2.call(chartInstance);
24451
+ dispatch({ type: RESET_AXES_RANGES, payload: { axes: [] } });
24452
+ dispatch({ type: UPDATE_EDITED, payload: false });
24453
+ (_c2 = chartInstance == null ? void 0 : chartInstance.update) == null ? void 0 : _c2.call(chartInstance);
24454
+ }
24440
24455
  }, [chartRef == null ? void 0 : chartRef.current]);
24441
24456
  const onUpdateAxes = useCallback(({ axes: axes2 }) => {
24442
24457
  dispatch({ type: UPDATE_AXES_RANGES, payload: { axes: axes2 } });
24443
24458
  }, []);
24459
+ const onUpdateEdited = useCallback(
24460
+ (edited) => {
24461
+ dispatch({ type: UPDATE_EDITED, payload: edited });
24462
+ },
24463
+ [state]
24464
+ );
24444
24465
  return {
24445
24466
  resetZoom: resetZoom2,
24446
24467
  onHover,
@@ -24450,7 +24471,8 @@ const useChartFunctions = ({
24450
24471
  controlsAxesLabels: getControlsAxesLabels(axes),
24451
24472
  updateAxesRangesFromChart,
24452
24473
  onResetAxes,
24453
- onUpdateAxes
24474
+ onUpdateAxes,
24475
+ onUpdateEdited
24454
24476
  };
24455
24477
  };
24456
24478
  const createErrorMessages = (value, compareTo, type) => {
@@ -24504,6 +24526,7 @@ const AxesOptionsPopover = (optionsPopover) => {
24504
24526
  controlsAxesLabels,
24505
24527
  onUpdateAxes,
24506
24528
  onResetAxes,
24529
+ onUpdateEdited,
24507
24530
  depthType,
24508
24531
  translations,
24509
24532
  close,
@@ -24512,7 +24535,7 @@ const AxesOptionsPopover = (optionsPopover) => {
24512
24535
  const [formState, setFormState] = useState({
24513
24536
  localAxes: getInitAxes({ chartRef, state }),
24514
24537
  depthType: depthType == null ? void 0 : depthType.selectedDepthType,
24515
- edited: false
24538
+ edited: state.edited
24516
24539
  });
24517
24540
  const { errors, valid } = validateAxes(formState.localAxes);
24518
24541
  const onEditValue = ({ name, value, id }) => {
@@ -24548,6 +24571,7 @@ const AxesOptionsPopover = (optionsPopover) => {
24548
24571
  if (depthType && (depthType == null ? void 0 : depthType.setSelectedDepthType)) {
24549
24572
  depthType == null ? void 0 : depthType.setSelectedDepthType(formState.depthType);
24550
24573
  }
24574
+ onUpdateEdited(formState.edited);
24551
24575
  };
24552
24576
  const onReset = () => {
24553
24577
  setFormState({
@@ -24556,6 +24580,7 @@ const AxesOptionsPopover = (optionsPopover) => {
24556
24580
  edited: false
24557
24581
  });
24558
24582
  onResetAxes();
24583
+ onUpdateEdited(false);
24559
24584
  close == null ? void 0 : close();
24560
24585
  };
24561
24586
  const handleInputFocus = (e2) => e2.target.select();
@@ -24624,11 +24649,13 @@ const AxesOptionsPopover = (optionsPopover) => {
24624
24649
  key: i2,
24625
24650
  label: depth
24626
24651
  })),
24627
- onSelected: (key) => setFormState((prevState) => ({
24628
- ...prevState,
24629
- depthType: depthType.options[key],
24630
- edited: true
24631
- })),
24652
+ onSelected: (key) => {
24653
+ setFormState((prevState) => ({
24654
+ ...prevState,
24655
+ depthType: depthType.options[key],
24656
+ edited: true
24657
+ }));
24658
+ },
24632
24659
  small: true,
24633
24660
  value: depthType.options.indexOf(formState.depthType)
24634
24661
  }
@@ -24710,7 +24737,13 @@ const Controls = ({
24710
24737
  onToggleDragAnnotation,
24711
24738
  onDisableDragOptions
24712
24739
  } = useToggleHandlers(dispatch);
24713
- const { handleDownload, controlsAxesLabels, onResetAxes, onUpdateAxes } = useChartFunctions({
24740
+ const {
24741
+ handleDownload,
24742
+ controlsAxesLabels,
24743
+ onResetAxes,
24744
+ onUpdateAxes,
24745
+ onUpdateEdited
24746
+ } = useChartFunctions({
24714
24747
  chartRef,
24715
24748
  state,
24716
24749
  options,
@@ -24771,6 +24804,7 @@ const Controls = ({
24771
24804
  controlsAxesLabels,
24772
24805
  onUpdateAxes,
24773
24806
  onResetAxes,
24807
+ onUpdateEdited,
24774
24808
  depthType,
24775
24809
  translations
24776
24810
  }
@@ -25080,19 +25114,20 @@ const generateLineChartDatasets = (datasets, state, options, { label }) => {
25080
25114
  } = line ?? {};
25081
25115
  const { lineEnabled, pointsEnabled, axes = [] } = state ?? {};
25082
25116
  const { lineTension, spanGaps } = graph ?? {};
25083
- if (formation) {
25117
+ const rawData = Array.isArray(data) ? data : [];
25118
+ if (formation && (rawData == null ? void 0 : rawData.length)) {
25084
25119
  const axesMin = Number((_a2 = axes[0]) == null ? void 0 : _a2.min);
25085
25120
  const axesMax = Number((_b2 = axes[0]) == null ? void 0 : _b2.max);
25086
- const [startPoint, endPoint] = data;
25121
+ const [startPoint, endPoint] = rawData;
25087
25122
  if (axesMin && (startPoint == null ? void 0 : startPoint.x)) {
25088
- data[0].x = Math.max(axesMin, startPoint.x);
25123
+ rawData[0].x = Math.max(axesMin, startPoint.x);
25089
25124
  }
25090
25125
  if (axesMax && (endPoint == null ? void 0 : endPoint.x)) {
25091
- data[2].x = Math.min(axesMax, endPoint.x);
25126
+ rawData[2].x = Math.min(axesMax, endPoint.x);
25092
25127
  }
25093
25128
  }
25094
25129
  const hasCustomOpt = checkCustomOption(line, CUSTOM_OPTION);
25095
- const filteredData = data.filter(Boolean) || [];
25130
+ const filteredData = (rawData == null ? void 0 : rawData.filter(Boolean)) || [];
25096
25131
  const isSinglePoint = (filteredData == null ? void 0 : filteredData.length) === 1;
25097
25132
  let pointState, lineState;
25098
25133
  if (customShowPoints !== void 0) {
@@ -25415,7 +25450,7 @@ const getAlignmentData = (context) => {
25415
25450
  const { chart: chart2, dataIndex = 0, datasetIndex = 0 } = context;
25416
25451
  const { chartArea } = chart2;
25417
25452
  const { left: left2 = null, right: right2 = null, bottom: bottom2 = null } = chartArea;
25418
- const meta = chart2.getDatasetMeta(datasetIndex);
25453
+ const meta = chart2 == null ? void 0 : chart2.getDatasetMeta(datasetIndex);
25419
25454
  const { x: x2 = null, y: y2 = null } = ((_a2 = meta == null ? void 0 : meta.data) == null ? void 0 : _a2[dataIndex]) || {};
25420
25455
  return {
25421
25456
  x: x2,
@@ -25937,7 +25972,7 @@ const useChartOptions = ({
25937
25972
  const [hoveredPoint, setHoveredPoint] = useState(
25938
25973
  null
25939
25974
  );
25940
- const { updateAxesRangesFromChart, onHover } = useChartFunctions({
25975
+ const { updateAxesRangesFromChart, onHover, onUpdateEdited } = useChartFunctions({
25941
25976
  chartRef,
25942
25977
  state,
25943
25978
  options,
@@ -25963,6 +25998,7 @@ const useChartOptions = ({
25963
25998
  mode: PanZoomMode.XY,
25964
25999
  onPanComplete() {
25965
26000
  updateAxesRangesFromChart();
26001
+ onUpdateEdited(true);
25966
26002
  }
25967
26003
  }),
25968
26004
  [panEnabled]
@@ -25979,6 +26015,7 @@ const useChartOptions = ({
25979
26015
  },
25980
26016
  onZoomComplete() {
25981
26017
  updateAxesRangesFromChart();
26018
+ onUpdateEdited(true);
25982
26019
  }
25983
26020
  }),
25984
26021
  [zoomEnabled]
@@ -26044,21 +26081,14 @@ const useChartOptions = ({
26044
26081
  };
26045
26082
  const useChartPlugins = ({ options, resetZoom: resetZoom2 }) => {
26046
26083
  const { graph, legend: legend2 } = options;
26047
- const debouncedResetZoom = useCallback(
26048
- debounce$3(() => {
26049
- resetZoom2();
26050
- }, 100),
26051
- // 100ms debounce delay
26052
- [resetZoom2]
26053
- );
26054
26084
  const handleDoubleClick = useCallback(
26055
26085
  (_2, args) => {
26056
26086
  const { event } = args;
26057
26087
  if (event.type === DOUBLE_CLICK) {
26058
- debouncedResetZoom();
26088
+ resetZoom2();
26059
26089
  }
26060
26090
  },
26061
- [debouncedResetZoom]
26091
+ [resetZoom2]
26062
26092
  );
26063
26093
  return useMemo(() => {
26064
26094
  return [