Skip to content
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
5 changes: 4 additions & 1 deletion src/coord/radar/Radar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class Radar implements CoordinateSystem, CoordinateSystemMaster {
const refContainer = createBoxLayoutReference(radarModel, api).refContainer;

const center = radarModel.get('center');
const clockwise = radarModel.get('clockwise') || false;
const viewSize = Math.min(refContainer.width, refContainer.height) / 2;
this.cx = numberUtil.parsePercent(center[0], refContainer.width) + refContainer.x;
this.cy = numberUtil.parsePercent(center[1], refContainer.height) + refContainer.y;
Expand All @@ -140,9 +141,11 @@ class Radar implements CoordinateSystem, CoordinateSystemMaster {
this.r0 = numberUtil.parsePercent(radius[0], viewSize);
this.r = numberUtil.parsePercent(radius[1], viewSize);

const sign = clockwise ? -1 : 1;

each(this._indicatorAxes, function (indicatorAxis, idx) {
indicatorAxis.setExtent(this.r0, this.r);
let angle = (this.startAngle + idx * Math.PI * 2 / this._indicatorAxes.length);
let angle = (this.startAngle + sign * idx * Math.PI * 2 / this._indicatorAxes.length);
// Normalize to [-PI, PI]
angle = Math.atan2(Math.sin(angle), Math.cos(angle));
indicatorAxis.angle = angle;
Expand Down
6 changes: 6 additions & 0 deletions src/coord/radar/RadarModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export interface RadarOption extends ComponentOption, CircleLayoutOptionMixin {

startAngle?: number

clockwise?: boolean

shape?: 'polygon' | 'circle'

// TODO. axisType seems to have issue.
Expand Down Expand Up @@ -106,6 +108,7 @@ class RadarModel extends ComponentModel<RadarOption> implements CoordinateSystem
optionUpdated() {
const boundaryGap = this.get('boundaryGap');
const splitNumber = this.get('splitNumber');
const clockwise = this.get('clockwise');
const scale = this.get('scale');
const axisLine = this.get('axisLine');
const axisTick = this.get('axisTick');
Expand Down Expand Up @@ -135,6 +138,7 @@ class RadarModel extends ComponentModel<RadarOption> implements CoordinateSystem
const innerIndicatorOpt: InnerIndicatorAxisOption = zrUtil.merge(zrUtil.clone(indicatorOpt), {
boundaryGap: boundaryGap,
splitNumber: splitNumber,
clockwise: clockwise,
scale: scale,
axisLine: axisLine,
axisTick: axisTick,
Expand Down Expand Up @@ -187,6 +191,8 @@ class RadarModel extends ComponentModel<RadarOption> implements CoordinateSystem

startAngle: 90,

clockwise: false,

axisName: {
show: true,
color: tokens.color.axisLabel
Expand Down
330 changes: 330 additions & 0 deletions test/radar-clockwise-interactive.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading