diff --git a/src/component/visualMap/PiecewiseView.ts b/src/component/visualMap/PiecewiseView.ts index 93cf0e7c76..1b49d8cb6d 100644 --- a/src/component/visualMap/PiecewiseView.ts +++ b/src/component/visualMap/PiecewiseView.ts @@ -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'; @@ -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(); @@ -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 @@ -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, @@ -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); @@ -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 @@ -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); } diff --git a/test/runTest/actions/__meta__.json b/test/runTest/actions/__meta__.json index c9abb1e8c8..3a9a4d28cd 100644 --- a/test/runTest/actions/__meta__.json +++ b/test/runTest/actions/__meta__.json @@ -220,5 +220,6 @@ "universalTransition2": 3, "universalTransition3": 2, "visualMap-categories": 1, - "visualMap-multi-continuous": 1 + "visualMap-multi-continuous": 1, + "visualMap-selectMode": 2 } \ No newline at end of file diff --git a/test/runTest/actions/visualMap-selectMode.json b/test/runTest/actions/visualMap-selectMode.json new file mode 100644 index 0000000000..bafe2f6557 --- /dev/null +++ b/test/runTest/actions/visualMap-selectMode.json @@ -0,0 +1 @@ +[{"name":"Action 1","ops":[{"type":"mousedown","time":1954,"x":598,"y":69},{"type":"mouseup","time":2073,"x":598,"y":69},{"time":2074,"delay":400,"type":"screenshot-auto"},{"type":"mousedown","time":2816,"x":598,"y":69},{"type":"mouseup","time":2982,"x":598,"y":69},{"time":2983,"delay":400,"type":"screenshot-auto"}],"scrollY":0,"scrollX":0,"timestamp":1733305566997},{"name":"Action 2","ops":[{"type":"mousemove","time":395,"x":596,"y":186},{"type":"mousemove","time":599,"x":596,"y":187},{"type":"mousemove","time":879,"x":596,"y":188},{"type":"mousemove","time":1078,"x":596,"y":207},{"type":"mousemove","time":1282,"x":596,"y":211},{"type":"screenshot","time":2565}],"scrollY":316,"scrollX":0,"timestamp":1733305618041}] diff --git a/test/runTest/client/client.css b/test/runTest/client/client.css index 1cce88083b..63ec88c424 100644 --- a/test/runTest/client/client.css +++ b/test/runTest/client/client.css @@ -277,6 +277,7 @@ .test-errors, .test-logs { margin-top: 20px; padding: 0 20px; + word-wrap: break-word; } .test-logs .log-item { diff --git a/test/visualMap-selectMode.html b/test/visualMap-selectMode.html index b254e0ea50..05511560b4 100644 --- a/test/visualMap-selectMode.html +++ b/test/visualMap-selectMode.html @@ -91,6 +91,13 @@ title: "mouse on visualMap should be **pointer**", option, }); + const tipDOM = document.createElement('span'); + tipDOM.style.cssText = 'position: absolute;top:10px;left:10px;color:#000'; + chart.getDom().appendChild(tipDOM); + chart.getDom().addEventListener('mousemove', function () { + const cursor = chart.getZr().painter.getViewportRoot().style.cursor || 'default'; + tipDOM.innerText = 'visualMap piece cursor: ' + cursor; + }); }); @@ -138,6 +145,13 @@ title: "mouse on visualMap should be **default**", option, }); + const tipDOM = document.createElement('span'); + tipDOM.style.cssText = 'position: absolute;top:10px;left:10px;color:#000'; + chart.getDom().appendChild(tipDOM); + chart.getDom().addEventListener('mousemove', function () { + const cursor = chart.getZr().painter.getViewportRoot().style.cursor || 'default'; + tipDOM.innerText = 'visualMap piece cursor: ' + cursor; + }); });