提交 e2936025 编写于 作者: S sushuang

Tweak

上级 2b5a3ee4
......@@ -37,21 +37,18 @@ function FunnelPiece(data, idx) {
this.add(labelLine);
this.add(text);
this.updateData(data, idx, true);
this.highDownOnUpdate = function (fromState, toState) {
if (toState === 'emphasis') {
labelLine.ignore = labelLine.hoverIgnore;
text.ignore = text.hoverIgnore;
}
else {
labelLine.ignore = labelLine.normalIgnore;
text.ignore = text.normalIgnore;
}
};
// Hover to change label and labelLine
function onEmphasis() {
labelLine.ignore = labelLine.hoverIgnore;
text.ignore = text.hoverIgnore;
}
function onNormal() {
labelLine.ignore = labelLine.normalIgnore;
text.ignore = text.normalIgnore;
}
this.on('emphasis', onEmphasis)
.on('normal', onNormal)
.on('mouseover', onEmphasis)
.on('mouseout', onNormal);
this.updateData(data, idx, true);
}
var funnelPieceProto = FunnelPiece.prototype;
......
......@@ -96,20 +96,6 @@ function PiePiece(data, idx) {
this.add(text);
this.updateData(data, idx, true);
// Hover to change label and labelLine
function onEmphasis() {
polyline.ignore = polyline.hoverIgnore;
text.ignore = text.hoverIgnore;
}
function onNormal() {
polyline.ignore = polyline.normalIgnore;
text.ignore = text.normalIgnore;
}
this.on('emphasis', onEmphasis)
.on('normal', onNormal)
.on('mouseover', onEmphasis)
.on('mouseout', onNormal);
}
var piePieceProto = PiePiece.prototype;
......@@ -117,6 +103,8 @@ var piePieceProto = PiePiece.prototype;
piePieceProto.updateData = function (data, idx, firstCreate) {
var sector = this.childAt(0);
var labelLine = this.childAt(1);
var labelText = this.childAt(2);
var seriesModel = data.hostModel;
var itemModel = data.getItemModel(idx);
......@@ -184,6 +172,9 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
this.highDownOnUpdate = (itemModel.get('hoverAnimation') && seriesModel.isAnimationEnabled())
? function (fromState, toState) {
if (toState === 'emphasis') {
labelLine.ignore = labelLine.hoverIgnore;
labelText.ignore = labelText.hoverIgnore;
// Sector may has animation of updating data. Force to move to the last frame
// Or it may stopped on the wrong shape
sector.stopAnimation(true);
......@@ -194,6 +185,9 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
}, 300, 'elasticOut');
}
else {
labelLine.ignore = labelLine.normalIgnore;
labelText.ignore = labelText.normalIgnore;
sector.stopAnimation(true);
sector.animateTo({
shape: {
......
......@@ -207,20 +207,9 @@ export default echarts.extendChartView({
);
});
function onEmphasis() {
polygon.attr('ignore', hoverPolygonIgnore);
}
function onNormal() {
polygon.attr('ignore', polygonIgnore);
}
itemGroup.off('mouseover').off('mouseout').off('normal').off('emphasis');
itemGroup.on('emphasis', onEmphasis)
.on('mouseover', onEmphasis)
.on('normal', onNormal)
.on('mouseout', onNormal);
itemGroup.highDownOnUpdate = function (fromState, toState) {
polygon.attr('ignore', toState === 'emphasis' ? hoverPolygonIgnore : polygonIgnore);
};
graphic.setHoverStyle(itemGroup);
});
......
......@@ -65,6 +65,8 @@ under the License.
<div id="main4"></div>
<div id="main5"></div>
<div id="main6"></div>
<div id="main7"></div>
<div id="main8"></div>
......@@ -760,5 +762,110 @@ under the License.
<script>
require(['echarts'], function (echarts) {
var option = {
hoverLayerThreshold: hoverLayerThreshold,
tooltip: {},
series: [{
type: 'funnel',
label: {
show: false
},
emphasis: {
label: {show: true}
},
data: [
{value: 12, name: 'poiu'},
{value: 15, name: 'zxcv'},
{value: 17, name: 'casdf'}
]
}]
};
var chart = testHelper.create(echarts, 'main7', {
title: [
'Click button highlight dataIndex 0 show label',
'Then hover and unhover the sector, highlight state will not changed'
],
option: option,
height: 200,
buttons: [{
text: 'highlight dataIndex 0',
onclick: function () {
chart.dispatchAction({
type: 'highlight',
seriesIndex: 0,
dataIndex: 0
});
}
}, {
text: 'downplay dataIndex 0',
onclick: function () {
chart.dispatchAction({
type: 'downplay',
seriesIndex: 0,
dataIndex: 0
});
}
}]
});
});
</script>
<script>
$.get('../map/json/china.json', function (chinaJson) {
if (typeof chinaJson === 'string') {
chinaJson = eval('(' + chinaJson + ')');
}
require(['echarts'], function (echarts) {
echarts.registerMap('china', chinaJson);
var option = {
hoverLayerThreshold: hoverLayerThreshold,
tooltip: {},
legend: {},
geo: [{
type: 'map',
map: 'china',
roam: true,
scaleLimit: {
min: 1.5,
max: 10
},
selectedMode: 'multiple'
}]
};
var chart = testHelper.create(echarts, 'main8', {
title: [
'Click button toggleSelected 内蒙古',
'Then hover and unhover the region, highlight state will not changed'
],
option: option,
height: 400,
buttons: [{
text: 'toggleSelected 内蒙古',
onclick: function () {
chart.dispatchAction({
type: 'geoToggleSelect',
geoIndex: 0,
name: '内蒙古'
});
}
}]
});
});
});
</script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册