Skip to content

Commit

Permalink
fix(radial-bar): 修复line类型的珏玦图,设置color对point不生效 (#2185)
Browse files Browse the repository at this point in the history
  • Loading branch information
visiky authored Jan 7, 2021
1 parent 20ad2c6 commit c47329f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
19 changes: 19 additions & 0 deletions __tests__/unit/plots/radial-bar/index-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,23 @@ describe('radial-bar', () => {
expect(bar.chart.getController('annotation').getComponents()[0].component.get('content')).toBe('Music');
bar.destroy();
});

it('展示形式为 line,自动带 point 且颜色可以对应上', () => {
const bar = new RadialBar(createDiv(), {
width: 400,
height: 300,
data: antvStar,
xField,
yField,
type: 'line',
color: (datum) => (datum[yField] < 800 ? 'red' : 'green'),
});
bar.render();
const line = bar.chart.geometries[0];
const point = bar.chart.geometries[1];
expect(line.attributes.shape.values[0]).toBe('line');
expect(point.type).toBe('point');
line.elements.forEach((ele, idx) => expect(ele.shape.attr('color')).toBe(point.elements[idx].shape.attr('color')));
bar.destroy();
});
});
7 changes: 5 additions & 2 deletions src/plots/radial-bar/adaptor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { interaction, animation, theme, scale, tooltip, legend, annotation } from '../../adaptor/common';
import { Params } from '../../core/adaptor';
import { flow, deepAssign } from '../../utils';
import { interval } from '../../adaptor/geometries';
import { interval, point } from '../../adaptor/geometries';
import { RadialBarOptions } from './types';
import { getScaleMax } from './utils';

Expand All @@ -26,7 +26,10 @@ function geometry(params: Params<RadialBarOptions>): Params<RadialBarOptions> {
});
interval(p);
if (type === 'line') {
chart.point().position(`${xField}*${yField}`).shape('circle');
point({
chart,
options: { xField, yField, seriesField: colorField, point: { shape: 'circle', color } },
});
}
return params;
}
Expand Down

0 comments on commit c47329f

Please sign in to comment.