Skip to content

Commit

Permalink
Merge pull request #20551 from sz-p/fix-20533
Browse files Browse the repository at this point in the history
fix(visualMap): cursor is pointer on selectedMode=false
  • Loading branch information
Ovilia authored Nov 29, 2024
2 parents 6b9642d + aa2baff commit 104df1b
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 10 deletions.
25 changes: 15 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 from './PiecewiseModel';
import PiecewiseModel, { PiecewiseVisualMapOption } from './PiecewiseModel';
import { TextAlign } from 'zrender/src/core/types';
import { VisualMappingOption } from '../../visual/VisualMapping';
import { createTextStyle } from '../../label/labelStyle';
Expand All @@ -43,6 +43,7 @@ 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 @@ -68,13 +69,12 @@ class PiecewiseVisualMapView extends VisualMapView {
const representValue = visualMapModel.getRepresentValue(piece) as number;

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

if (showLabel) {
const visualState = this.visualMapModel.getValueState(representValue);

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

thisGroup.add(itemGroup);
Expand Down Expand Up @@ -199,15 +201,18 @@ class PiecewiseVisualMapView extends VisualMapView {
private _createItemSymbol(
group: graphic.Group,
representValue: number,
shapeParam: number[]
shapeParam: number[],
selectMode: PiecewiseVisualMapOption['selectedMode'],
) {
group.add(createSymbol(
const itemSymbol = createSymbol(
// symbol will be string
this.getControllerVisual(representValue, 'symbol') as string,
shapeParam[0], shapeParam[1], shapeParam[2], shapeParam[3],
// color will be string
this.getControllerVisual(representValue, 'color') as string
));
);
itemSymbol.silent = !selectMode;
group.add(itemSymbol);
}

private _onItemClick(
Expand Down Expand Up @@ -241,4 +246,4 @@ class PiecewiseVisualMapView extends VisualMapView {
}
}

export default PiecewiseVisualMapView;
export default PiecewiseVisualMapView;
144 changes: 144 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 104df1b

Please sign in to comment.