diff --git a/__tests__/unit/plots/radar/coordinate-spec.ts b/__tests__/unit/plots/radar/coordinate-spec.ts new file mode 100644 index 0000000000..a418c28b67 --- /dev/null +++ b/__tests__/unit/plots/radar/coordinate-spec.ts @@ -0,0 +1,27 @@ +import { Radar } from '../../../../src'; +import { SINGLE_DATA } from '../../../data/radar'; +import { createDiv } from '../../../utils/dom'; + +describe('radar', () => { + it('set innerRadius & startAngle & endAngle', () => { + const radar = new Radar(createDiv(), { + width: 400, + height: 300, + data: SINGLE_DATA, + xField: 'name', + yField: 'value', + radius: 0.8, + startAngle: 0, + endAngle: Math.PI, + }); + + radar.render(); + + const coordinate = radar.chart.getCoordinate(); + const { startAngle, endAngle } = coordinate; + expect(startAngle).toBe(0); + expect(endAngle).toBe(Math.PI); + + radar.destroy(); + }); +}); diff --git a/docs/api/plots/radar.en.md b/docs/api/plots/radar.en.md index 51e96aa2a7..e9697a509d 100644 --- a/docs/api/plots/radar.en.md +++ b/docs/api/plots/radar.en.md @@ -72,6 +72,18 @@ A field that groups a radar map, usually corresponding to a classification field The radius of the radar map, starting at the center of the drawing area (not including the chart component area). The configuration range is (0,1), where 1 means to fill the drawing area. +#### startAngle + +**optional** _number_ _default:_ `(Math.PI * 0) / 180` + +The starting Angle of the disk. + +#### endAngle + +**optional** _number_ _default:_ `(Math.PI * 180) / 180` + +The termination Angle of the disk. + `markdown:docs/common/color.en.md` #### smooth diff --git a/docs/api/plots/radar.zh.md b/docs/api/plots/radar.zh.md index a0cf115264..fa7c909acb 100644 --- a/docs/api/plots/radar.zh.md +++ b/docs/api/plots/radar.zh.md @@ -46,19 +46,19 @@ const radarPlot = new Radar('container', { radarPlot.render(); ``` -#### xField +#### xField **required** _string_ 雷达图映射到圆周角度所对应的字段,一般为一个分类字段。 -#### yField +#### yField **required** _string_ 雷达图映射到半径所对应的字段,一般为一个连续字段。 -#### seriesField +#### seriesField **required** _string_ @@ -66,21 +66,33 @@ radarPlot.render(); ### 图形样式 -#### radius +#### radius **optional** _number_ 雷达图的半径,原点为绘图区域中心(不包含图表组件区域)。配置值域为 (0,1],1 代表撑满绘图区域。 +#### startAngle + +**optional** _number_ _default:_ `(Math.PI * 0) / 180` + +配置坐标系的起始角度。 + +#### endAngle + +**optional** _number_ _default:_ `(Math.PI * 180) / 180` + +配置坐标系的结束角度。 + `markdown:docs/common/color.zh.md` -#### smooth +#### smooth **optional** _boolean_ _default:_ `false` 是否以曲线的形态绘制 (spline)。 -#### lineStyle +#### lineStyle **optional** _object | Function_ @@ -101,7 +113,7 @@ radarPlot.render(); } ``` -#### point +#### point **optional** _object_ @@ -109,7 +121,7 @@ radarPlot.render(); `markdown:docs/common/point-style.zh.md` -#### area +#### area **optional** _object_ diff --git a/src/plots/radar/adaptor.ts b/src/plots/radar/adaptor.ts index ddc824f72e..85ec568d07 100644 --- a/src/plots/radar/adaptor.ts +++ b/src/plots/radar/adaptor.ts @@ -73,10 +73,12 @@ function meta(params: Params): Params { */ function coord(params: Params): Params { const { chart, options } = params; - const { radius } = options; + const { radius, startAngle, endAngle } = options; chart.coordinate('polar', { radius, + startAngle, + endAngle, }); return params; } diff --git a/src/plots/radar/types.ts b/src/plots/radar/types.ts index 4731b3671e..d47e09ba4d 100644 --- a/src/plots/radar/types.ts +++ b/src/plots/radar/types.ts @@ -22,4 +22,8 @@ export interface RadarOptions extends Options { readonly yAxis?: any; /** 雷达图半径 */ readonly radius?: number; + /** 雷达图开始角度 */ + readonly startAngle?: number; + /** 雷达图结束角度 */ + readonly endAngle?: number; }