@app-studio/web 0.9.48 → 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 +58 -25
- 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 +58 -25
- package/dist/web.esm.js.map +1 -1
- package/dist/web.umd.development.js +58 -25
- 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
|
@@ -4914,17 +4914,28 @@ var getButtonVariants = function getButtonVariants(color, isLight, isThemeLight)
|
|
|
4914
4914
|
borderStyle: 'solid',
|
|
4915
4915
|
borderColor: 'transparent',
|
|
4916
4916
|
_hover: {
|
|
4917
|
-
opacity: 0.9
|
|
4918
|
-
color: textColor
|
|
4917
|
+
opacity: 0.9
|
|
4919
4918
|
},
|
|
4920
4919
|
_active: {
|
|
4921
|
-
opacity: 0.95
|
|
4922
|
-
color: textColor
|
|
4920
|
+
opacity: 0.95
|
|
4923
4921
|
},
|
|
4924
4922
|
_focusVisible: {
|
|
4925
4923
|
outline: 'none',
|
|
4926
|
-
boxShadow: "0 0 0 2px rgba(255, 255, 255, 1), 0 0 0 4px " + color
|
|
4927
|
-
|
|
4924
|
+
boxShadow: "0 0 0 2px rgba(255, 255, 255, 1), 0 0 0 4px " + color
|
|
4925
|
+
},
|
|
4926
|
+
transition: 'background-color 0.2s ease, opacity 0.2s ease'
|
|
4927
|
+
},
|
|
4928
|
+
reversed: {
|
|
4929
|
+
backgroundColor: textColor,
|
|
4930
|
+
color: color,
|
|
4931
|
+
borderWidth: 1,
|
|
4932
|
+
borderStyle: 'solid',
|
|
4933
|
+
borderColor: textColor,
|
|
4934
|
+
_hover: {
|
|
4935
|
+
opacity: 0.9
|
|
4936
|
+
},
|
|
4937
|
+
_active: {
|
|
4938
|
+
opacity: 0.95
|
|
4928
4939
|
},
|
|
4929
4940
|
transition: 'background-color 0.2s ease, opacity 0.2s ease'
|
|
4930
4941
|
},
|
|
@@ -4964,7 +4975,6 @@ var getButtonVariants = function getButtonVariants(color, isLight, isThemeLight)
|
|
|
4964
4975
|
opacity: 0.9
|
|
4965
4976
|
},
|
|
4966
4977
|
_active: {
|
|
4967
|
-
color: color,
|
|
4968
4978
|
opacity: 0.95
|
|
4969
4979
|
},
|
|
4970
4980
|
_focusVisible: {
|
|
@@ -4984,11 +4994,9 @@ var getButtonVariants = function getButtonVariants(color, isLight, isThemeLight)
|
|
|
4984
4994
|
textDecorationThickness: '1px',
|
|
4985
4995
|
textDecorationColor: color,
|
|
4986
4996
|
_hover: {
|
|
4987
|
-
color: color,
|
|
4988
4997
|
opacity: 0.8
|
|
4989
4998
|
},
|
|
4990
4999
|
_active: {
|
|
4991
|
-
color: color,
|
|
4992
5000
|
opacity: 0.9
|
|
4993
5001
|
},
|
|
4994
5002
|
_focusVisible: {
|
|
@@ -6528,12 +6536,14 @@ var BarChart = _ref => {
|
|
|
6528
6536
|
var groupWidth = chartWidth / barCount;
|
|
6529
6537
|
var barWidth = groupWidth * 0.8 / seriesCount;
|
|
6530
6538
|
var barSpacing = groupWidth * 0.2 / (seriesCount + 1);
|
|
6539
|
+
// Calculate effective max value
|
|
6540
|
+
var effectiveMaxValue = maxValue || 10;
|
|
6531
6541
|
// Generate y-axis ticks
|
|
6532
6542
|
var yAxisTicks = useMemo(() => {
|
|
6533
6543
|
var tickCount = 5;
|
|
6534
6544
|
var ticks = [];
|
|
6535
6545
|
for (var i = 0; i <= tickCount; i++) {
|
|
6536
|
-
var value =
|
|
6546
|
+
var value = effectiveMaxValue / tickCount * i;
|
|
6537
6547
|
ticks.push(value);
|
|
6538
6548
|
}
|
|
6539
6549
|
return ticks;
|
|
@@ -6566,7 +6576,7 @@ var BarChart = _ref => {
|
|
|
6566
6576
|
}
|
|
6567
6577
|
}), label);
|
|
6568
6578
|
}), yAxisTicks.map((tick, index) => {
|
|
6569
|
-
var y = height - padding.bottom - tick /
|
|
6579
|
+
var y = height - padding.bottom - tick / effectiveMaxValue * chartHeight;
|
|
6570
6580
|
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
6571
6581
|
key: "y-tick-" + index
|
|
6572
6582
|
}, /*#__PURE__*/React.createElement("text", Object.assign({
|
|
@@ -6588,7 +6598,7 @@ var BarChart = _ref => {
|
|
|
6588
6598
|
}), data.series.map((series, seriesIndex) => (/*#__PURE__*/React.createElement(React.Fragment, {
|
|
6589
6599
|
key: "series-" + seriesIndex
|
|
6590
6600
|
}, series.data.map((value, dataIndex) => {
|
|
6591
|
-
var barHeight = value /
|
|
6601
|
+
var barHeight = value / effectiveMaxValue * chartHeight * animationProgress;
|
|
6592
6602
|
var x = padding.left + dataIndex * groupWidth + barSpacing * (seriesIndex + 1) + barWidth * seriesIndex;
|
|
6593
6603
|
var y = height - padding.bottom - barHeight;
|
|
6594
6604
|
var categoryLabel = data.labels[dataIndex];
|
|
@@ -6701,12 +6711,14 @@ var LineChart = _ref => {
|
|
|
6701
6711
|
});
|
|
6702
6712
|
return max;
|
|
6703
6713
|
}, [data]);
|
|
6714
|
+
// Calculate effective max value
|
|
6715
|
+
var effectiveMaxValue = maxValue || 10;
|
|
6704
6716
|
// Generate y-axis ticks
|
|
6705
6717
|
var yAxisTicks = useMemo(() => {
|
|
6706
6718
|
var tickCount = 5;
|
|
6707
6719
|
var ticks = [];
|
|
6708
6720
|
for (var i = 0; i <= tickCount; i++) {
|
|
6709
|
-
var value =
|
|
6721
|
+
var value = effectiveMaxValue / tickCount * i;
|
|
6710
6722
|
ticks.push(value);
|
|
6711
6723
|
}
|
|
6712
6724
|
return ticks;
|
|
@@ -6715,7 +6727,7 @@ var LineChart = _ref => {
|
|
|
6715
6727
|
var generatePath = series => {
|
|
6716
6728
|
var points = series.map((value, index) => {
|
|
6717
6729
|
var x = padding.left + index / (data.labels.length - 1) * chartWidth;
|
|
6718
|
-
var y = height - padding.bottom - value /
|
|
6730
|
+
var y = height - padding.bottom - value / effectiveMaxValue * chartHeight * animationProgress;
|
|
6719
6731
|
return x + "," + y;
|
|
6720
6732
|
});
|
|
6721
6733
|
return "M " + points.join(' L ');
|
|
@@ -6727,7 +6739,7 @@ var LineChart = _ref => {
|
|
|
6727
6739
|
var baseY = height - padding.bottom;
|
|
6728
6740
|
var points = series.map((value, index) => {
|
|
6729
6741
|
var x = padding.left + index / (data.labels.length - 1) * chartWidth;
|
|
6730
|
-
var y = height - padding.bottom - value /
|
|
6742
|
+
var y = height - padding.bottom - value / effectiveMaxValue * chartHeight * animationProgress;
|
|
6731
6743
|
return x + "," + y;
|
|
6732
6744
|
});
|
|
6733
6745
|
return "M " + startX + "," + baseY + " L " + points.join(' L ') + " L " + endX + "," + baseY + " Z";
|
|
@@ -6760,7 +6772,7 @@ var LineChart = _ref => {
|
|
|
6760
6772
|
}
|
|
6761
6773
|
}), label);
|
|
6762
6774
|
}), yAxisTicks.map((tick, index) => {
|
|
6763
|
-
var y = height - padding.bottom - tick /
|
|
6775
|
+
var y = height - padding.bottom - tick / effectiveMaxValue * chartHeight;
|
|
6764
6776
|
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
6765
6777
|
key: "y-tick-" + index
|
|
6766
6778
|
}, /*#__PURE__*/React.createElement("text", Object.assign({
|
|
@@ -6792,7 +6804,7 @@ var LineChart = _ref => {
|
|
|
6792
6804
|
stroke: lineColor
|
|
6793
6805
|
}, LineStyles, views == null ? void 0 : views.line)), series.data.map((value, dataIndex) => {
|
|
6794
6806
|
var x = padding.left + dataIndex / (data.labels.length - 1) * chartWidth;
|
|
6795
|
-
var y = height - padding.bottom - value /
|
|
6807
|
+
var y = height - padding.bottom - value / effectiveMaxValue * chartHeight * animationProgress;
|
|
6796
6808
|
var categoryLabel = data.labels[dataIndex];
|
|
6797
6809
|
var categoryTotal = data.series.reduce((sum, currentSeries) => {
|
|
6798
6810
|
var seriesValue = currentSeries.data[dataIndex];
|
|
@@ -6924,6 +6936,22 @@ var PieChart = _ref => {
|
|
|
6924
6936
|
}, [dataPoints]);
|
|
6925
6937
|
// Generate pie slices
|
|
6926
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
|
+
}
|
|
6927
6955
|
var result = [];
|
|
6928
6956
|
var startAngle = -Math.PI / 2; // Start from top (12 o'clock position)
|
|
6929
6957
|
for (var i = 0; i < dataPoints.length; i++) {
|
|
@@ -6944,13 +6972,13 @@ var PieChart = _ref => {
|
|
|
6944
6972
|
// Create arc flag
|
|
6945
6973
|
var largeArcFlag = angle > Math.PI ? 1 : 0;
|
|
6946
6974
|
// Create path
|
|
6947
|
-
var
|
|
6975
|
+
var _path = void 0;
|
|
6948
6976
|
if (isDonut) {
|
|
6949
6977
|
// Donut slice path
|
|
6950
|
-
|
|
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(' ');
|
|
6951
6979
|
} else {
|
|
6952
6980
|
// Regular pie slice path
|
|
6953
|
-
|
|
6981
|
+
_path = ["M " + centerX + " " + centerY, "L " + startX + " " + startY, "A " + radius + " " + radius + " 0 " + largeArcFlag + " 1 " + endX + " " + endY, 'Z'].join(' ');
|
|
6954
6982
|
}
|
|
6955
6983
|
// Calculate label position
|
|
6956
6984
|
var labelAngle = startAngle + angle / 2;
|
|
@@ -6964,7 +6992,7 @@ var PieChart = _ref => {
|
|
|
6964
6992
|
// Resolve the color through the theme system
|
|
6965
6993
|
var resolvedColor = getColor(colorValue);
|
|
6966
6994
|
result.push({
|
|
6967
|
-
path,
|
|
6995
|
+
path: _path,
|
|
6968
6996
|
color: resolvedColor,
|
|
6969
6997
|
label: dataPoints[i].label,
|
|
6970
6998
|
value: dataPoints[i].value,
|
|
@@ -7071,19 +7099,24 @@ var PieChart = _ref => {
|
|
|
7071
7099
|
showTooltip(x, y, tooltipContent);
|
|
7072
7100
|
};
|
|
7073
7101
|
var handleClick = () => {
|
|
7074
|
-
if (onSliceClick) {
|
|
7102
|
+
if (slice.index !== -1 && onSliceClick) {
|
|
7075
7103
|
onSliceClick(dataPoints[slice.index], slice.index);
|
|
7076
7104
|
}
|
|
7077
7105
|
};
|
|
7106
|
+
var isPlaceholder = slice.index === -1;
|
|
7078
7107
|
return /*#__PURE__*/React.createElement("g", {
|
|
7079
7108
|
key: "slice-" + index
|
|
7080
7109
|
}, /*#__PURE__*/React.createElement("path", Object.assign({
|
|
7081
7110
|
d: slice.path,
|
|
7082
7111
|
fill: slice.color,
|
|
7083
|
-
onMouseEnter: handleMouseEnter,
|
|
7084
|
-
onMouseLeave: hideTooltip,
|
|
7112
|
+
onMouseEnter: !isPlaceholder ? handleMouseEnter : undefined,
|
|
7113
|
+
onMouseLeave: !isPlaceholder ? hideTooltip : undefined,
|
|
7085
7114
|
onClick: handleClick
|
|
7086
|
-
}, 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", {
|
|
7087
7120
|
x: slice.labelX,
|
|
7088
7121
|
y: slice.labelY,
|
|
7089
7122
|
textAnchor: "middle",
|