Skip to content

fix(visualMap): fix cursor is still pointer when selectedMode is disabled #20551

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

Merged
merged 2 commits into from
Nov 29, 2024
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
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.