<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>第一个 ECharts 实例</title>
<!-- 引入 echarts.js -->
<script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>
</head>
<body>
<div id="main" style="width: 600px; height: 400px"></div>
<script type="text/javascript">
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById("main"));
// 指定图表的配置项和数据
var option = {
tooltip: {
trigger: "axis",
formatter: "{b0}({a0}): {c0}<br />{b1}({a1}): {c1}%",
},
legend: {
data: ["销量", "占比"],
},
xAxis: {
data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"],
},
yAxis: [
{
type: "value",
name: "销量",
show: true,
interval: 10,
axisLine: {
lineStyle: {
color: "#5e859e",
width: 2,
},
},
},
{
type: "value",
name: "占比",
min: 0,
max: 100,
interval: 10,
axisLabel: {
formatter: "{value} %",
},
axisLine: {
lineStyle: {
color: "#5e859e", //纵坐标轴和字体颜色
width: 2,
},
},
},
],
series: [
{
name: "销量",
type: "bar",
barWidth: "50%",
data: [5, 20, 36, 10, 10, 20],
},
{
name: "占比",
type: "line",
smooth: true,
data: [15, 30, 46, 20, 20, 30],
},
],
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
</script>
</body>
</html>
手机扫一扫
移动阅读更方便
你可能感兴趣的文章