标签:
1.新建项目,引入jquery包,Echarts文件及需要的图表文件4.通过jquery.Ajax获取并绑定数据(survey.js)...<!--chart[[--><script src="Scripts/echarts.js" type="text/javascript"></script><script src="Scripts/survey.js" type="text/javascript"></script><!--chart]]--></body>
var data_bar = Object;// 引入文件require.config({paths: {echarts: ‘./Scripts‘}});// 引入需要的脚本require([‘echarts‘,‘echarts/chart/bar‘,‘echarts/chart/pie‘],function (ec) {//获取柱形图数据GetBarData();// 通过id获取div,初始化var myChart = ec.init(document.getElementById(‘tabShow1‘));myChart.setOption({tooltip: {trigger: ‘axis‘},legend: {x: ‘76%‘,y: ‘5%‘,data: [‘bar1name‘, ‘bar2name‘]},color: [‘#2ec7c9‘, ‘#b6a2de‘, ‘#99d2dd‘, ‘#88b0bb‘, ‘#1c7099‘],calculable: true,xAxis: [{type: ‘category‘,axisLabel: { ‘interval‘: 0 },data: data_bar.xraydata}],yAxis: [{type: ‘value‘,splitArea: { show: true }}],series: [{name: ‘bar1name‘,type: ‘bar‘,data: data_bar.registdata,markPoint: { data: [{ type: ‘max‘, name: ‘最大值‘ }, { type: ‘min‘, name: ‘最小值‘}] }},{name: ‘bar2name‘,type: ‘bar‘,data: data_bar.surveydata,markPoint: { data: [{ type: ‘max‘, name: ‘最大值‘ }, { type: ‘min‘, name: ‘最小值‘}] }}]});}});//获取数据function GetBarData() {$.ajax({//资源文件路径url: ‘Analysisdata.ashx‘,// 参数data: { oper: "bardata" },cache: false,async: false,// 数据类型dataType: "json",success: function (data) {if (data != null) {if (data) {data_bar = data;}else {alert("获取失败");}}},error: function (e) {alert("获取失败");}});}
6.运行效果
标签:
原文地址:http://www.cnblogs.com/touphery/p/4210539.html