Skip to content

Commit

Permalink
fix(visualMap): tweak #20551 & add VRT test
Browse files Browse the repository at this point in the history
  • Loading branch information
plainheart committed Dec 4, 2024
1 parent 9676b2f commit d58827a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
19 changes: 9 additions & 10 deletions src/component/visualMap/PiecewiseView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import * as graphic from '../../util/graphic';
import {createSymbol} from '../../util/symbol';
import * as layout from '../../util/layout';
import * as helper from './helper';
import PiecewiseModel, { PiecewiseVisualMapOption } from './PiecewiseModel';
import type PiecewiseModel from './PiecewiseModel';
import { TextAlign } from 'zrender/src/core/types';
import { VisualMappingOption } from '../../visual/VisualMapping';
import { createTextStyle } from '../../label/labelStyle';
Expand All @@ -43,7 +43,6 @@ class PiecewiseVisualMapView extends VisualMapView {

const visualMapModel = this.visualMapModel;
const textGap = visualMapModel.get('textGap');
const selectMode = visualMapModel.get('selectedMode');
const textStyleModel = visualMapModel.textStyleModel;
const textFont = textStyleModel.getFont();
const textFill = textStyleModel.getTextColor();
Expand All @@ -52,6 +51,7 @@ class PiecewiseVisualMapView extends VisualMapView {
const viewData = this._getViewData();
const endsText = viewData.endsText;
const showLabel = zrUtil.retrieve(visualMapModel.get('showLabel', true), !endsText);
const silent = !visualMapModel.get('selectedMode');

endsText && this._renderEndsText(
thisGroup, endsText[0], itemSize, showLabel, itemAlign
Expand All @@ -69,12 +69,12 @@ class PiecewiseVisualMapView extends VisualMapView {
const representValue = visualMapModel.getRepresentValue(piece) as number;

this._createItemSymbol(
itemGroup, representValue, [0, 0, itemSize[0], itemSize[1]], selectMode
itemGroup, representValue, [0, 0, itemSize[0], itemSize[1]], silent
);

if (showLabel) {
const visualState = this.visualMapModel.getValueState(representValue);
const itemText = new graphic.Text({
itemGroup.add(new graphic.Text({
style: {
x: itemAlign === 'right' ? -textGap : itemSize[0] + textGap,
y: itemSize[1] / 2,
Expand All @@ -84,10 +84,9 @@ class PiecewiseVisualMapView extends VisualMapView {
font: textFont,
fill: textFill,
opacity: visualState === 'outOfRange' ? 0.5 : 1,
}
});
itemText.silent = !selectMode;
itemGroup.add(itemText);
},
silent
}));
}

thisGroup.add(itemGroup);
Expand Down Expand Up @@ -202,7 +201,7 @@ class PiecewiseVisualMapView extends VisualMapView {
group: graphic.Group,
representValue: number,
shapeParam: number[],
selectMode: PiecewiseVisualMapOption['selectedMode'],
silent?: boolean,
) {
const itemSymbol = createSymbol(
// symbol will be string
Expand All @@ -211,7 +210,7 @@ class PiecewiseVisualMapView extends VisualMapView {
// color will be string
this.getControllerVisual(representValue, 'color') as string
);
itemSymbol.silent = !selectMode;
itemSymbol.silent = silent;
group.add(itemSymbol);
}

Expand Down
3 changes: 2 additions & 1 deletion test/runTest/actions/__meta__.json

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

1 change: 1 addition & 0 deletions test/runTest/actions/visualMap-selectMode.json

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

1 change: 1 addition & 0 deletions test/runTest/client/client.css

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

14 changes: 14 additions & 0 deletions test/visualMap-selectMode.html

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

0 comments on commit d58827a

Please sign in to comment.