@easyv/charts 1.10.28 → 1.10.30
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/lib/components/CartesianChart.js +26 -4
- package/lib/components/Control.js +7 -0
- package/lib/components/Legend.js +42 -21
- package/lib/components/PieChart.js +2 -2
- package/lib/utils/index.js +31 -1
- package/package.json +2 -2
- package/src/components/CartesianChart.js +35 -2
- package/src/components/Control.jsx +7 -1
- package/src/components/Legend.js +101 -84
- package/src/components/PieChart.js +1629 -1629
- package/src/utils/index.js +26 -0
package/src/utils/index.js
CHANGED
|
@@ -897,6 +897,31 @@ const mathR = (value, range) => {
|
|
|
897
897
|
return Math.max(min, Math.min(value, max));
|
|
898
898
|
};
|
|
899
899
|
|
|
900
|
+
/**
|
|
901
|
+
* 根据控制条位置计算当前图表视口内可见的原始数据
|
|
902
|
+
*/
|
|
903
|
+
const getControlVisibleData = (originData, axisX, controlInfo, chartWidth) => {
|
|
904
|
+
if (!originData?.length || !axisX || !controlInfo) return [];
|
|
905
|
+
|
|
906
|
+
const { cBarX, cBarWidth, cWidth, cPercent } = controlInfo;
|
|
907
|
+
const { controlEnd, start, scaler, step = 0 } = axisX;
|
|
908
|
+
const slideRange = cWidth - cBarWidth;
|
|
909
|
+
const percent = slideRange > 0 ? cBarX / slideRange : 0;
|
|
910
|
+
const safeCPercent = cPercent > 0 && Number.isFinite(cPercent) ? cPercent : 1;
|
|
911
|
+
const span = controlEnd + start / safeCPercent - chartWidth;
|
|
912
|
+
const translateX = Number.isFinite(span) ? -span * percent : 0;
|
|
913
|
+
const clipLeft = Number.isFinite(-translateX) ? -translateX : 0;
|
|
914
|
+
const clipRight = clipLeft + chartWidth;
|
|
915
|
+
const halfStep = Number.isFinite(step) ? step / 2 : 0;
|
|
916
|
+
|
|
917
|
+
return originData.filter((d) => {
|
|
918
|
+
if (d?.x === undefined) return false;
|
|
919
|
+
const pos = scaler(d.x);
|
|
920
|
+
if (!Number.isFinite(pos)) return false;
|
|
921
|
+
return pos + halfStep >= clipLeft && pos - halfStep <= clipRight;
|
|
922
|
+
});
|
|
923
|
+
};
|
|
924
|
+
|
|
900
925
|
export {
|
|
901
926
|
dateFormat,
|
|
902
927
|
getBreakWord,
|
|
@@ -931,6 +956,7 @@ export {
|
|
|
931
956
|
reduceConfig,
|
|
932
957
|
getSeriesInfo,
|
|
933
958
|
mathR,
|
|
959
|
+
getControlVisibleData,
|
|
934
960
|
renderCanvasBackground, // 导出 Canvas 绘制方法
|
|
935
961
|
SvgBackground,
|
|
936
962
|
reverseGradientStops,
|