<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://cdn.bootcss.com/echarts/4.3.0-rc.2/echarts.js"></script>
</head>
<body>
<!-- 为ECharts准备一个具备大小(宽高)的Dom -->
<div id="main" style="width: 800px;height:500px;"></div>
<script>
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('main'));
var option = {
'title' : {
text: '一周发消息总数',
subtext: '估计'
},
'tooltip': {
'show': 'true',
'trigger': 'axis',
'axisPointer': { // 坐标轴指示器
'type': 'shadow', // 默认为直线,可以设置为:'line' | 'shadow'
'lineStyle': {
'color': 'rgba(150, 150, 150, 0.3)' // 坐标轴指示器颜色
},
z: 0 // 层级低
},
'background': 'rgba(0, 0, 0, .60)',
'padding': 16,
'textStyle': {
'color': '#2c8fff',
'lineHeight': 22
}
},
'legend': {
data: ['发送消息总条数']
},
toolbox: {
'show': true,
'feature': {
'dataView': {show: true, readOnly: false},
'magicType': {show: true, type: ['line', 'bar']},
'restore': {show: true},
'saveAsImage': {show: true}
}
},
'calculable': false,
'animation ': false,
'xAxis': [{
'type': 'category',
'name': '(时间)',
'axisLine': {
'show': true,
'lineStyle': {
'color': '#000' // 更改坐标轴颜色
},
'textStyle': {
'fontSize': 12,
'color': '#ccc'
}
},
'axisTick': { // x轴刻度线
'show': true
},
'data': ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
'offset': 20 // x轴距离星期的距离
}],
'yAxis': [{
'type': 'value',
'name': '(条)',
'axisLine': {
'show': true,
'lineStyle': {
'color': '#000' // 更改坐标轴颜色
},
'textStyle': {
'fontSize': 12,
'color': '#ccc'
}
},
'axisTick': { // y轴刻度线
'show': true
},
'splitLine': { // 网络线
'show': true,
'lineStyle': {
'type': 'line' // 虚线
}
},
'max': 150 // Y轴最大值
}],
'series': [{
'name': '发送消息总条数',
'type': 'line',
'lineStyle': {
'color': '#2C8FFF' // 更改坐标轴颜色
},
'itemStyle': {
'normal': {
'color': '#FFB6C1', // 拐点颜色
'borderColor': '#FFB6C1', // 拐点边框颜色
'borderWidth': 3 // 拐点边框大小
}
},
'symbol': 'circle', // 圆点
'showAllSymbol': false, // 如果数据很多,不显示所有的圆点
'data': [10, 15, 20, 40, 70, 100, 120] // 渲染的数据
}]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
</script>
</body>
显示效果: