<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>echart 柱狀圖 (精簡)</title> <script src="https://cdn.bootcss.com/echarts/3.7.2/echarts-en.js"></script> </head> <body> <!-- 爲ECharts準備一個具有大小(寬高)的Dom --> <div id="main" style="width: 120px;height:80px;"></div> <script type="text/javascript"> // 基於準備好的dom,初始化echarts實例 var myChart = echarts.init(document.getElementById('main')); // 指定圖表的配置項和數據 var option = { grid: { top: '3%', left: '3%', right: '3%', bottom: '3%', containLabel: false }, xAxis: { //show: false, type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], axisLabel: { show: false }, axisTick: { show: false }, //boundaryGap: true, //offset: 20 }, yAxis: { type: 'value', axisLabel: { show: false }, axisTick: { show: false }, splitLine: { show: false }, boundaryGap: ['20%', '20%'] }, series: [{ data: [120, 200, 150, 80, 70, 110, 130], type: 'bar' }] }; // 使用剛指定的配置項和數據顯示圖表。 myChart.setOption(option); </script> </body> </html>