<!DOCTYPE html>
<html>
<!-- https://blog.csdn.net/weixin_42698255/article/details/89249531 -->
<head>
<meta charset="utf-8">
<title>五分鍾上手之餅狀</title>
<!-- 引入 echarts.js -->
<script src="https://cdn.bootcss.com/echarts/4.2.1-rc1/echarts.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
</head>
<body>
<!-- 為ECharts准備一個具備大小(寬高)的Dom -->
<div id="main" style="width: 800px;height:700px; background: pink;"></div>
<script type="text/javascript">
// 基於准備好的dom,初始化echarts實例
var myChart = echarts.init(document.getElementById('main'));
// 指定圖表的配置項和數據
myChart.setOption({
tooltip: {
trigger: 'item',
formatter: "{a} <br/>{b}: {c} ({d}%)"
},
title: {
text: '我是第一餅狀圖',
subtext: '我是第一個的副標題',
x: 'center',
y: '630px',
// 控制主標題的樣似
textStyle: {//主標題的屬性
color: '#C28D21',//顏色
fontSize: 24,//大小
fontWeight:400,//
},
// 控制副標題的樣似
subtextStyle: {//副標題的屬性
color: '#C28D21',
fontSize: 24,//大小
},
},
series: [{
name: '訪問來源',
type: 'pie',
radius: ['50%', '70%'],
avoidLabelOverlap: false,
label: {
normal: {
show: false,
position: 'center'
},
emphasis: {
show: true,
textStyle: {
fontSize: '30',
fontWeight: 'bold'
}
}
},
labelLine: {
normal: {
show: false
}
},
data: [{
value: 12,
name: '在線',
itemStyle: {
color: '#005eff'
}
},
{
value: 3,
name: '離線',
itemStyle: {
color: '#ff9194'
}
},
]
}]
});
</script>
</body>
</html>
