Echarts柱状图

简介:
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. <!DOCTYPE html>  
  2. <html lang="en">  
  3. <head>  
  4.     <meta charset="utf-8" />  
  5.     <title>ECharts-基本线性图及其配置要求</title>  
  6.     <script src="js/esl.js" type="text/javascript"></script>  
  7. </head>  
  8. <body>  
  9.     <div id="main" style="height: 400px; border: 1px solid #ccc; padding: 10px;">  
  10.     </div>  
  11.     <script type="text/javascript" language="javascript">  
  12.         // 按需加载  
  13.         // Step:3 conifg ECharts's path, link to echarts.js from current page.  
  14.         // Step:3 为模块加载器配置echarts的路径,从当前页面链接到echarts.js,定义所需图表路径  
  15.         require.config({  
  16.             paths: {  
  17.                 echarts: './js/echarts' //echarts.js的路径  
  18.             }  
  19.         });  
  20.         // Step:4 require echarts and use it in the callback.  
  21.         // Step:4 动态加载echarts然后在回调函数中开始使用,注意保持按需加载结构定义图表路径  
  22.         require(  
  23.         [  
  24.             'echarts',  
  25.             'echarts/chart/bar'  
  26.         ],  
  27.         //回调函数  
  28.         DrawEChart  
  29.         );  
  30.   
  31.         //渲染ECharts图表  
  32.         function DrawEChart(ec) {  
  33.             //图表渲染的容器对象  
  34.             var chartContainer = document.getElementById("main");  
  35.             //加载图表  
  36.             var myChart = ec.init(chartContainer);  
  37.             myChart.setOption({  
  38.                 tooltip : {  
  39.         trigger: 'axis',  
  40.         axisPointer : {            // 坐标轴指示器,坐标轴触发有效  
  41.             type : 'shadow'        // 默认为直线,可选为:'line' | 'shadow'  
  42.         }  
  43.     },  
  44.     legend: {  
  45.         data:['新闻', '论坛','博客','微博']  
  46.     },  
  47.     toolbox: {  
  48.         show : true,  
  49.         feature : {  
  50.             mark : {show: true},  
  51.             dataView : {show: true, readOnly: false},  
  52.             magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},  
  53.             restore : {show: true},  
  54.             saveAsImage : {show: true}  
  55.         }  
  56.     },  
  57.     calculable : true,  
  58.     xAxis : [  
  59.         {  
  60.             name : '数量',  
  61.             type : 'value'  
  62.         }  
  63.     ],  
  64.     yAxis : [  
  65.         {  
  66.             name : '关键词',  
  67.             type : 'category',  
  68.             data : ['关键词1','关键词2','关键词2']  
  69.         }  
  70.     ],  
  71.     series : [  
  72.         {  
  73.             name:'新闻',  
  74.             type:'bar',  
  75.             stack: '总量',  
  76.             itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},  
  77.             data:[320, 302, 301]  
  78.         },  
  79.         {  
  80.             name:'论坛',  
  81.             type:'bar',  
  82.             stack: '总量',  
  83.             itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},  
  84.             data:[120, 132, 101]  
  85.         },  
  86.         {  
  87.             name:'博客',  
  88.             type:'bar',  
  89.             stack: '总量',  
  90.             itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},  
  91.             data:[220, 182, 191]  
  92.         },  
  93.         {  
  94.             name:'微博',  
  95.             type:'bar',  
  96.             stack: '总量',  
  97.             itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},  
  98.             data:[150, 212, 201]  
  99.         },  
  100.          
  101.     ]  
  102.         });  
  103.         }  
  104.     </script>  
  105. </body>  
  106. </html>  

目录
相关文章
|
5月前
|
JSON 前端开发 数据格式
【前端统计图】echarts实现简单柱状图
【前端统计图】echarts实现简单柱状图
43 0
|
5月前
ECharts 柱状图横轴(X轴)文字内容显示不全
ECharts 柱状图横轴(X轴)文字内容显示不全
106 0
|
6月前
235Echarts - 3D 柱状图(Voxelize image)
235Echarts - 3D 柱状图(Voxelize image)
47 0
235Echarts - 3D 柱状图(Voxelize image)
|
4月前
设置echarts的grid、tooltip、柱状图渐变色、折线图渐变色
设置echarts的grid、tooltip、柱状图渐变色、折线图渐变色
|
4月前
Echarts柱状图x轴刻度间隔显示不全/x轴文字倾斜
Echarts柱状图x轴刻度间隔显示不全/x轴文字倾斜
59 0
|
4月前
Echarts 柱状图添加标记 最大值 最小值 平均值
Echarts 柱状图添加标记 最大值 最小值 平均值
|
4月前
|
容器
Echarts 最简单创建柱状图
Echarts 最简单创建柱状图
|
5月前
|
JSON 数据可视化 JavaScript
vue+echarts实现一个叠堆柱状图
vue+echarts实现一个叠堆柱状图
46 0
|
5月前
关于Echarts柱状图监听点击事件的实现方法
关于Echarts柱状图监听点击事件的实现方法
104 0
|
5月前
|
JSON 数据格式
Echarts+ajax实现叠堆柱状图
Echarts+ajax实现叠堆柱状图
28 0