Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gauge): render gauge sectors in the order of the "clockwise" option #17691

Merged
merged 3 commits into from
Sep 28, 2022
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
8 changes: 6 additions & 2 deletions src/chart/gauge/GaugeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import SeriesData from '../../data/SeriesData';
import Sausage from '../../util/shape/sausage';
import {createSymbol} from '../../util/symbol';
import ZRImage from 'zrender/src/graphic/Image';
import {extend, isFunction, isString, isNumber} from 'zrender/src/core/util';
import { extend, isFunction, isString, isNumber, each } from 'zrender/src/core/util';
import {setCommonECData} from '../../util/innerStore';
import { normalizeArcAngles } from 'zrender/src/core/PathProxy';

Expand Down Expand Up @@ -127,6 +127,7 @@ class GaugeView extends ChartView {

let prevEndAngle = startAngle;

const sectors: (Sausage | graphic.Sector)[] = [];
for (let i = 0; showAxis && i < colorList.length; i++) {
// Clamp
const percent = Math.min(Math.max(colorList[i][0], 0), 1);
Expand Down Expand Up @@ -154,11 +155,14 @@ class GaugeView extends ChartView {
['color', 'width']
));

group.add(sector);
sectors.push(sector);

prevEndAngle = endAngle;
}

sectors.reverse();
each(sectors, sector => group.add(sector));

const getColor = function (percent: number) {
// Less than 0
if (percent <= 0) {
Expand Down
151 changes: 104 additions & 47 deletions test/gauge-case.html

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