diff --git a/src/chart/bar/BarView.ts b/src/chart/bar/BarView.ts index e4be916699..dce754a46c 100644 --- a/src/chart/bar/BarView.ts +++ b/src/chart/bar/BarView.ts @@ -746,18 +746,9 @@ const elementCreator: { seriesModel, data, newIndex, layout: SectorLayout, isRadial: boolean, animationModel, axisModel, isUpdate, roundCap ) { - // Keep the same logic with bar in catesion: use end value to control - // direction. Notice that if clockwise is true (by default), the sector - // will always draw clockwisely, no matter whether endAngle is greater - // or less than startAngle. - const clockwise = layout.startAngle < layout.endAngle; - const ShapeClass = (!isRadial && roundCap) ? Sausage : Sector; - const sector = new ShapeClass({ - shape: defaults({ - clockwise: clockwise - }, layout), + shape: layout, z2: 1 }); @@ -909,7 +900,8 @@ const getLayout: { r0: layout.r0, r: layout.r, startAngle: layout.startAngle, - endAngle: layout.endAngle + endAngle: layout.endAngle, + clockwise: layout.clockwise } as SectorLayout; } }; diff --git a/src/layout/barPolar.ts b/src/layout/barPolar.ts index 081d884634..bc63fcba99 100644 --- a/src/layout/barPolar.ts +++ b/src/layout/barPolar.ts @@ -183,7 +183,15 @@ function barLayoutPolar(seriesType: string, ecModel: GlobalModel, api: Extension // Consider that positive angle is anti-clockwise, // while positive radian of sector is clockwise startAngle: -startAngle * Math.PI / 180, - endAngle: -endAngle * Math.PI / 180 + endAngle: -endAngle * Math.PI / 180, + + /** + * Keep the same logic with bar in catesion: use end value to + * control direction. Notice that if clockwise is true (by + * default), the sector will always draw clockwisely, no matter + * whether endAngle is greater or less than startAngle. + */ + clockwise: startAngle >= endAngle }); } diff --git a/test/bar-polar-basic.html b/test/bar-polar-basic.html deleted file mode 100644 index 3dab721de3..0000000000 --- a/test/bar-polar-basic.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - -

click axis labe should console log

-
- - - diff --git a/test/bar-polar-clockwise.html b/test/bar-polar-clockwise.html new file mode 100644 index 0000000000..d799c3fbbf --- /dev/null +++ b/test/bar-polar-clockwise.html @@ -0,0 +1,106 @@ + + + + + + + + + + + + +

click axis label should console log

+

click update button, sectors should be in the same order

+ +
+

clockwise: true

+
+
+
+

clockwise: false

+
+
+ + + diff --git a/test/runTest/actions/__meta__.json b/test/runTest/actions/__meta__.json index 28341e7bd1..fd4327a6f5 100644 --- a/test/runTest/actions/__meta__.json +++ b/test/runTest/actions/__meta__.json @@ -21,6 +21,7 @@ "bar-label-rotation": 2, "bar-large": 2, "bar-overflow-time-plot": 3, + "bar-polar-clockwise": 1, "bar-polar-multi-series": 1, "bar-polar-multi-series-radial": 1, "bar-polar-null-data-radial": 1, diff --git a/test/runTest/actions/bar-polar-clockwise.json b/test/runTest/actions/bar-polar-clockwise.json new file mode 100644 index 0000000000..9dbcc44e11 --- /dev/null +++ b/test/runTest/actions/bar-polar-clockwise.json @@ -0,0 +1 @@ +[{"name":"Action 1","ops":[{"type":"mousedown","time":1234,"x":34,"y":125},{"type":"mouseup","time":1393,"x":34,"y":125},{"time":1394,"delay":400,"type":"screenshot-auto"}],"scrollY":0,"scrollX":0,"timestamp":1631523020115}] \ No newline at end of file