From f14f97dcd4283f37be34f8946f2a9cd599d886e6 Mon Sep 17 00:00:00 2001 From: arcsin1 Date: Fri, 18 Sep 2020 16:34:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=BB=98=E9=BB=98=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=A2=9C=E8=89=B2=E9=97=AE=E9=A2=98=EF=BC=8C=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E4=B8=8D=E5=90=8C=E6=98=A0=E5=B0=84=E9=A2=9C=E8=89=B2=E7=9A=84?= =?UTF-8?q?key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __tests__/unit/plots/bullet/data-spec.ts | 24 ++++++++++++------------ src/plots/bullet/adaptor.ts | 6 +++--- src/plots/bullet/utils.ts | 6 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) 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], });