define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echarts-theme', 'template'], function ($, undefined, Backend, Datatable, Table, Echarts, undefined, Template) { var Controller = { index: function () { var that = this; var myChart = Echarts.init(document.getElementById('echart'), 'walden'); Fast.api.ajax({ url: window.Config.moduleurl+"/csminvite/dashboard/indexChartDataset", type: "get", }, function (data, ret) { var option = that._option(data); myChart.setOption(option); return false; }, function (data, ret) { return false; }); $(window).resize(function () { myChart.resize(); }); $(document).on("click", ".btn-refresh", function () { window.location.reload(); }); }, _option:function(data){ console.log(data.dataset); var source2 = []; for(var item in data.dataset){ source2.push(data.dataset[item]); } var option = { legend: {}, tooltip: {}, dataset: { // 提供一份数据。 source: source2 }, grid:{ left:50, right:0, top:50, bottom:50 }, color: ['#EC7366', '#1BDAB4', '#50a6e0','#918EC3'], // 声明一个 X 轴,类目轴(category)。默认情况下,类目轴对应到 dataset 第一列。 xAxis: {type: 'category'}, // 声明一个 Y 轴,数值轴。 yAxis: {}, // 声明多个 bar 系列,默认情况下,每个系列会自动对应到 dataset 的每一列。 series: [ {type: 'bar', barWidth : 15}, {type: 'bar', barWidth : 15}, {type: 'bar', barWidth : 15}, {type: 'bar', barWidth : 15} ] }; return option; } }; return Controller; });