就是现在平均线只显示平均数,如果我想显示为,当前平均数为:87 怎么把汉字加上?
配置项如下
var data = JSON.parse("[{\"_value\":102,\"title\":\"上海君悦\",\"value\":44,\"value1\":53},{\"_value\":111,\"title\":\"崇明凯悦\",\"value\":38,\"value1\":43},{\"_value\":60,\"title\":\"深圳万豪\",\"value\":30,\"value1\":37},{\"_value\":104,\"title\":\"三亚希尔顿\",\"value\":66,\"value1\":79},{\"_value\":81,\"title\":\"北京万丽\",\"value\":39,\"value1\":50},{\"_value\":114,\"title\":\"三亚丽思\",\"value\":73,\"value1\":87},{\"_value\":73,\"title\":\"丽江君悦\",\"value\":37,\"value1\":31},{\"_value\":108,\"title\":\"南京威斯汀\",\"value\":47,\"value1\":53},{\"_value\":86,\"title\":\"北京威斯汀\",\"value\":46,\"value1\":51}]");
var option = {
color: ['#3398DB'],
tooltip: { //鼠标滑过提示框设置
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
grid: { //整个图形在页面的位置
left: '4%',
right: '14%',
bottom: '15%',
containLabel: true
},
visualMap: { //柱子颜色渐变
show: false,
min: 0,
max: 50,
dimension: 0,
inRange: {
color: ['#4a657a', '#308e92', '#b1cfa5', '#f5d69f', '#f5898b', '#ef5055']
}
},
xAxis: [ //x轴
{
type: 'category',
axisLabel: {
show: true,
interval: 0, // {number}
rotate: 40,
textStyle: {
fontSize: 12, //字体大小
}
},
data: data.map(function(value, index, arr) {
//alert(JSON.stringify(value.title))
return {
value: value.title,
itemStyle: {
normal: {
//barBorderRadius: [6, 14, 14, 14]
},
emphasis: {
}
}
}
}), //['Mon222222222222', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
axisTick: {
alignWithLabel: true
}
}
],
yAxis: [ //y轴 (x的data放在y里面,则横向显示)
{
type: 'value',
axisLabel: {
show: true,
interval: 3, // {number}
textStyle: {
fontSize: 12, //字体大小
}
},
max: 100,
splitNumber: 10 //刻度分割数
}
],
series: [ //柱子填充内容设置
{
name: '直接访问',
type: 'bar',
position: 'top',
barWidth: '60%', //柱子的宽度
itemStyle: {
normal: {
label: {
show: true,
position: 'top', //数据显示的位置inside为中间
//formatter:'{c}%'//百分比显示
textStyle: {
fontSize: 12, //字体大小
color: '#000'
}
}
}
},
markLine: { //平均线显示
label: {
normal: {
color: '#ff0000',
borderWidth: 1,
borderColor: 'rgba(30,144,255,0.5)',
formatter:function(params){
return '当前平均数为 87';
}
}
},
data: [
//{type : 'average', name: '平均值'}
{
// 固定起点的 x 像素位置,用于模拟一条指向最大值的水平线
yAxis: 'max',
x: '90%'
}, {
type: 'max'
}
]
},
data: data.map(function(value, index, arr) {
//alert(JSON.stringify(value.value1))
return {
value: value.value1,
itemStyle: {
normal: {
//barBorderRadius: [6, 14, 14, 14]
},
emphasis: {
}
}
}
}), //[93.73, 90.5, 88, 36, 86, 100, 65]
}
]
};