Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 默默修复颜色问题,定义不同映射颜色的key #1598

Merged
merged 1 commit into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions __tests__/unit/plots/bullet/data-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/plots/bullet/adaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function geometry(params: Params<BulletOptions>): Params<BulletOptions> {
options: {
xField: xField,
yField: rangeField,
seriesField: 'index',
seriesField: 'rKey',
isStack: true,
interval: {
color: range.color,
Expand All @@ -58,7 +58,7 @@ function geometry(params: Params<BulletOptions>): Params<BulletOptions> {
options: {
xField: xField,
yField: measureField,
seriesField: 'index',
seriesField: 'mKey',
isStack: true,
interval: {
color: measure.color,
Expand All @@ -74,7 +74,7 @@ function geometry(params: Params<BulletOptions>): Params<BulletOptions> {
options: {
xField: xField,
yField: targetField,
seriesField: targetField,
seriesField: 'tKey',
point: {
color: target.color,
style: target.style,
Expand Down
6 changes: 3 additions & 3 deletions src/plots/bullet/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ 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,
});
});
// 构建 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],
});
Expand Down