Browse Source

✨ feat(charts): 为多个数据点生成函数添加动画进度参数

- 在 `getDataPoints`、`getMountDataPoints`、`getBarDataPoints`、`getStackDataPoints` 和 `getBarStackDataPoints` 函数签名中添加可选的 `process` 参数,默认值为1
- 更新 `getDataPoints` 函数的JSDoc注释,说明新增的 `process` 参数
yourname 3 weeks ago
parent
commit
70e6af7252
1 changed files with 11 additions and 5 deletions
  1. 11 5
      mini-ui-packages/mini-charts/src/lib/charts-data/basic-charts.ts

+ 11 - 5
mini-ui-packages/mini-charts/src/lib/charts-data/basic-charts.ts

@@ -183,6 +183,7 @@ export function getCandleDataPoints(
  * @param eachSpacing - 每个点之间的间距
  * @param opts - 图表配置
  * @param config - uCharts配置
+ * @param process - 动画进度(默认为1)
  * @returns 数据点数组
  */
 export function getDataPoints(
@@ -192,7 +193,8 @@ export function getDataPoints(
   xAxisPoints: number[],
   eachSpacing: number,
   opts: ChartOptions,
-  config: UChartsConfig
+  config: UChartsConfig,
+  process = 1
 ): (DataPoint | null)[] {
   let boundaryGap = 'center';
   if (opts.type == 'line' || opts.type == 'area' || opts.type == 'scatter' || opts.type == 'bubble' ) {
@@ -399,7 +401,8 @@ export function getMountDataPoints(
   eachSpacing: number,
   opts: ChartOptions,
   mountOption: MountOption,
-  zeroPoints: number[]
+  zeroPoints: number[],
+  process = 1
 ): (MountDataPoint | null)[] {
   let points: (MountDataPoint | null)[] = [];
   let validHeight = opts.height - opts.area[0] - opts.area[2];
@@ -442,7 +445,8 @@ export function getBarDataPoints(
   yAxisPoints: number[],
   eachSpacing: number,
   opts: ChartOptions,
-  config: UChartsConfig
+  config: UChartsConfig,
+  process = 1
 ): DataPoint[] {
   let points: DataPoint[] = [];
   let validHeight = opts.height - opts.area[0] - opts.area[2];
@@ -497,7 +501,8 @@ export function getStackDataPoints(
   opts: ChartOptions,
   config: UChartsConfig,
   seriesIndex: number,
-  stackSeries: SeriesItem[]
+  stackSeries: SeriesItem[],
+  process = 1
 ): (StackDataPoint | null)[] {
   let points: (StackDataPoint | null)[] = [];
   let validHeight = opts.height - opts.area[0] - opts.area[2];
@@ -558,7 +563,8 @@ export function getBarStackDataPoints(
   opts: ChartOptions,
   config: UChartsConfig,
   seriesIndex: number,
-  stackSeries: SeriesItem[]
+  stackSeries: SeriesItem[],
+  process = 1
 ): (BarStackDataPoint | null)[] {
   let points: (BarStackDataPoint | null)[] = [];
   let validHeight = opts.width - opts.area[1] - opts.area[3];