提交 3a1a3d51 编写于 作者: O Ovilia

refactor(sunburst): update with doc

上级 4d74bbd1
...@@ -83,7 +83,7 @@ SunburstPieceProto.updateData = function ( ...@@ -83,7 +83,7 @@ SunburstPieceProto.updateData = function (
style = zrUtil.defaults( style = zrUtil.defaults(
{ {
lineJoin: 'bevel', lineJoin: 'bevel',
fill: visualColor fill: style.fill || visualColor
}, },
style style
); );
...@@ -132,8 +132,11 @@ SunburstPieceProto.updateData = function ( ...@@ -132,8 +132,11 @@ SunburstPieceProto.updateData = function (
SunburstPieceProto.onEmphasis = function (highlightPolicy) { SunburstPieceProto.onEmphasis = function (highlightPolicy) {
var that = this; var that = this;
this.node.hostTree.root.eachNode(function (n) { this.node.hostTree.root.eachNode(function (n) {
if (that.node !== n && n.piece) { if (n.piece) {
if (isNodeHighlighted(n, that.node, highlightPolicy)) { if (that.node === n) {
n.piece.updateData(false, n, 'emphasis');
}
else if (isNodeHighlighted(n, that.node, highlightPolicy)) {
n.piece.childAt(0).trigger('highlight'); n.piece.childAt(0).trigger('highlight');
} }
else if (highlightPolicy !== NodeHighlightPolicy.NONE) { else if (highlightPolicy !== NodeHighlightPolicy.NONE) {
...@@ -192,16 +195,14 @@ SunburstPieceProto._updateLabel = function (seriesModel, ecModel, visualColor) { ...@@ -192,16 +195,14 @@ SunburstPieceProto._updateLabel = function (seriesModel, ecModel, visualColor) {
var r; var r;
var labelPosition = labelModel.get('position'); var labelPosition = labelModel.get('position');
var labelPadding = labelModel.get('padding') || 0; var labelPadding = labelModel.get('distance') || 0;
var textAlign = labelModel.get('align'); var textAlign = labelModel.get('align');
if (labelPosition === 'outside') { if (labelPosition === 'outside') {
r = layout.r + labelPadding; r = layout.r + labelPadding;
if (!textAlign) { textAlign = midAngle > Math.PI / 2 ? 'right' : 'left';
textAlign = midAngle > Math.PI / 2 ? 'right' : 'left';
}
} }
else { else {
if (!textAlign) { if (!textAlign || textAlign === 'center') {
r = (layout.r + layout.r0) / 2; r = (layout.r + layout.r0) / 2;
textAlign = 'center'; textAlign = 'center';
} }
...@@ -246,6 +247,8 @@ SunburstPieceProto._updateLabel = function (seriesModel, ecModel, visualColor) { ...@@ -246,6 +247,8 @@ SunburstPieceProto._updateLabel = function (seriesModel, ecModel, visualColor) {
else if (rotate < -Math.PI / 2) { else if (rotate < -Math.PI / 2) {
rotate += Math.PI; rotate += Math.PI;
} }
} else if (typeof rotateType === 'number') {
rotate = rotateType * Math.PI / 180;
} }
label.attr('rotation', rotate); label.attr('rotation', rotate);
}; };
...@@ -256,8 +259,6 @@ SunburstPieceProto._initEvents = function ( ...@@ -256,8 +259,6 @@ SunburstPieceProto._initEvents = function (
seriesModel, seriesModel,
highlightPolicy highlightPolicy
) { ) {
var itemModel = node.getModel();
sector.off('mouseover').off('mouseout').off('emphasis').off('normal'); sector.off('mouseover').off('mouseout').off('emphasis').off('normal');
var that = this; var that = this;
...@@ -274,7 +275,7 @@ SunburstPieceProto._initEvents = function ( ...@@ -274,7 +275,7 @@ SunburstPieceProto._initEvents = function (
that.onHighlight(); that.onHighlight();
}; };
if (itemModel.get('hoverAnimation') && seriesModel.isAnimationEnabled()) { if (seriesModel.isAnimationEnabled()) {
sector sector
.on('mouseover', onEmphasis) .on('mouseover', onEmphasis)
.on('mouseout', onNormal) .on('mouseout', onNormal)
...@@ -351,7 +352,7 @@ function isNodeHighlighted(node, activeNode, policy) { ...@@ -351,7 +352,7 @@ function isNodeHighlighted(node, activeNode, policy) {
return node === activeNode; return node === activeNode;
} }
else if (policy === NodeHighlightPolicy.ANCESTOR) { else if (policy === NodeHighlightPolicy.ANCESTOR) {
return node === activeNode || node.isAncestorOf(activeNode); return node === activeNode || node.isAncestorOf(activeNode);
} }
else { else {
return node === activeNode || node.isDescendantOf(activeNode); return node === activeNode || node.isDescendantOf(activeNode);
......
...@@ -51,9 +51,7 @@ export default SeriesModel.extend({ ...@@ -51,9 +51,7 @@ export default SeriesModel.extend({
defaultOption: { defaultOption: {
zlevel: 0, zlevel: 0,
z: 2, z: 2,
legendHoverLink: true,
hoverAnimation: true,
// 默认全局居中 // 默认全局居中
center: ['50%', '50%'], center: ['50%', '50%'],
radius: [0, '75%'], radius: [0, '75%'],
...@@ -83,11 +81,11 @@ export default SeriesModel.extend({ ...@@ -83,11 +81,11 @@ export default SeriesModel.extend({
rotate: 'radial', rotate: 'radial',
show: true, show: true,
opacity: 1, opacity: 1,
// could be 'inner', 'outside', 'left' or 'right'
// 'left' is for inner side of inside, and 'right' is for outter // 'left' is for inner side of inside, and 'right' is for outter
// side for inside // side for inside
position: 'inner', align: 'center',
padding: 5, position: 'inside',
distance: 5,
silent: true, silent: true,
emphasis: {} emphasis: {}
}, },
...@@ -100,14 +98,14 @@ export default SeriesModel.extend({ ...@@ -100,14 +98,14 @@ export default SeriesModel.extend({
opacity: 1 opacity: 1
}, },
downplay: { downplay: {
opacity: 0.6 opacity: 0.9
} }
}, },
// Animation type canbe expansion, scale // Animation type canbe expansion, scale
animationType: 'expansion', animationType: 'expansion',
animationDuration: 1000, animationDuration: 1000,
animationUpdateDuration: 500, animationDurationUpdate: 500,
animationEasing: 'cubicOut', animationEasing: 'cubicOut',
data: [], data: [],
......
...@@ -64,10 +64,10 @@ echarts.registerAction( ...@@ -64,10 +64,10 @@ echarts.registerAction(
ecModel.eachComponent( ecModel.eachComponent(
{mainType: 'series', subType: 'sunburst', query: payload}, {mainType: 'series', subType: 'sunburst', query: payload},
handleUnighlight handleUnhighlight
); );
function handleUnighlight(model, index) { function handleUnhighlight(model, index) {
payload.unhighlight = true; payload.unhighlight = true;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册