Skip to content

Commit c47329f

Browse files
authored
fix(radial-bar): 修复line类型的珏玦图,设置color对point不生效 (#2185)
1 parent 20ad2c6 commit c47329f

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

__tests__/unit/plots/radial-bar/index-spec.ts

+19
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,23 @@ describe('radial-bar', () => {
8484
expect(bar.chart.getController('annotation').getComponents()[0].component.get('content')).toBe('Music');
8585
bar.destroy();
8686
});
87+
88+
it('展示形式为 line,自动带 point 且颜色可以对应上', () => {
89+
const bar = new RadialBar(createDiv(), {
90+
width: 400,
91+
height: 300,
92+
data: antvStar,
93+
xField,
94+
yField,
95+
type: 'line',
96+
color: (datum) => (datum[yField] < 800 ? 'red' : 'green'),
97+
});
98+
bar.render();
99+
const line = bar.chart.geometries[0];
100+
const point = bar.chart.geometries[1];
101+
expect(line.attributes.shape.values[0]).toBe('line');
102+
expect(point.type).toBe('point');
103+
line.elements.forEach((ele, idx) => expect(ele.shape.attr('color')).toBe(point.elements[idx].shape.attr('color')));
104+
bar.destroy();
105+
});
87106
});

src/plots/radial-bar/adaptor.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { interaction, animation, theme, scale, tooltip, legend, annotation } from '../../adaptor/common';
22
import { Params } from '../../core/adaptor';
33
import { flow, deepAssign } from '../../utils';
4-
import { interval } from '../../adaptor/geometries';
4+
import { interval, point } from '../../adaptor/geometries';
55
import { RadialBarOptions } from './types';
66
import { getScaleMax } from './utils';
77

@@ -26,7 +26,10 @@ function geometry(params: Params<RadialBarOptions>): Params<RadialBarOptions> {
2626
});
2727
interval(p);
2828
if (type === 'line') {
29-
chart.point().position(`${xField}*${yField}`).shape('circle');
29+
point({
30+
chart,
31+
options: { xField, yField, seriesField: colorField, point: { shape: 'circle', color } },
32+
});
3033
}
3134
return params;
3235
}

0 commit comments

Comments
 (0)