@app-studio/web 0.9.49 → 0.9.50

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.
@@ -6504,12 +6504,14 @@
6504
6504
  var groupWidth = chartWidth / barCount;
6505
6505
  var barWidth = groupWidth * 0.8 / seriesCount;
6506
6506
  var barSpacing = groupWidth * 0.2 / (seriesCount + 1);
6507
+ // Calculate effective max value
6508
+ var effectiveMaxValue = maxValue || 10;
6507
6509
  // Generate y-axis ticks
6508
6510
  var yAxisTicks = React.useMemo(() => {
6509
6511
  var tickCount = 5;
6510
6512
  var ticks = [];
6511
6513
  for (var i = 0; i <= tickCount; i++) {
6512
- var value = maxValue / tickCount * i;
6514
+ var value = effectiveMaxValue / tickCount * i;
6513
6515
  ticks.push(value);
6514
6516
  }
6515
6517
  return ticks;
@@ -6542,7 +6544,7 @@
6542
6544
  }
6543
6545
  }), label);
6544
6546
  }), yAxisTicks.map((tick, index) => {
6545
- var y = height - padding.bottom - tick / maxValue * chartHeight;
6547
+ var y = height - padding.bottom - tick / effectiveMaxValue * chartHeight;
6546
6548
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, {
6547
6549
  key: "y-tick-" + index
6548
6550
  }, /*#__PURE__*/React__default.createElement("text", Object.assign({
@@ -6564,7 +6566,7 @@
6564
6566
  }), data.series.map((series, seriesIndex) => (/*#__PURE__*/React__default.createElement(React__default.Fragment, {
6565
6567
  key: "series-" + seriesIndex
6566
6568
  }, series.data.map((value, dataIndex) => {
6567
- var barHeight = value / maxValue * chartHeight * animationProgress;
6569
+ var barHeight = value / effectiveMaxValue * chartHeight * animationProgress;
6568
6570
  var x = padding.left + dataIndex * groupWidth + barSpacing * (seriesIndex + 1) + barWidth * seriesIndex;
6569
6571
  var y = height - padding.bottom - barHeight;
6570
6572
  var categoryLabel = data.labels[dataIndex];
@@ -6677,12 +6679,14 @@
6677
6679
  });
6678
6680
  return max;
6679
6681
  }, [data]);
6682
+ // Calculate effective max value
6683
+ var effectiveMaxValue = maxValue || 10;
6680
6684
  // Generate y-axis ticks
6681
6685
  var yAxisTicks = React.useMemo(() => {
6682
6686
  var tickCount = 5;
6683
6687
  var ticks = [];
6684
6688
  for (var i = 0; i <= tickCount; i++) {
6685
- var value = maxValue / tickCount * i;
6689
+ var value = effectiveMaxValue / tickCount * i;
6686
6690
  ticks.push(value);
6687
6691
  }
6688
6692
  return ticks;
@@ -6691,7 +6695,7 @@
6691
6695
  var generatePath = series => {
6692
6696
  var points = series.map((value, index) => {
6693
6697
  var x = padding.left + index / (data.labels.length - 1) * chartWidth;
6694
- var y = height - padding.bottom - value / maxValue * chartHeight * animationProgress;
6698
+ var y = height - padding.bottom - value / effectiveMaxValue * chartHeight * animationProgress;
6695
6699
  return x + "," + y;
6696
6700
  });
6697
6701
  return "M " + points.join(' L ');
@@ -6703,7 +6707,7 @@
6703
6707
  var baseY = height - padding.bottom;
6704
6708
  var points = series.map((value, index) => {
6705
6709
  var x = padding.left + index / (data.labels.length - 1) * chartWidth;
6706
- var y = height - padding.bottom - value / maxValue * chartHeight * animationProgress;
6710
+ var y = height - padding.bottom - value / effectiveMaxValue * chartHeight * animationProgress;
6707
6711
  return x + "," + y;
6708
6712
  });
6709
6713
  return "M " + startX + "," + baseY + " L " + points.join(' L ') + " L " + endX + "," + baseY + " Z";
@@ -6736,7 +6740,7 @@
6736
6740
  }
6737
6741
  }), label);
6738
6742
  }), yAxisTicks.map((tick, index) => {
6739
- var y = height - padding.bottom - tick / maxValue * chartHeight;
6743
+ var y = height - padding.bottom - tick / effectiveMaxValue * chartHeight;
6740
6744
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, {
6741
6745
  key: "y-tick-" + index
6742
6746
  }, /*#__PURE__*/React__default.createElement("text", Object.assign({
@@ -6768,7 +6772,7 @@
6768
6772
  stroke: lineColor
6769
6773
  }, LineStyles, views == null ? void 0 : views.line)), series.data.map((value, dataIndex) => {
6770
6774
  var x = padding.left + dataIndex / (data.labels.length - 1) * chartWidth;
6771
- var y = height - padding.bottom - value / maxValue * chartHeight * animationProgress;
6775
+ var y = height - padding.bottom - value / effectiveMaxValue * chartHeight * animationProgress;
6772
6776
  var categoryLabel = data.labels[dataIndex];
6773
6777
  var categoryTotal = data.series.reduce((sum, currentSeries) => {
6774
6778
  var seriesValue = currentSeries.data[dataIndex];
@@ -6900,6 +6904,22 @@
6900
6904
  }, [dataPoints]);
6901
6905
  // Generate pie slices
6902
6906
  var slices = React.useMemo(() => {
6907
+ if (total === 0) {
6908
+ // Return a single placeholder slice
6909
+ var path = isDonut ? ["M " + centerX + " " + (centerY - radius), "A " + radius + " " + radius + " 0 1 1 " + centerX + " " + (centerY + radius), "A " + radius + " " + radius + " 0 1 1 " + centerX + " " + (centerY - radius), "M " + centerX + " " + (centerY - donutRadius), "A " + donutRadius + " " + donutRadius + " 0 1 0 " + centerX + " " + (centerY + donutRadius), "A " + donutRadius + " " + donutRadius + " 0 1 0 " + centerX + " " + (centerY - donutRadius), 'Z'].join(' ') : ["M " + centerX + " " + centerY, "M " + centerX + " " + (centerY - radius), "A " + radius + " " + radius + " 0 1 1 " + centerX + " " + (centerY + radius), "A " + radius + " " + radius + " 0 1 1 " + centerX + " " + (centerY - radius), 'Z'].join(' ');
6910
+ return [{
6911
+ path,
6912
+ color: '#E2E8F0',
6913
+ label: 'Total',
6914
+ value: 0,
6915
+ percentage: '0%',
6916
+ labelX: centerX,
6917
+ labelY: centerY,
6918
+ startAngle: 0,
6919
+ endAngle: Math.PI * 2,
6920
+ index: -1
6921
+ }];
6922
+ }
6903
6923
  var result = [];
6904
6924
  var startAngle = -Math.PI / 2; // Start from top (12 o'clock position)
6905
6925
  for (var i = 0; i < dataPoints.length; i++) {
@@ -6920,13 +6940,13 @@
6920
6940
  // Create arc flag
6921
6941
  var largeArcFlag = angle > Math.PI ? 1 : 0;
6922
6942
  // Create path
6923
- var path = void 0;
6943
+ var _path = void 0;
6924
6944
  if (isDonut) {
6925
6945
  // Donut slice path
6926
- path = ["M " + startX + " " + startY, "A " + radius + " " + radius + " 0 " + largeArcFlag + " 1 " + endX + " " + endY, "L " + innerEndX + " " + innerEndY, "A " + donutRadius + " " + donutRadius + " 0 " + largeArcFlag + " 0 " + innerStartX + " " + innerStartY, 'Z'].join(' ');
6946
+ _path = ["M " + startX + " " + startY, "A " + radius + " " + radius + " 0 " + largeArcFlag + " 1 " + endX + " " + endY, "L " + innerEndX + " " + innerEndY, "A " + donutRadius + " " + donutRadius + " 0 " + largeArcFlag + " 0 " + innerStartX + " " + innerStartY, 'Z'].join(' ');
6927
6947
  } else {
6928
6948
  // Regular pie slice path
6929
- path = ["M " + centerX + " " + centerY, "L " + startX + " " + startY, "A " + radius + " " + radius + " 0 " + largeArcFlag + " 1 " + endX + " " + endY, 'Z'].join(' ');
6949
+ _path = ["M " + centerX + " " + centerY, "L " + startX + " " + startY, "A " + radius + " " + radius + " 0 " + largeArcFlag + " 1 " + endX + " " + endY, 'Z'].join(' ');
6930
6950
  }
6931
6951
  // Calculate label position
6932
6952
  var labelAngle = startAngle + angle / 2;
@@ -6940,7 +6960,7 @@
6940
6960
  // Resolve the color through the theme system
6941
6961
  var resolvedColor = getColor(colorValue);
6942
6962
  result.push({
6943
- path,
6963
+ path: _path,
6944
6964
  color: resolvedColor,
6945
6965
  label: dataPoints[i].label,
6946
6966
  value: dataPoints[i].value,
@@ -7047,19 +7067,24 @@
7047
7067
  showTooltip(x, y, tooltipContent);
7048
7068
  };
7049
7069
  var handleClick = () => {
7050
- if (onSliceClick) {
7070
+ if (slice.index !== -1 && onSliceClick) {
7051
7071
  onSliceClick(dataPoints[slice.index], slice.index);
7052
7072
  }
7053
7073
  };
7074
+ var isPlaceholder = slice.index === -1;
7054
7075
  return /*#__PURE__*/React__default.createElement("g", {
7055
7076
  key: "slice-" + index
7056
7077
  }, /*#__PURE__*/React__default.createElement("path", Object.assign({
7057
7078
  d: slice.path,
7058
7079
  fill: slice.color,
7059
- onMouseEnter: handleMouseEnter,
7060
- onMouseLeave: hideTooltip,
7080
+ onMouseEnter: !isPlaceholder ? handleMouseEnter : undefined,
7081
+ onMouseLeave: !isPlaceholder ? hideTooltip : undefined,
7061
7082
  onClick: handleClick
7062
- }, PieSliceStyles, views == null ? void 0 : views.pie)), slice.endAngle - slice.startAngle > 0.2 && (/*#__PURE__*/React__default.createElement("text", {
7083
+ }, PieSliceStyles, {
7084
+ style: Object.assign({}, PieSliceStyles == null ? void 0 : PieSliceStyles.style, {
7085
+ cursor: isPlaceholder ? 'default' : 'pointer'
7086
+ })
7087
+ }, views == null ? void 0 : views.pie)), !isPlaceholder && slice.endAngle - slice.startAngle > 0.2 && (/*#__PURE__*/React__default.createElement("text", {
7063
7088
  x: slice.labelX,
7064
7089
  y: slice.labelY,
7065
7090
  textAnchor: "middle",