@oliasoft-open-source/charts-library 3.5.3 → 3.5.4-beta-2

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,9 +22275,12 @@ 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);
22278
22280
  if (!axes[axisType]) {
22279
22281
  return [];
22280
22282
  }
22283
+ console.log("getStateAxesByType");
22281
22284
  if (((_a2 = axes[axisType]) == null ? void 0 : _a2.length) > 1) {
22282
22285
  return axes[axisType].map(
22283
22286
  (axisObj, index2) => {
@@ -22300,6 +22303,7 @@ const initialState = ({ options, persistenceId }) => {
22300
22303
  const customMin = (_b2 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _b2.min;
22301
22304
  const customMax = (_c2 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _c2.max;
22302
22305
  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);
22303
22307
  return [
22304
22308
  {
22305
22309
  id,
@@ -22314,6 +22318,7 @@ const initialState = ({ options, persistenceId }) => {
22314
22318
  const xStateAxes = getStateAxesByType(AxisType.X, customAxesRange);
22315
22319
  const yStateAxes = getStateAxesByType(AxisType.Y, customAxesRange);
22316
22320
  const stateAxes = [...xStateAxes, ...yStateAxes];
22321
+ console.log("stateAxes", stateAxes);
22317
22322
  const {
22318
22323
  zoomEnabled,
22319
22324
  panEnabled,
@@ -23711,9 +23716,9 @@ const useChartFunctions = ({
23711
23716
  const onResetAxes = useCallback(() => {
23712
23717
  dispatch({ type: RESET_AXES_RANGES });
23713
23718
  }, []);
23714
- const onUpdateAxes = useCallback(({ axes: axes2 }) => {
23719
+ const onUpdateAxes = ({ axes: axes2 }) => {
23715
23720
  dispatch({ type: UPDATE_AXES_RANGES, payload: { axes: axes2 } });
23716
- }, []);
23721
+ };
23717
23722
  return {
23718
23723
  legendClick,
23719
23724
  resetZoom: resetZoom2,
@@ -24539,122 +24544,116 @@ const TextLabelPosition = {
24539
24544
  BOTTOM_CENTER: "bottom-center",
24540
24545
  BOTTOM_RIGHT: "bottom-right"
24541
24546
  };
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) || null,
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
- });
24632
24547
  const getDefaultProps$2 = (props) => {
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,
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,
24640
24566
  options: {
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) ?? {}
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
+ }
24656
24654
  }
24657
24655
  };
24656
+ return chart2;
24658
24657
  };
24659
24658
  const DEFAULT_POINT_RADIUS = 2;
24660
24659
  const DEFAULT_HOVER_RADIUS = 5;
@@ -25265,7 +25264,7 @@ const useChartOptions = ({
25265
25264
  );
25266
25265
  const scales = useMemo(
25267
25266
  () => autoScale(options, state, generatedDatasets, chartRef),
25268
- [options, state, generatedDatasets]
25267
+ [options, state, generatedDatasets, chartRef]
25269
25268
  );
25270
25269
  const dragData = useMemo(
25271
25270
  () => enableDragPoints && getDraggableData(options),
@@ -25348,7 +25347,7 @@ const useChartOptions = ({
25348
25347
  plugins,
25349
25348
  events: Object.values(Events)
25350
25349
  }),
25351
- [state, options]
25350
+ [state, options, chartRef]
25352
25351
  );
25353
25352
  };
25354
25353
  const useChartPlugins = ({ options, resetZoom: resetZoom2 }) => {
@@ -25423,25 +25422,31 @@ const useStoreChartStateInStorage = (memoState, persistenceId) => {
25423
25422
  ]);
25424
25423
  };
25425
25424
  const useUpdateAxesRanges = (range, dispatch) => {
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)) {
25433
- dispatch({
25434
- type: UPDATE_AXES_RANGES,
25435
- payload: { axes }
25436
- });
25437
- prevAxes.current = axes;
25438
- }
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]);
25439
25443
  };
25440
25444
  const useSaveInitialAxesRanges = (chartRef, axes, generatedDatasets, dispatch) => {
25441
25445
  const prevGeneratedDatasets = useRef();
25442
25446
  const saveInitialAxesRanges = useCallback(() => {
25443
25447
  if (chartRef && !isEqual(generatedDatasets, prevGeneratedDatasets.current)) {
25444
25448
  const initialAxesRanges = getAxesRangesFromChart(chartRef, axes);
25449
+ console.log("initialAxesRanges", initialAxesRanges);
25445
25450
  dispatch({
25446
25451
  type: SAVE_INITIAL_AXES_RANGES,
25447
25452
  payload: { initialAxesRanges }
@@ -25464,7 +25469,7 @@ const useChartState = ({
25464
25469
  const memoState = useMemo(() => state, [state]);
25465
25470
  const memoOptions = useMemo(() => options, [options]);
25466
25471
  const {
25467
- additionalAxesOptions: { range = null },
25472
+ additionalAxesOptions: { range = void 0 },
25468
25473
  axes
25469
25474
  } = memoOptions;
25470
25475
  useStoreChartStateInStorage(memoState, persistenceId);
@@ -25724,6 +25729,8 @@ const LineChart = (props) => {
25724
25729
  generatedDatasets
25725
25730
  });
25726
25731
  const usePlugins = useChartPlugins({ options, resetZoom: resetZoom2 });
25732
+ console.log("State", state);
25733
+ console.log("options", options);
25727
25734
  return /* @__PURE__ */ jsxs(
25728
25735
  "div",
25729
25736
  {