提交 cae8662f 编写于 作者: O Ovilia

feat(sunburst): defined sunburstHighlight action

上级 6613ffc0
......@@ -357,6 +357,7 @@ function updatePiece(node, state) {
: (isHighlight ? DEFAULT_SECTOR_HIGHLIGHT_Z : DEFAULT_SECTOR_Z);
sector.attr('z', sectorZ);
sector.stopAnimation(true);
sector.animateTo({
style: {
opacity: itemModel.get('opacity') || 1
......@@ -373,6 +374,7 @@ function updatePiece(node, state) {
: (isHighlight ? DEFAULT_TEXT_HIGHLIGHT_Z : DEFAULT_TEXT_Z);
text.attr('z', textZ);
text.stopAnimation(true);
text.animateTo({
style: {
opacity: labelModel.get('opacity') || 1
......
......@@ -40,6 +40,11 @@ var SunburstView = ChartView.extend({
renderRollUp(virtualRoot, newRoot);
if (payload && payload.highlight && payload.highlight.piece) {
var highlightPolicy = seriesModel.getShallow('highlightPolicy');
payload.highlight.piece.onEmphasis(highlightPolicy);
}
this._initEvents();
this._oldRoot = newRoot;
......
......@@ -31,3 +31,27 @@ echarts.registerAction(
}
}
);
var HIGHLIGHT_ACTION = 'sunburstHighlight';
echarts.registerAction(
{type: HIGHLIGHT_ACTION, update: 'updateView'},
function (payload, ecModel) {
ecModel.eachComponent(
{mainType: 'series', subType: 'sunburst', query: payload},
handleHighlight
);
function handleHighlight(model, index) {
var targetInfo = helper
.retrieveTargetInfo(payload, [HIGHLIGHT_ACTION], model);
if (targetInfo) {
payload.highlight = targetInfo.node;
}
}
}
);
import * as zrUtil from 'zrender/src/core/util';
import DataDiff from './DataDiffer';
/**
* @param {Array} oldArr
* @param {Array} newArr
* @param {Function} oldKeyGetter
* @param {Function} newKeyGetter
* @param {Object} [context] Can be visited by this.context in callback.
*/
function TreeDiff(oldArr, newArr, oldKeyGetter, newKeyGetter, context) {
DataDiff.apply(this, arguments);
}
TreeDiff.prototype._initIndexMap = function (
arr, map, keyArr, keyGetterName, dataDiffer
) {
for (var i = 0; i < arr.length; i++) {
// Add prefix to avoid conflict with Object.prototype.
var key = '_ec_' + dataDiffer[keyGetterName](arr[i], i);
var existence = map[key];
if (existence == null) {
map[key] = keyArr.length;
keyArr.push(key);
}
else {
if (!existence.length) {
map[key] = existence = [existence];
}
existence.push(i);
}
if (arr[i].children && arr[i].children.length > 0) {
this._initIndexMap(
arr[i].children, map, keyArr, keyGetterName, dataDiffer
);
}
}
};
zrUtil.inherits(TreeDiff, DataDiff);
export default TreeDiff;
......@@ -115,6 +115,13 @@
}
}
});
setTimeout(function () {
chart.dispatchAction({
type: 'sunburstHighlight',
targetNodeId: 'Cousin Jenny'
});
}, 3000);
});
</script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册