Skip to content

Commit

Permalink
Prevent treamap from using hover layer by default. Fix #10521 . Ref #…
Browse files Browse the repository at this point in the history
  • Loading branch information
100pah committed Jun 10, 2019
1 parent 23d0ef5 commit 20bed53
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/chart/treemap/TreemapSeries.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export default SeriesModel.extend({

dependencies: ['grid', 'polar'],

preventUsingHoverLayer: true,

/**
* @type {module:echarts/data/Tree~Node}
*/
Expand All @@ -40,7 +42,6 @@ export default SeriesModel.extend({
defaultOption: {
// Disable progressive rendering
progressive: 0,
hoverLayerThreshold: Infinity,
// center: ['50%', '50%'], // not supported in ec3.
// size: ['80%', '80%'], // deprecated, compatible with ec2.
left: 'center',
Expand Down
25 changes: 16 additions & 9 deletions src/echarts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ function renderSeries(ecIns, ecModel, api, payload, dirtyMap) {
scheduler.unfinished |= unfinished;

// If use hover layer
updateHoverLayerStatus(ecIns._zr, ecModel);
updateHoverLayerStatus(ecIns, ecModel);

// Add aria
aria(ecIns._zr.dom, ecModel);
Expand Down Expand Up @@ -1655,19 +1655,26 @@ echartsProto.dispose = function () {

zrUtil.mixin(ECharts, Eventful);

function updateHoverLayerStatus(zr, ecModel) {
function updateHoverLayerStatus(ecIns, ecModel) {
var zr = ecIns._zr;
var storage = zr.storage;
var elCount = 0;

storage.traverse(function (el) {
if (!el.isGroup) {
elCount++;
}
elCount++;
});

if (elCount > ecModel.get('hoverLayerThreshold') && !env.node) {
storage.traverse(function (el) {
if (!el.isGroup) {
// Don't switch back.
el.useHoverLayer = true;
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.preventUsingHoverLayer) {
return;
}
var chartView = ecIns._chartsMap[seriesModel.__viewId];
if (chartView.__alive) {
chartView.group.traverse(function (el) {
// Don't switch back.
el.useHoverLayer = true;
});
}
});
}
Expand Down
8 changes: 7 additions & 1 deletion test/tooltip-axisPointer.html
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,13 @@ <h1>tooltip.axisPointer.label.show: fasle</h1>
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross'
type: 'cross',
label: {
formatter: function (params) {
console.log(params);
return 'asdfa';
}
}
}
}
};
Expand Down

0 comments on commit 20bed53

Please sign in to comment.