option图表选项,包含图表实例任何可配置选项: 公共选项 , 组件选项 , 数据选项
例子:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>ceshi</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <!-- 为ECharts准备一个具备大小(宽高)的Dom --> <div id="main" style="height:400px"></div> <!-- ECharts单文件引入 --> <!--<script src="http://echarts.baidu.com/build/dist/echarts.js"></script> --> <script type="text/javascript" src="res/skin/tjsn/plugin/echarts/echarts.js"></script> <script type="text/javascript"> require.config({ paths: { echarts: 'http://echarts.baidu.com/build/dist' } }); // 使用 require( [ 'echarts', 'echarts/chart/bar', // 使用柱状图就加载bar模块,按需加载 'echarts/chart/line', //使用折现图加载line模块, 'echarts/chart/scatter', //使用散点图加载scatter模块, 'echarts/chart/pie', //使用饼图加载pie模块, ], function (ec) { // 基于准备好的dom,初始化echarts图表 var myChart = ec.init(document.getElementById('main')); var option = { title : { text: '某楼盘销售情况', subtext: '纯属虚构' }, tooltip : { trigger: 'axis' }, legend: { data:['预购','成交'] }, toolbox: { show : true, feature : { mark : {show: true}, dataView : {show: true, readOnly: true}, magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']}, restore : {show: true}, saveAsImage : {show: true} } }, calculable : false, xAxis : [ //X轴数据 { type : 'category', boundaryGap : true, data : ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'] } ], yAxis : [ //Y轴数据 { type : 'value' } ], series : [ //驱动图表数据 { name:'成交', type:'bar', //设置 默认显示图表形状 bar smooth:true, itemStyle: {normal: {areaStyle: {type: 'default'}}}, data:[10, 12, 21, 54, 260, 830, 710] }, { name:'预购', type:'bar', //设置 默认显示图表形状 bar smooth:true, itemStyle: {normal: {areaStyle: {type: 'default'}}}, data:[30, 182, 434, 791, 390, 30, 10] } ] }; // 为echarts对象加载数据 myChart.setOption(option); } ); </script> </body> </html> |
|
来自: _明心见性_ > 《ECharts图表》