echart单击后获取横坐标值_echart 横坐标倾斜
var width;
var height;
var myChart;
$(function() {
//自適應設置
width = $(window).width();
height = $(window).height();
$("#mainBar").css("width", width - 40);
$("#mainBar").css("height", height - 40);
console.log(height);
setEcharts();
});
$(window).resize(function() {
width = $(window).width();
height = $(window).height();
$("#mainBar").css("width", width - 40);
$("#mainBar").css("height", height - 40);
});
function setEcharts() {
myChart = echarts.init(document.getElementById('mainBar'));
//自適應
window.onresize = myChart.resize;
myChart.setOption({
tooltip: {
trigger: 'axis'
},
legend: {
data: ['蒸發量', '降水量']
},
toolbox: {
show: true,
feature: {
mark: {
show: true
},
dataView: {
show: true,
readOnly: false
},
magicType: {
show: true,
type: ['line', 'bar']
},
restore: {
show: true
},
saveAsImage: {
show: true
}
}
},
calculable: true,
xAxis: [{
type: 'category',
data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
//設置字體傾斜
axisLabel: {
interval: 0,
rotate: 45,
//傾斜度 -90 至 90 默認為0
margin: 2,
textStyle: {
fontWeight: "bolder",
color: "#000000"
}
},
}],
yAxis: [{
type: 'value',
splitArea: {
show: true
}
}],
series: [{
name: '蒸發量',
type: 'bar',
data: [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
},
{
name: '降水量',
type: 'bar',
data: [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],
//頂部數字展示pzr
itemStyle: {
normal: {
label: {
show: true,
//是否展示
textStyle: {
fontWeight: 'bolder',
fontSize: '12',
fontFamily: '微軟雅黑',
}
}
}
},
}]
});
}
總結
以上是生活随笔為你收集整理的echart单击后获取横坐标值_echart 横坐标倾斜的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java skype 类库_Skype4
- 下一篇: iis 不是 php,iis是不是默认支