@oliasoft-open-source/charts-library 3.5.4-beta-2 → 3.5.4-beta-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
@@ -22275,12 +22275,9 @@ const initialState = ({ options, persistenceId }) => {
22275
22275
  } = options;
22276
22276
  const getStateAxesByType = (axisType, customAxesRange2) => {
22277
22277
  var _a2, _b2, _c2, _d2, _e2;
22278
- console.log("axisType", axisType);
22279
- console.log("axes", axes);
22280
22278
  if (!axes[axisType]) {
22281
22279
  return [];
22282
22280
  }
22283
- console.log("getStateAxesByType");
22284
22281
  if (((_a2 = axes[axisType]) == null ? void 0 : _a2.length) > 1) {
22285
22282
  return axes[axisType].map(
22286
22283
  (axisObj, index2) => {
@@ -22303,7 +22300,6 @@ const initialState = ({ options, persistenceId }) => {
22303
22300
  const customMin = (_b2 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _b2.min;
22304
22301
  const customMax = (_c2 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _c2.max;
22305
22302
  const unit = (_e2 = (_d2 = axes == null ? void 0 : axes[id]) == null ? void 0 : _d2[0]) == null ? void 0 : _e2.unit;
22306
- console.log("id", id);
22307
22303
  return [
22308
22304
  {
22309
22305
  id,
@@ -22318,7 +22314,6 @@ const initialState = ({ options, persistenceId }) => {
22318
22314
  const xStateAxes = getStateAxesByType(AxisType.X, customAxesRange);
22319
22315
  const yStateAxes = getStateAxesByType(AxisType.Y, customAxesRange);
22320
22316
  const stateAxes = [...xStateAxes, ...yStateAxes];
22321
- console.log("stateAxes", stateAxes);
22322
22317
  const {
22323
22318
  zoomEnabled,
22324
22319
  panEnabled,
@@ -23716,9 +23711,9 @@ const useChartFunctions = ({
23716
23711
  const onResetAxes = useCallback(() => {
23717
23712
  dispatch({ type: RESET_AXES_RANGES });
23718
23713
  }, []);
23719
- const onUpdateAxes = ({ axes: axes2 }) => {
23714
+ const onUpdateAxes = useCallback(({ axes: axes2 }) => {
23720
23715
  dispatch({ type: UPDATE_AXES_RANGES, payload: { axes: axes2 } });
23721
- };
23716
+ }, []);
23722
23717
  return {
23723
23718
  legendClick,
23724
23719
  resetZoom: resetZoom2,
@@ -23794,7 +23789,7 @@ const reducer = (state, action) => {
23794
23789
  return produce(state, (draft) => {
23795
23790
  const { name: name2, value, id } = action.payload;
23796
23791
  const axis = draft.find((a2) => a2.id === id);
23797
- if (axis) {
23792
+ if (axis && value) {
23798
23793
  axis[name2] = value;
23799
23794
  }
23800
23795
  });
@@ -24544,116 +24539,122 @@ const TextLabelPosition = {
24544
24539
  BOTTOM_CENTER: "bottom-center",
24545
24540
  BOTTOM_RIGHT: "bottom-right"
24546
24541
  };
24542
+ const defaultAxes$1 = (axes) => ({
24543
+ x: (axes == null ? void 0 : axes.x) || [{}],
24544
+ y: (axes == null ? void 0 : axes.y) || [{}]
24545
+ });
24546
+ const defaultAdditionalAxesOptions$1 = (options) => ({
24547
+ chartScaleType: (options == null ? void 0 : options.chartScaleType) || "linear",
24548
+ reverse: (options == null ? void 0 : options.reverse) || false,
24549
+ beginAtZero: (options == null ? void 0 : options.beginAtZero) ?? false,
24550
+ stepSize: options == null ? void 0 : options.stepSize,
24551
+ suggestedMin: options == null ? void 0 : options.suggestedMin,
24552
+ suggestedMax: options == null ? void 0 : options.suggestedMax,
24553
+ range: options == null ? void 0 : options.range,
24554
+ autoAxisPadding: (options == null ? void 0 : options.autoAxisPadding) ?? false
24555
+ });
24556
+ const defaultChartStyling$2 = (options) => ({
24557
+ width: options == null ? void 0 : options.width,
24558
+ height: options == null ? void 0 : options.height,
24559
+ maintainAspectRatio: (options == null ? void 0 : options.maintainAspectRatio) ?? false,
24560
+ staticChartHeight: (options == null ? void 0 : options.staticChartHeight) ?? false,
24561
+ performanceMode: (options == null ? void 0 : options.performanceMode) ?? true,
24562
+ squareAspectRatio: options == null ? void 0 : options.squareAspectRatio,
24563
+ layoutPadding: (options == null ? void 0 : options.layoutPadding) || {
24564
+ top: 0,
24565
+ bottom: 20,
24566
+ left: 0,
24567
+ right: 0
24568
+ }
24569
+ });
24570
+ const defaultTooltip$2 = (tooltip) => ({
24571
+ tooltips: (tooltip == null ? void 0 : tooltip.tooltips) ?? true,
24572
+ showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) ?? false,
24573
+ hideSimulationName: (tooltip == null ? void 0 : tooltip.hideSimulationName) ?? false
24574
+ });
24575
+ const defaultGraph$2 = (graph) => ({
24576
+ lineTension: (graph == null ? void 0 : graph.lineTension) ?? 0.01,
24577
+ spanGaps: (graph == null ? void 0 : graph.spanGaps) ?? false,
24578
+ showDataLabels: (graph == null ? void 0 : graph.showDataLabels) ?? false,
24579
+ showMinorGridlines: (graph == null ? void 0 : graph.showMinorGridlines) ?? false
24580
+ });
24581
+ const defaultAnnotations$1 = (annotations) => {
24582
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
24583
+ return {
24584
+ labelAnnotation: {
24585
+ showLabel: ((_a2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _a2.showLabel) ?? false,
24586
+ text: ((_b2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _b2.text) ?? "",
24587
+ position: ((_c2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _c2.position) ?? TextLabelPosition.BOTTOM_RIGHT,
24588
+ fontSize: ((_d2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _d2.fontSize) ?? 12,
24589
+ xOffset: ((_e2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _e2.xOffset) ?? 5,
24590
+ yOffset: ((_f2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _f2.yOffset) ?? 5,
24591
+ maxWidth: ((_g2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _g2.maxWidth) ?? 300,
24592
+ lineHeight: ((_h2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _h2.lineHeight) ?? 12
24593
+ },
24594
+ showAnnotations: (annotations == null ? void 0 : annotations.showAnnotations) ?? false,
24595
+ controlAnnotation: (annotations == null ? void 0 : annotations.controlAnnotation) ?? false,
24596
+ annotationsData: (annotations == null ? void 0 : annotations.annotationsData) ?? []
24597
+ };
24598
+ };
24599
+ const defaultLegend$2 = (legend2) => ({
24600
+ display: (legend2 == null ? void 0 : legend2.display) ?? true,
24601
+ position: (legend2 == null ? void 0 : legend2.position) ?? Position.BottomLeft,
24602
+ align: (legend2 == null ? void 0 : legend2.align) ?? AlignOptions.Center,
24603
+ customLegend: (legend2 == null ? void 0 : legend2.customLegend) ?? {
24604
+ customLegendPlugin: null,
24605
+ customLegendContainerID: ""
24606
+ },
24607
+ usePointStyle: (legend2 == null ? void 0 : legend2.usePointStyle) ?? true
24608
+ });
24609
+ const defaultChartOptions$2 = (options) => ({
24610
+ showPoints: (options == null ? void 0 : options.showPoints) ?? true,
24611
+ enableZoom: (options == null ? void 0 : options.enableZoom) ?? true,
24612
+ enablePan: (options == null ? void 0 : options.enablePan) ?? false,
24613
+ showLine: (options == null ? void 0 : options.showLine) ?? true,
24614
+ closeOnOutsideClick: (options == null ? void 0 : options.closeOnOutsideClick) ?? false
24615
+ });
24616
+ const defaultInteractions$2 = (interactions) => ({
24617
+ onLegendClick: interactions == null ? void 0 : interactions.onLegendClick,
24618
+ onHover: interactions == null ? void 0 : interactions.onHover,
24619
+ onUnhover: interactions == null ? void 0 : interactions.onUnhover,
24620
+ onAnimationComplete: interactions == null ? void 0 : interactions.onAnimationComplete
24621
+ });
24622
+ const defaultDragData$1 = (dragData) => ({
24623
+ enableDragData: (dragData == null ? void 0 : dragData.enableDragData) ?? false,
24624
+ showTooltip: (dragData == null ? void 0 : dragData.showTooltip) ?? true,
24625
+ roundPoints: (dragData == null ? void 0 : dragData.roundPoints) ?? true,
24626
+ dragX: (dragData == null ? void 0 : dragData.dragX) ?? true,
24627
+ dragY: (dragData == null ? void 0 : dragData.dragY) ?? true,
24628
+ onDragStart: dragData == null ? void 0 : dragData.onDragStart,
24629
+ onDrag: dragData == null ? void 0 : dragData.onDrag,
24630
+ onDragEnd: dragData == null ? void 0 : dragData.onDragEnd
24631
+ });
24547
24632
  const getDefaultProps$2 = (props) => {
24548
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2;
24549
- props.chart.options = props.chart.options || {};
24550
- props.chart.options.axes = props.chart.options.axes || {};
24551
- props.chart.options.additionalAxesOptions = props.chart.options.additionalAxesOptions || {};
24552
- props.chart.options.chartStyling = props.chart.options.chartStyling || {};
24553
- props.chart.options.tooltip = props.chart.options.tooltip || {};
24554
- props.chart.options.graph = props.chart.options.graph || {};
24555
- props.chart.options.annotations = props.chart.options.annotations || {};
24556
- props.chart.options.legend = props.chart.options.legend || {};
24557
- props.chart.options.legend.customLegend = props.chart.options.legend.customLegend || { customLegendPlugin: null, customLegendContainerID: "" };
24558
- props.chart.options.chartOptions = props.chart.options.chartOptions || {};
24559
- props.chart.options.interactions = props.chart.options.interactions || {};
24560
- props.chart.options.dragData = props.chart.options.dragData || {};
24561
- const chart2 = {
24562
- persistenceId: props.chart.persistenceId ?? "",
24563
- controlsPortalId: props.chart.controlsPortalId ?? null,
24564
- testId: props.chart.testId ?? null,
24565
- data: props.chart.data,
24633
+ const chart2 = (props == null ? void 0 : props.chart) || {};
24634
+ const options = (chart2 == null ? void 0 : chart2.options) || {};
24635
+ return {
24636
+ persistenceId: (chart2 == null ? void 0 : chart2.persistenceId) ?? "",
24637
+ controlsPortalId: (chart2 == null ? void 0 : chart2.controlsPortalId) ?? "",
24638
+ testId: (chart2 == null ? void 0 : chart2.testId) ?? null,
24639
+ data: chart2 == null ? void 0 : chart2.data,
24566
24640
  options: {
24567
- title: props.chart.options.title || "",
24568
- scales: props.chart.options.scales || {},
24569
- axes: {
24570
- x: props.chart.options.axes.x || [{}],
24571
- y: props.chart.options.axes.y || [{}]
24572
- },
24573
- additionalAxesOptions: {
24574
- chartScaleType: props.chart.options.additionalAxesOptions.chartScaleType || "linear",
24575
- reverse: props.chart.options.additionalAxesOptions.reverse || false,
24576
- beginAtZero: props.chart.options.additionalAxesOptions.beginAtZero || false,
24577
- stepSize: props.chart.options.additionalAxesOptions.stepSize,
24578
- suggestedMin: props.chart.options.additionalAxesOptions.suggestedMin,
24579
- suggestedMax: props.chart.options.additionalAxesOptions.suggestedMax,
24580
- range: props.chart.options.additionalAxesOptions.range,
24581
- autoAxisPadding: props.chart.options.additionalAxesOptions.autoAxisPadding ?? false
24582
- },
24583
- chartStyling: {
24584
- width: props.chart.options.chartStyling.width,
24585
- height: props.chart.options.chartStyling.height,
24586
- maintainAspectRatio: props.chart.options.chartStyling.maintainAspectRatio || false,
24587
- staticChartHeight: props.chart.options.chartStyling.staticChartHeight || false,
24588
- performanceMode: props.chart.options.chartStyling.performanceMode ?? true,
24589
- squareAspectRatio: props.chart.options.chartStyling.squareAspectRatio || false,
24590
- layoutPadding: props.chart.options.chartStyling.layoutPadding || {
24591
- top: 0,
24592
- bottom: 20,
24593
- left: 0,
24594
- right: 0
24595
- }
24596
- },
24597
- tooltip: {
24598
- tooltips: props.chart.options.tooltip.tooltips ?? true,
24599
- showLabelsInTooltips: props.chart.options.tooltip.showLabelsInTooltips || false,
24600
- hideSimulationName: props.chart.options.tooltip.hideSimulationName || false
24601
- },
24602
- graph: {
24603
- lineTension: props.chart.options.graph.lineTension || 0.01,
24604
- spanGaps: props.chart.options.graph.spanGaps || false,
24605
- showDataLabels: props.chart.options.graph.showDataLabels || false,
24606
- showMinorGridlines: props.chart.options.graph.showMinorGridlines || false
24607
- },
24608
- annotations: {
24609
- labelAnnotation: {
24610
- showLabel: ((_a2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _a2.showLabel) ?? false,
24611
- text: ((_b2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _b2.text) ?? "",
24612
- position: ((_c2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _c2.position) ?? TextLabelPosition.BOTTOM_RIGHT,
24613
- fontSize: ((_d2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _d2.fontSize) ?? 12,
24614
- xOffset: ((_e2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _e2.xOffset) ?? 5,
24615
- yOffset: ((_f2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _f2.yOffset) ?? 5,
24616
- maxWidth: ((_g2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _g2.maxWidth) ?? 300,
24617
- lineHeight: ((_h2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _h2.lineHeight) ?? 12
24618
- },
24619
- showAnnotations: props.chart.options.annotations.showAnnotations ?? false,
24620
- controlAnnotation: props.chart.options.annotations.controlAnnotation || false,
24621
- annotationsData: props.chart.options.annotations.annotationsData || []
24622
- },
24623
- legend: {
24624
- display: props.chart.options.legend.display ?? true,
24625
- position: props.chart.options.legend.position || "bottom-left",
24626
- align: props.chart.options.legend.align || "center",
24627
- customLegend: props.chart.options.legend.customLegend,
24628
- usePointStyle: props.chart.options.legend.usePointStyle ?? true
24629
- },
24630
- chartOptions: {
24631
- showPoints: props.chart.options.chartOptions.showPoints ?? true,
24632
- enableZoom: props.chart.options.chartOptions.enableZoom || true,
24633
- enablePan: props.chart.options.chartOptions.enablePan || false,
24634
- showLine: props.chart.options.chartOptions.showLine ?? true,
24635
- closeOnOutsideClick: props.chart.options.chartOptions.closeOnOutsideClick || false
24636
- },
24637
- interactions: {
24638
- onLegendClick: props.chart.options.interactions.onLegendClick,
24639
- onPointHover: (_i2 = props.chart.options.interactions) == null ? void 0 : _i2.onPointHover,
24640
- onPointUnhover: (_j2 = props.chart.options.interactions) == null ? void 0 : _j2.onPointUnhover,
24641
- onAnimationComplete: props.chart.options.interactions.onAnimationComplete
24642
- },
24643
- depthType: props.chart.options.depthType,
24644
- dragData: {
24645
- enableDragData: props.chart.options.dragData.enableDragData ?? false,
24646
- showTooltip: props.chart.options.dragData.showTooltip ?? true,
24647
- roundPoints: props.chart.options.dragData.roundPoints ?? true,
24648
- dragX: props.chart.options.dragData.dragX ?? true,
24649
- dragY: props.chart.options.dragData.dragY ?? true,
24650
- onDragStart: props.chart.options.dragData.onDragStart,
24651
- onDrag: props.chart.options.dragData.onDrag,
24652
- onDragEnd: props.chart.options.dragData.onDragEnd
24653
- }
24641
+ title: (options == null ? void 0 : options.title) ?? "",
24642
+ scales: (options == null ? void 0 : options.scales) ?? {},
24643
+ axes: defaultAxes$1(options == null ? void 0 : options.axes),
24644
+ additionalAxesOptions: defaultAdditionalAxesOptions$1(
24645
+ options == null ? void 0 : options.additionalAxesOptions
24646
+ ),
24647
+ chartStyling: defaultChartStyling$2(options == null ? void 0 : options.chartStyling),
24648
+ tooltip: defaultTooltip$2(options == null ? void 0 : options.tooltip),
24649
+ graph: defaultGraph$2(options == null ? void 0 : options.graph),
24650
+ annotations: defaultAnnotations$1(options == null ? void 0 : options.annotations),
24651
+ legend: defaultLegend$2(options == null ? void 0 : options.legend),
24652
+ chartOptions: defaultChartOptions$2(options == null ? void 0 : options.chartOptions),
24653
+ interactions: defaultInteractions$2(options == null ? void 0 : options.interactions),
24654
+ dragData: defaultDragData$1(options == null ? void 0 : options.dragData),
24655
+ depthType: (options == null ? void 0 : options.depthType) ?? {}
24654
24656
  }
24655
24657
  };
24656
- return chart2;
24657
24658
  };
24658
24659
  const DEFAULT_POINT_RADIUS = 2;
24659
24660
  const DEFAULT_HOVER_RADIUS = 5;
@@ -25422,31 +25423,25 @@ const useStoreChartStateInStorage = (memoState, persistenceId) => {
25422
25423
  ]);
25423
25424
  };
25424
25425
  const useUpdateAxesRanges = (range, dispatch) => {
25425
- const prevRange = useRef();
25426
- const updateAxesRanges = useCallback(() => {
25427
- if (range && isRangeValid(range) && !isEqual(range, prevRange.current)) {
25428
- const axes = Object.entries(range).map(([key, { min, max }]) => ({
25429
- id: key,
25430
- min: min ?? 0,
25431
- max: max ?? 0
25432
- }));
25433
- dispatch({
25434
- type: UPDATE_AXES_RANGES,
25435
- payload: { axes }
25436
- });
25437
- prevRange.current = range;
25438
- }
25439
- }, [range]);
25440
- useEffect(() => {
25441
- updateAxesRanges();
25442
- }, [updateAxesRanges]);
25426
+ const prevAxes = useRef(null);
25427
+ const axes = range && isRangeValid(range) ? Object.entries(range).map(([key, { min, max }]) => ({
25428
+ id: key,
25429
+ min: min ?? 0,
25430
+ max: max ?? 0
25431
+ })) : null;
25432
+ if (!isEqual(axes, prevAxes.current) && axes !== null) {
25433
+ dispatch({
25434
+ type: UPDATE_AXES_RANGES,
25435
+ payload: { axes }
25436
+ });
25437
+ prevAxes.current = axes;
25438
+ }
25443
25439
  };
25444
25440
  const useSaveInitialAxesRanges = (chartRef, axes, generatedDatasets, dispatch) => {
25445
25441
  const prevGeneratedDatasets = useRef();
25446
25442
  const saveInitialAxesRanges = useCallback(() => {
25447
25443
  if (chartRef && !isEqual(generatedDatasets, prevGeneratedDatasets.current)) {
25448
25444
  const initialAxesRanges = getAxesRangesFromChart(chartRef, axes);
25449
- console.log("initialAxesRanges", initialAxesRanges);
25450
25445
  dispatch({
25451
25446
  type: SAVE_INITIAL_AXES_RANGES,
25452
25447
  payload: { initialAxesRanges }
@@ -25729,8 +25724,9 @@ const LineChart = (props) => {
25729
25724
  generatedDatasets
25730
25725
  });
25731
25726
  const usePlugins = useChartPlugins({ options, resetZoom: resetZoom2 });
25732
- console.log("State", state);
25727
+ console.log("state", state);
25733
25728
  console.log("options", options);
25729
+ console.log("generatedDatasets", generatedDatasets);
25734
25730
  return /* @__PURE__ */ jsxs(
25735
25731
  "div",
25736
25732
  {