@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.
- package/dist/web.cjs.development.js +41 -16
- package/dist/web.cjs.development.js.map +1 -1
- package/dist/web.cjs.production.min.js +1 -1
- package/dist/web.cjs.production.min.js.map +1 -1
- package/dist/web.esm.js +41 -16
- package/dist/web.esm.js.map +1 -1
- package/dist/web.umd.development.js +41 -16
- package/dist/web.umd.development.js.map +1 -1
- package/dist/web.umd.production.min.js +1 -1
- package/dist/web.umd.production.min.js.map +1 -1
- package/docs/components/Chart.mdx +34 -0
- package/package.json +2 -2
package/dist/web.esm.js
CHANGED
|
@@ -6536,12 +6536,14 @@ var BarChart = _ref => {
|
|
|
6536
6536
|
var groupWidth = chartWidth / barCount;
|
|
6537
6537
|
var barWidth = groupWidth * 0.8 / seriesCount;
|
|
6538
6538
|
var barSpacing = groupWidth * 0.2 / (seriesCount + 1);
|
|
6539
|
+
// Calculate effective max value
|
|
6540
|
+
var effectiveMaxValue = maxValue || 10;
|
|
6539
6541
|
// Generate y-axis ticks
|
|
6540
6542
|
var yAxisTicks = useMemo(() => {
|
|
6541
6543
|
var tickCount = 5;
|
|
6542
6544
|
var ticks = [];
|
|
6543
6545
|
for (var i = 0; i <= tickCount; i++) {
|
|
6544
|
-
var value =
|
|
6546
|
+
var value = effectiveMaxValue / tickCount * i;
|
|
6545
6547
|
ticks.push(value);
|
|
6546
6548
|
}
|
|
6547
6549
|
return ticks;
|
|
@@ -6574,7 +6576,7 @@ var BarChart = _ref => {
|
|
|
6574
6576
|
}
|
|
6575
6577
|
}), label);
|
|
6576
6578
|
}), yAxisTicks.map((tick, index) => {
|
|
6577
|
-
var y = height - padding.bottom - tick /
|
|
6579
|
+
var y = height - padding.bottom - tick / effectiveMaxValue * chartHeight;
|
|
6578
6580
|
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
6579
6581
|
key: "y-tick-" + index
|
|
6580
6582
|
}, /*#__PURE__*/React.createElement("text", Object.assign({
|
|
@@ -6596,7 +6598,7 @@ var BarChart = _ref => {
|
|
|
6596
6598
|
}), data.series.map((series, seriesIndex) => (/*#__PURE__*/React.createElement(React.Fragment, {
|
|
6597
6599
|
key: "series-" + seriesIndex
|
|
6598
6600
|
}, series.data.map((value, dataIndex) => {
|
|
6599
|
-
var barHeight = value /
|
|
6601
|
+
var barHeight = value / effectiveMaxValue * chartHeight * animationProgress;
|
|
6600
6602
|
var x = padding.left + dataIndex * groupWidth + barSpacing * (seriesIndex + 1) + barWidth * seriesIndex;
|
|
6601
6603
|
var y = height - padding.bottom - barHeight;
|
|
6602
6604
|
var categoryLabel = data.labels[dataIndex];
|
|
@@ -6709,12 +6711,14 @@ var LineChart = _ref => {
|
|
|
6709
6711
|
});
|
|
6710
6712
|
return max;
|
|
6711
6713
|
}, [data]);
|
|
6714
|
+
// Calculate effective max value
|
|
6715
|
+
var effectiveMaxValue = maxValue || 10;
|
|
6712
6716
|
// Generate y-axis ticks
|
|
6713
6717
|
var yAxisTicks = useMemo(() => {
|
|
6714
6718
|
var tickCount = 5;
|
|
6715
6719
|
var ticks = [];
|
|
6716
6720
|
for (var i = 0; i <= tickCount; i++) {
|
|
6717
|
-
var value =
|
|
6721
|
+
var value = effectiveMaxValue / tickCount * i;
|
|
6718
6722
|
ticks.push(value);
|
|
6719
6723
|
}
|
|
6720
6724
|
return ticks;
|
|
@@ -6723,7 +6727,7 @@ var LineChart = _ref => {
|
|
|
6723
6727
|
var generatePath = series => {
|
|
6724
6728
|
var points = series.map((value, index) => {
|
|
6725
6729
|
var x = padding.left + index / (data.labels.length - 1) * chartWidth;
|
|
6726
|
-
var y = height - padding.bottom - value /
|
|
6730
|
+
var y = height - padding.bottom - value / effectiveMaxValue * chartHeight * animationProgress;
|
|
6727
6731
|
return x + "," + y;
|
|
6728
6732
|
});
|
|
6729
6733
|
return "M " + points.join(' L ');
|
|
@@ -6735,7 +6739,7 @@ var LineChart = _ref => {
|
|
|
6735
6739
|
var baseY = height - padding.bottom;
|
|
6736
6740
|
var points = series.map((value, index) => {
|
|
6737
6741
|
var x = padding.left + index / (data.labels.length - 1) * chartWidth;
|
|
6738
|
-
var y = height - padding.bottom - value /
|
|
6742
|
+
var y = height - padding.bottom - value / effectiveMaxValue * chartHeight * animationProgress;
|
|
6739
6743
|
return x + "," + y;
|
|
6740
6744
|
});
|
|
6741
6745
|
return "M " + startX + "," + baseY + " L " + points.join(' L ') + " L " + endX + "," + baseY + " Z";
|
|
@@ -6768,7 +6772,7 @@ var LineChart = _ref => {
|
|
|
6768
6772
|
}
|
|
6769
6773
|
}), label);
|
|
6770
6774
|
}), yAxisTicks.map((tick, index) => {
|
|
6771
|
-
var y = height - padding.bottom - tick /
|
|
6775
|
+
var y = height - padding.bottom - tick / effectiveMaxValue * chartHeight;
|
|
6772
6776
|
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
6773
6777
|
key: "y-tick-" + index
|
|
6774
6778
|
}, /*#__PURE__*/React.createElement("text", Object.assign({
|
|
@@ -6800,7 +6804,7 @@ var LineChart = _ref => {
|
|
|
6800
6804
|
stroke: lineColor
|
|
6801
6805
|
}, LineStyles, views == null ? void 0 : views.line)), series.data.map((value, dataIndex) => {
|
|
6802
6806
|
var x = padding.left + dataIndex / (data.labels.length - 1) * chartWidth;
|
|
6803
|
-
var y = height - padding.bottom - value /
|
|
6807
|
+
var y = height - padding.bottom - value / effectiveMaxValue * chartHeight * animationProgress;
|
|
6804
6808
|
var categoryLabel = data.labels[dataIndex];
|
|
6805
6809
|
var categoryTotal = data.series.reduce((sum, currentSeries) => {
|
|
6806
6810
|
var seriesValue = currentSeries.data[dataIndex];
|
|
@@ -6932,6 +6936,22 @@ var PieChart = _ref => {
|
|
|
6932
6936
|
}, [dataPoints]);
|
|
6933
6937
|
// Generate pie slices
|
|
6934
6938
|
var slices = useMemo(() => {
|
|
6939
|
+
if (total === 0) {
|
|
6940
|
+
// Return a single placeholder slice
|
|
6941
|
+
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(' ');
|
|
6942
|
+
return [{
|
|
6943
|
+
path,
|
|
6944
|
+
color: '#E2E8F0',
|
|
6945
|
+
label: 'Total',
|
|
6946
|
+
value: 0,
|
|
6947
|
+
percentage: '0%',
|
|
6948
|
+
labelX: centerX,
|
|
6949
|
+
labelY: centerY,
|
|
6950
|
+
startAngle: 0,
|
|
6951
|
+
endAngle: Math.PI * 2,
|
|
6952
|
+
index: -1
|
|
6953
|
+
}];
|
|
6954
|
+
}
|
|
6935
6955
|
var result = [];
|
|
6936
6956
|
var startAngle = -Math.PI / 2; // Start from top (12 o'clock position)
|
|
6937
6957
|
for (var i = 0; i < dataPoints.length; i++) {
|
|
@@ -6952,13 +6972,13 @@ var PieChart = _ref => {
|
|
|
6952
6972
|
// Create arc flag
|
|
6953
6973
|
var largeArcFlag = angle > Math.PI ? 1 : 0;
|
|
6954
6974
|
// Create path
|
|
6955
|
-
var
|
|
6975
|
+
var _path = void 0;
|
|
6956
6976
|
if (isDonut) {
|
|
6957
6977
|
// Donut slice path
|
|
6958
|
-
|
|
6978
|
+
_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(' ');
|
|
6959
6979
|
} else {
|
|
6960
6980
|
// Regular pie slice path
|
|
6961
|
-
|
|
6981
|
+
_path = ["M " + centerX + " " + centerY, "L " + startX + " " + startY, "A " + radius + " " + radius + " 0 " + largeArcFlag + " 1 " + endX + " " + endY, 'Z'].join(' ');
|
|
6962
6982
|
}
|
|
6963
6983
|
// Calculate label position
|
|
6964
6984
|
var labelAngle = startAngle + angle / 2;
|
|
@@ -6972,7 +6992,7 @@ var PieChart = _ref => {
|
|
|
6972
6992
|
// Resolve the color through the theme system
|
|
6973
6993
|
var resolvedColor = getColor(colorValue);
|
|
6974
6994
|
result.push({
|
|
6975
|
-
path,
|
|
6995
|
+
path: _path,
|
|
6976
6996
|
color: resolvedColor,
|
|
6977
6997
|
label: dataPoints[i].label,
|
|
6978
6998
|
value: dataPoints[i].value,
|
|
@@ -7079,19 +7099,24 @@ var PieChart = _ref => {
|
|
|
7079
7099
|
showTooltip(x, y, tooltipContent);
|
|
7080
7100
|
};
|
|
7081
7101
|
var handleClick = () => {
|
|
7082
|
-
if (onSliceClick) {
|
|
7102
|
+
if (slice.index !== -1 && onSliceClick) {
|
|
7083
7103
|
onSliceClick(dataPoints[slice.index], slice.index);
|
|
7084
7104
|
}
|
|
7085
7105
|
};
|
|
7106
|
+
var isPlaceholder = slice.index === -1;
|
|
7086
7107
|
return /*#__PURE__*/React.createElement("g", {
|
|
7087
7108
|
key: "slice-" + index
|
|
7088
7109
|
}, /*#__PURE__*/React.createElement("path", Object.assign({
|
|
7089
7110
|
d: slice.path,
|
|
7090
7111
|
fill: slice.color,
|
|
7091
|
-
onMouseEnter: handleMouseEnter,
|
|
7092
|
-
onMouseLeave: hideTooltip,
|
|
7112
|
+
onMouseEnter: !isPlaceholder ? handleMouseEnter : undefined,
|
|
7113
|
+
onMouseLeave: !isPlaceholder ? hideTooltip : undefined,
|
|
7093
7114
|
onClick: handleClick
|
|
7094
|
-
}, PieSliceStyles,
|
|
7115
|
+
}, PieSliceStyles, {
|
|
7116
|
+
style: Object.assign({}, PieSliceStyles == null ? void 0 : PieSliceStyles.style, {
|
|
7117
|
+
cursor: isPlaceholder ? 'default' : 'pointer'
|
|
7118
|
+
})
|
|
7119
|
+
}, views == null ? void 0 : views.pie)), !isPlaceholder && slice.endAngle - slice.startAngle > 0.2 && (/*#__PURE__*/React.createElement("text", {
|
|
7095
7120
|
x: slice.labelX,
|
|
7096
7121
|
y: slice.labelY,
|
|
7097
7122
|
textAnchor: "middle",
|