提交 8cb6cc2f 编写于 作者: C Catouse

* fix draw label method for doughnut chart.

上级 717af5be
......@@ -132,7 +132,7 @@
segment.color = color.toCssStr();
if(!segment.highlight) segment.highlight = color.lighten(5).toCssStr();
}
/// ----- ZUI change begin -----
/// ----- ZUI change end -----
var index = atIndex || this.segments.length;
this.segments.splice(index, 0, new this.SegmentArc({
id: typeof segment.id === 'undefined' ? index : segment.id,
......@@ -148,7 +148,7 @@
circumference: (this.options.animateRotate) ? 0 : this.calculateCircumference(segment.value),
/// ----- ZUI change begin -----
showLabel: segment.showLabel !== false,
/// ----- ZUI change begin -----
/// ----- ZUI change end -----
label: segment.label
}));
if(!silent) {
......@@ -228,7 +228,7 @@
var chartWidthHalf = this.chart.width / 2;
var chartHeightHalf = this.chart.height / 2;
if(placement === 'outside') {
if(placement === 'outside') { // outside
var isRight = x >= 0;
var lineX = x + chartWidthHalf;
var lineY = y + chartHeightHalf;
......@@ -248,7 +248,8 @@
else labelPos++;
}
while(labelPosMap[isRight ? labelPos : (-labelPos)] && labelPos < maxPos) labelPos++;
if(labelPosMap[labelPos]) return;
if(labelPosMap[isRight ? labelPos : (-labelPos)]) return;
y = (labelPos - 1) * textHeight + options.scaleFontSize / 2;
labelPosMap[labelPos] = true;
......@@ -261,12 +262,11 @@
ctx.strokeWidth = options.scaleLineWidth;
ctx.stroke();
ctx.fillStyle = segment.fillColor;
} else { // outside
} else { // inside
x = x * 0.6 + chartWidthHalf;
y = y * 0.6 + chartHeightHalf;
ctx.fillStyle = ($.zui && $.zui.Color) ? (new $.zui.Color(segment.fillColor).contrast().toCssStr()) : '#fff';
}
ctx.fillText(text, x, y);
},
// ZUI change end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册