diff --git a/__tests__/unit/plots/bullet/data-spec.ts b/__tests__/unit/plots/bullet/data-spec.ts index 3d0ddd5a08..aeb8b3f0d2 100644 --- a/__tests__/unit/plots/bullet/data-spec.ts +++ b/__tests__/unit/plots/bullet/data-spec.ts @@ -22,27 +22,27 @@ describe('bullet*data*transfrom', () => { { title: '数学', ranges: 30, - index: 'ranges_0', + rKey: 'ranges_0', }, { title: '数学', ranges: 20, - index: 'ranges_1', + rKey: 'ranges_1', }, { title: '数学', ranges: 50, - index: 'ranges_2', + rKey: 'ranges_2', }, { title: '数学', measures: 20, - index: 'measures', // 只有一个数据 + mKey: 'measures', // 只有一个数据 }, { title: '数学', target: 85, - index: 'target', + tKey: 'target', }, ]; expect(ds).toEqual(transDS); @@ -69,37 +69,37 @@ describe('bullet*data*transfrom', () => { { subTitle: 'g2', count: 30, - index: 'count_0', + rKey: 'count_0', }, { subTitle: 'g2', count: 20, - index: 'count_1', + rKey: 'count_1', }, { subTitle: 'g2', count: 50, - index: 'count_2', + rKey: 'count_2', }, { subTitle: 'g2', count: 50, - index: 'count_3', + rKey: 'count_3', }, { subTitle: 'g2', measures: 20, - index: 'measures_0', // 多个数据 + mKey: 'measures_0', // 多个数据 }, { subTitle: 'g2', measures: 30, - index: 'measures_1', + mKey: 'measures_1', }, { subTitle: 'g2', target: 85, - index: 'target', + tKey: 'target', }, ]; expect(ds).toEqual(transDS); diff --git a/src/plots/bullet/adaptor.ts b/src/plots/bullet/adaptor.ts index df5e74f294..52bd5a316f 100644 --- a/src/plots/bullet/adaptor.ts +++ b/src/plots/bullet/adaptor.ts @@ -40,7 +40,7 @@ function geometry(params: Params): Params { options: { xField: xField, yField: rangeField, - seriesField: 'index', + seriesField: 'rKey', isStack: true, interval: { color: range.color, @@ -58,7 +58,7 @@ function geometry(params: Params): Params { options: { xField: xField, yField: measureField, - seriesField: 'index', + seriesField: 'mKey', isStack: true, interval: { color: measure.color, @@ -74,7 +74,7 @@ function geometry(params: Params): Params { options: { xField: xField, yField: targetField, - seriesField: targetField, + seriesField: 'tKey', point: { color: target.color, style: target.style, diff --git a/src/plots/bullet/utils.ts b/src/plots/bullet/utils.ts index 66cef42674..3e83a9f973 100644 --- a/src/plots/bullet/utils.ts +++ b/src/plots/bullet/utils.ts @@ -19,7 +19,7 @@ export function transformData(options: BulletOptions): TransformData { item[rangeField].forEach((d: number, i: number) => { const range = i === 0 ? d : item[rangeField][i] - item[rangeField][i - 1]; ds.push({ - index: `${rangeField}_${i}`, + rKey: `${rangeField}_${i}`, [xField]: xField ? item[xField] : String(index), // 没有xField就用索引 [rangeField]: range, }); @@ -27,14 +27,14 @@ export function transformData(options: BulletOptions): TransformData { // 构建 title * measure item[measureField].forEach((d: number, i: number) => { ds.push({ - index: item[measureField].length > 1 ? `${measureField}_${i}` : `${measureField}`, // 一个数据就不带索引了 + mKey: item[measureField].length > 1 ? `${measureField}_${i}` : `${measureField}`, // 一个数据就不带索引了 [xField]: xField ? item[xField] : String(index), [measureField]: d, }); }); // 构建 title * target ds.push({ - index: `${targetField}`, + tKey: `${targetField}`, [xField]: xField ? item[xField] : String(index), [targetField]: item[targetField], });