Skip to content

Commit edd23af

Browse files
committed
Fix z2 and cache on hover.
1 parent 679033d commit edd23af

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

src/util/graphic.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,15 +376,13 @@ function doSingleLeaveHover(el) {
376376
// `setStyle` but not `extendFrom(stl, true)`.
377377
el.setStyle(normalStl);
378378
applyDefaultTextStyle(style);
379-
el.__cachedNormalStl = null;
380379
}
381380
// `__cachedNormalZ2` will not be reset if calling `setElementHoverStyle`
382381
// when `el` is on emphasis state. So here by comparing with 1, we try
383382
// hard to make the bug case rare.
384383
var normalZ2 = el.__cachedNormalZ2;
385-
if (el.z2 - normalZ2 === Z2_LIFT_VALUE) {
384+
if (normalZ2 != null && el.z2 - normalZ2 === Z2_LIFT_VALUE) {
386385
el.z2 = normalZ2;
387-
el.__cachedNormalZ2 = null;
388386
}
389387
}
390388
}

test/hoverStyle.html

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656

5757
<div id="mainb1"></div>
5858
<div id="mainb2"></div>
59+
<div id="mainb3"></div>
5960

6061
<div id="main0"></div>
6162
<div id="main1"></div>
@@ -84,7 +85,9 @@
8485

8586
function genInfo(zrRefreshTimestamp) {
8687
infoEl.innerHTML = [
87-
useHoverLayer ? 'Using HoverLayer' : 'NOT using HoverLayer',
88+
'<span style="color:yellow">'
89+
+ (useHoverLayer ? 'Using HoverLayer' : 'NOT using HoverLayer')
90+
+ '</span>',
8891
'hoverLayerThreshold: ' + hoverLayerThreshold,
8992
'zr refresh base layer at: <span style="color:yellow">' + (zrRefreshTimestamp || null) + '</span>'
9093
].join('<br>');
@@ -231,6 +234,37 @@
231234

232235

233236

237+
<script>
238+
require(['echarts'], function (echarts) {
239+
var option = {
240+
hoverLayerThreshold: hoverLayerThreshold,
241+
xAxis: {
242+
},
243+
yAxis: {
244+
},
245+
series: [{
246+
type: 'scatter',
247+
symbolSize: 100,
248+
data: [
249+
{value: [0, 0], itemStyle: {color: 'blue'}},
250+
{value: [0, 1], itemStyle: {color: 'red'}}
251+
]
252+
}]
253+
};
254+
255+
var chart = testHelper.create(echarts, 'mainb3', {
256+
title: [
257+
'hover the blue symbol, the z2 can be top',
258+
'unhover, **z2 should be back** to bottom'
259+
],
260+
option: option,
261+
height: 200
262+
});
263+
});
264+
</script>
265+
266+
267+
234268
<script>
235269
require(['echarts'], function (echarts) {
236270
var option = {

0 commit comments

Comments
 (0)