提交 269eeaaf 编写于 作者: K kener

bar label position支持 insideX

bar label position支持
‘insideLeft’,‘insideRight’,‘insideTop’‘insideBottom’
上级 b025d93e
......@@ -124,7 +124,7 @@ option = {
borderColor: 'tomato',
borderWidth: 6,
label : {
show: true, position: 'inside'
show: true, position: 'insideTop'
}
}
},
......
......@@ -104,35 +104,35 @@ option = {
name:'直接访问',
type:'bar',
stack: '总量',
itemStyle : { normal: {label : {show: true, position: 'inside'}}},
itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
data:[320, 302, 301, 334, 390, 330, 320]
},
{
name:'邮件营销',
type:'bar',
stack: '总量',
itemStyle : { normal: {label : {show: true, position: 'inside'}}},
itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
data:[120, 132, 101, 134, 90, 230, 210]
},
{
name:'联盟广告',
type:'bar',
stack: '总量',
itemStyle : { normal: {label : {show: true, position: 'inside'}}},
itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
data:[220, 182, 191, 234, 290, 330, 310]
},
{
name:'视频广告',
type:'bar',
stack: '总量',
itemStyle : { normal: {label : {show: true, position: 'inside'}}},
itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
data:[150, 212, 201, 154, 190, 330, 410]
},
{
name:'搜索引擎',
type:'bar',
stack: '总量',
itemStyle : { normal: {label : {show: true, position: 'inside'}}},
itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
data:[820, 832, 901, 934, 1290, 1330, 1320]
}
]
......
......@@ -81,7 +81,7 @@ var dataStyle = {
normal: {
label : {
show: true,
position: 'inside',
position: 'insideLeft',
formatter: '{c}%'
}
}
......
......@@ -843,6 +843,43 @@ define(function (require) {
barShape.highlightStyle.textColor = barShape.highlightStyle.color;
barShape = this.addLabel(barShape, serie, data, name, orient);
if (barShape.style.textPosition == 'insideLeft'
|| barShape.style.textPosition == 'insideRight'
|| barShape.style.textPosition == 'insideTop'
|| barShape.style.textPosition == 'insideBottom'
) {
var gap = 5;
switch (barShape.style.textPosition) {
case 'insideLeft' :
barShape.style.textX = barShape.style.x + gap;
barShape.style.textY = barShape.style.y + barShape.style.height / 2;
barShape.style.textAlign = 'left';
barShape.style.textBaseline = 'middle';
break;
case 'insideRight' :
barShape.style.textX = barShape.style.x + barShape.style.width - gap;
barShape.style.textY = barShape.style.y + barShape.style.height / 2;
barShape.style.textAlign = 'right';
barShape.style.textBaseline = 'middle';
break;
case 'insideTop' :
barShape.style.textX = barShape.style.x + barShape.style.width / 2;
barShape.style.textY = barShape.style.y + gap / 2;
barShape.style.textAlign = 'center';
barShape.style.textBaseline = 'top';
break;
case 'insideBottom' :
barShape.style.textX = barShape.style.x + barShape.style.width / 2;
barShape.style.textY = barShape.style.y + barShape.style.height - gap / 2;
barShape.style.textAlign = 'center';
barShape.style.textBaseline = 'bottom';
break;
}
barShape.style.textPosition = 'specific';
barShape.style.textColor = barShape.style.textColor || '#fff';
}
if (this.deepQuery([data, serie, this.option],'calculable')) {
this.setCalculable(barShape);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册