Skip to content

Commit b94047f

Browse files
authored
Merge pull request #21224 from StNimmerlein/fix/color-progress-bar-in-gauge-chart
feat(gauge): progress.color supports 'auto'
2 parents be1028e + 0b06d7f commit b94047f

File tree

2 files changed

+57
-3
lines changed

2 files changed

+57
-3
lines changed

src/chart/gauge/GaugeView.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ class GaugeView extends ChartView {
529529
const focus = emphasisModel.get('focus');
530530
const blurScope = emphasisModel.get('blurScope');
531531
const emphasisDisabled = emphasisModel.get('disabled');
532+
const autoColor = getColor(linearMap(data.get(valueDim, idx) as number, valueExtent, [0, 1], true));
532533
if (showPointer) {
533534
const pointer = data.getItemGraphicEl(idx) as ECSymbol;
534535
const symbolStyle = data.getItemVisual(idx, 'style');
@@ -550,9 +551,7 @@ class GaugeView extends ChartView {
550551

551552

552553
if (pointer.style.fill === 'auto') {
553-
pointer.setStyle('fill', getColor(
554-
linearMap(data.get(valueDim, idx) as number, valueExtent, [0, 1], true)
555-
));
554+
pointer.setStyle('fill', autoColor);
556555
}
557556

558557
(pointer as ECElement).z2EmphasisLift = 0;
@@ -564,6 +563,9 @@ class GaugeView extends ChartView {
564563
const progress = progressList[idx];
565564
progress.useStyle(data.getItemVisual(idx, 'style'));
566565
progress.setStyle(itemModel.getModel(['progress', 'itemStyle']).getItemStyle());
566+
if (progress.style.fill === 'auto') {
567+
progress.setStyle('fill', autoColor);
568+
}
567569
(progress as ECElement).z2EmphasisLift = 0;
568570
setStatesStylesFromModel(progress, itemModel);
569571
toggleHoverEmphasis(progress, focus, blurScope, emphasisDisabled);

test/gauge-progress.html

Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)