同样的代码,我在本地的网页,柱形图的起点就在X轴的下面??但是在官方用例上编辑,就没有问题
配置项如下
option = {
title: {
text:'Y轴设置scale之后柱形图的起点在X轴下面',
// subtext: 'From ExcelHome',
x:'center',
textStyle:{
color:'#3f5f82',
// fontStyle:'oblique',
fontWeight:'bold',
fontSize:24,
left:'center',
// align:'center'
},
},
color: ['#27BAE5','#67C23A','#e9cb73'],
tooltip: {
trigger: 'axis',
// formatter: '{b0}<br />{a0}: {c0}<br />{a1}: {c1}<br />{a2}: {c2}%',
axisPointer:
{
type: 'cross'
}
},
toolbox: {
top:25,
show : true,
itemGap: 3,
right:20,
feature : {
dataView : {show: true, readOnly: false},
magicType : {show: true, type: ['line']},
restore : {show: true},
saveAsImage : {show: true}
}
},
legend: {
data:['当期值','同期值','同比增减'],
left:'center',
top:30
},
grid: {
left:'40',
right: '55',
top:'80',
bottom:'30'
},
xAxis: [
{
type: 'category',
data: ["59","66","70","55"],
// axisPointer: {
// type: 'shadow'
// },
// axisLabel: {
// rotate: 50,
// interval: 0,
// fontSize:9
// }
}
],
yAxis : [
{
name:"leftY",
type : 'value',
scale:true,
// power:1,
// precision:1,
// max:100,
// min:20,
},
{
name:"leftY",
type : 'value',
// scale:true,
// axisLabel: {
// formatter: '{value} %'
// },
splitLine: {
show: false
}
}
],
series: [
{
name:'当期值',
type:'bar',
smooth: true,
data:["59","66","70","55"],
markPoint : {
z:3,
zlevel:3,
data : [
{type : 'max', name: '最大值'},
{type : 'min', name: '最小值'}
],
itemStyle:{
normal:{
label:{
show: true,
formatter: function (param) {
var num=param.value;
num = Math.round(num*10000)/10000
var source = String(num).split(".");
source[0] = source[0].replace(new RegExp('(\\d)(?=(\\d{3})+$)','ig'),"$1,");
return source.join(".");
}
}
}
},
},
},
{
name:'同期值',
type:'bar',
smooth: true,
data:["59","66","70","55"],
barGap:'5%',
markPoint : {
data : [
{type : 'max', name: '最大值'},
{type : 'min', name: '最小值'}
],
itemStyle:{
normal:{
label:{
show: true,
formatter: function (param) {
var num=param.value;
num = Math.round(num*10000)/10000
var source = String(num).split(".");
source[0] = source[0].replace(new RegExp('(\\d)(?=(\\d{3})+$)','ig'),"$1,");
return source.join(".");
}
}
}
},
},
},
{
name:'同比增减',
type:'line',
smooth: true,
yAxisIndex: 1,
data:["-0.03","0.5","0.32","-0.5"],
markPoint : {
data : [
{type : 'max', name: '最大值'},
{type : 'min', name: '最小值'}
],
itemStyle:{
normal:{
label:{
show: true,
formatter: function (param) {
var num=param.value;
num = Math.round(num*10000)/10000
var source = String(num).split(".");
source[0] = source[0].replace(new RegExp('(\\d)(?=(\\d{3})+$)','ig'),"$1,");
return source.join(".");
}
}
}
},
},
}
]
};