echarts的 各种参数

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片

  1. 转载:http://blog.csdn.net/zou128865/article/details/42802671  
  2.   
  3.     <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>    
  4.     <%    
  5.     String path = request.getContextPath();    
  6.     String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";    
  7.     %>    
  8.         
  9.     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">    
  10.     <html>    
  11.       <head>    
  12.         <base href="<%=basePath%>">    
  13.         <title>ECharts实例</title>    
  14.       </head>    
  15.       <body>    
  16.         <!--Step:1 Prepare a dom for ECharts which (must) has size (width & hight)-->    
  17.         <!--Step:1 为ECharts准备一个具备大小(宽高)的Dom-->    
  18.         <div id="mainBar" style="height:500px;border:1px solid #ccc;padding:10px;"></div>    
  19.             
  20.         <!--Step:2 Import echarts.js-->    
  21.         <!--Step:2 引入echarts.js-->    
  22.         <script src="js/echarts.js"></script>    
  23.             
  24.         <script type="text/javascript">    
  25.         // Step:3 conifg ECharts's path, link to echarts.js from current page.    
  26.         // Step:3 为模块加载器配置echarts的路径,从当前页面链接到echarts.js,定义所需图表路径    
  27.         require.config({    
  28.             paths: {    
  29.                 echarts: './js'    
  30.             }    
  31.         });    
  32.             
  33.         // Step:4 require echarts and use it in the callback.    
  34.         // Step:4 动态加载echarts然后在回调函数中开始使用,注意保持按需加载结构定义图表路径    
  35.         require(    
  36.             [    
  37.                 //这里的'echarts'相当于'./js'    
  38.                 'echarts',    
  39.                 'echarts/chart/bar',    
  40.                 'echarts/chart/line',    
  41.             ],    
  42.             //创建ECharts图表方法    
  43.             function (ec) {    
  44.                 //--- 折柱 ---    
  45.                     //基于准备好的dom,初始化echart图表    
  46.                 var myChart = ec.init(document.getElementById('mainBar'));    
  47.                 //定义图表option    
  48.                 var option = {    
  49.                     //标题,每个图表最多仅有一个标题控件,每个标题控件可设主副标题    
  50.                     title: {    
  51.                         //主标题文本,'\n'指定换行    
  52.                         text: '2013年广州降水量与蒸发量统计报表',    
  53.                         //主标题文本超链接    
  54.                         link: 'http://www.tqyb.com.cn/weatherLive/climateForecast/2014-01-26/157.html',    
  55.                         //副标题文本,'\n'指定换行    
  56.                         subtext: 'www.stepday.com',    
  57.                         //副标题文本超链接    
  58.                         sublink: 'http://www.stepday.com/myblog/?Echarts',    
  59.                         //水平安放位置,默认为左侧,可选为:'center' | 'left' | 'right' | {number}(x坐标,单位px)    
  60.                         x: 'left',    
  61.                         //垂直安放位置,默认为全图顶端,可选为:'top' | 'bottom' | 'center' | {number}(y坐标,单位px)    
  62.                         y: 'top'    
  63.                     },    
  64.                     //提示框,鼠标悬浮交互时的信息提示    
  65.                     tooltip: {    
  66.                         //触发类型,默认('item')数据触发,可选为:'item' | 'axis'    
  67.                         trigger: 'axis'    
  68.                     },    
  69.                     //图例,每个图表最多仅有一个图例    
  70.                     legend: {    
  71.                         //显示策略,可选为:true(显示) | false(隐藏),默认值为true    
  72.                         show: true,    
  73.                         //水平安放位置,默认为全图居中,可选为:'center' | 'left' | 'right' | {number}(x坐标,单位px)    
  74.                         x: 'center',    
  75.                         //垂直安放位置,默认为全图顶端,可选为:'top' | 'bottom' | 'center' | {number}(y坐标,单位px)    
  76.                         y: 'top',    
  77.                         //legend的data: 用于设置图例,data内的字符串数组需要与sereis数组内每一个series的name值对应    
  78.                         data: ['蒸发量','降水量']    
  79.                     },    
  80.                     //工具箱,每个图表最多仅有一个工具箱    
  81.                     toolbox: {    
  82.                         //显示策略,可选为:true(显示) | false(隐藏),默认值为false    
  83.                         show: true,    
  84.                         //启用功能,目前支持feature,工具箱自定义功能回调处理    
  85.                         feature: {    
  86.                             //辅助线标志    
  87.                             mark: {show: true},    
  88.                             //dataZoom,框选区域缩放,自动与存在的dataZoom控件同步,分别是启用,缩放后退    
  89.                             dataZoom: {    
  90.                                 show: true,    
  91.                                  title: {    
  92.                                     dataZoom: '区域缩放',    
  93.                                     dataZoomReset: '区域缩放后退'    
  94.                                 }    
  95.                             },    
  96.                             //数据视图,打开数据视图,可设置更多属性,readOnly 默认数据视图为只读(即值为true),可指定readOnly为false打开编辑功能    
  97.                             dataView: {show: true, readOnly: true},    
  98.                             //magicType,动态类型切换,支持直角系下的折线图、柱状图、堆积、平铺转换    
  99.                             magicType: {show: true, type: ['line', 'bar']},    
  100.                             //restore,还原,复位原始图表    
  101.                             restore: {show: true},    
  102.                             //saveAsImage,保存图片(IE8-不支持),图片类型默认为'png'    
  103.                             saveAsImage: {show: true}    
  104.                         }    
  105.                     },    
  106.                     //是否启用拖拽重计算特性,默认关闭(即值为false)    
  107.                     calculable: true,    
  108.                     //直角坐标系中横轴数组,数组中每一项代表一条横轴坐标轴,仅有一条时可省略数值    
  109.                     //横轴通常为类目型,但条形图时则横轴为数值型,散点图时则横纵均为数值型    
  110.                     xAxis: [    
  111.                         {    
  112.                             //显示策略,可选为:true(显示) | false(隐藏),默认值为true    
  113.                             show: true,    
  114.                             //坐标轴类型,横轴默认为类目型'category'    
  115.                             type: 'category',    
  116.                             //类目型坐标轴文本标签数组,指定label内容。 数组项通常为文本,'\n'指定换行    
  117.                             data: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']    
  118.                         }    
  119.                     ],    
  120.                     //直角坐标系中纵轴数组,数组中每一项代表一条纵轴坐标轴,仅有一条时可省略数值    
  121.                     //纵轴通常为数值型,但条形图时则纵轴为类目型    
  122.                     yAxis: [    
  123.                         {    
  124.                             //显示策略,可选为:true(显示) | false(隐藏),默认值为true    
  125.                             show: true,    
  126.                             //坐标轴类型,纵轴默认为数值型'value'    
  127.                             type: 'value',    
  128.                             //分隔区域,默认不显示    
  129.                             splitArea: {show: true}    
  130.                         }    
  131.                     ],    
  132.                         
  133.                     //sereis的数据: 用于设置图表数据之用。series是一个对象嵌套的结构;对象内包含对象    
  134.                     series: [    
  135.                         {    
  136.                             //系列名称,如果启用legend,该值将被legend.data索引相关    
  137.                             name: '蒸发量',    
  138.                             //图表类型,必要参数!如为空或不支持类型,则该系列数据不被显示。    
  139.                             type: 'bar',    
  140.                             //系列中的数据内容数组,折线图以及柱状图时数组长度等于所使用类目轴文本标签数组axis.data的长度,并且他们间是一一对应的。数组项通常为数值    
  141.                             data: [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3],    
  142.                             //系列中的数据标注内容    
  143.                             markPoint: {    
  144.                                 data: [    
  145.                                     {type: 'max', name: '最大值'},    
  146.                                     {type: 'min', name: '最小值'}    
  147.                                 ]    
  148.                             },    
  149.                             //系列中的数据标线内容    
  150.                             markLine: {    
  151.                                 data: [    
  152.                                     {type: 'average', name: '平均值'}    
  153.                                 ]    
  154.                             }    
  155.                         },    
  156.                         {    
  157.                             //系列名称,如果启用legend,该值将被legend.data索引相关    
  158.                             name: '降水量',    
  159.                             //图表类型,必要参数!如为空或不支持类型,则该系列数据不被显示。    
  160.                             type: 'bar',    
  161.                             //系列中的数据内容数组,折线图以及柱状图时数组长度等于所使用类目轴文本标签数组axis.data的长度,并且他们间是一一对应的。数组项通常为数值    
  162.                             data: [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],    
  163.                             //系列中的数据标注内容    
  164.                             markPoint: {    
  165.                                 data: [    
  166.                                     {type: 'max', name: '最大值'},    
  167.                                     {type: 'min', name: '最小值'}    
  168.                                 ]    
  169.                             },    
  170.                             //系列中的数据标线内容    
  171.                             markLine: {    
  172.                                 data: [    
  173.                                     {type: 'average', name: '平均值'}    
  174.                                 ]    
  175.                             }    
  176.                         }    
  177.                     ]    
  178.                 };    
  179.                         
  180.                 //为echarts对象加载数据                
  181.                 myChart.setOption(option);    
  182.             }    
  183.         );    
  184.         </script>    
  185.       </body>    
  186.     </html>    
  187. 官方文档 http://echarts.baidu.com/echarts2/doc/doc.html#Grid   http://echarts.baidu.com/option.html#xAxis.axisLine.lineStyle.color  

猜你喜欢

转载自blog.csdn.net/Bruce__taotao/article/details/52815550