数据类型
我这里用了三种数据类型
- 饼图
var pieData = [{
'name' : 'aaa', 'value' : 2},{
'name' : 'bbb', 'value' : 2},{
'name' : 'vvv', 'value' : 2},{
'name' : 'ddd', 'value' : 2}];
2.柱状图或者折现图(Echarts的DataSet格式1);
var barOrLine1 = [["product","当前任务数","当前商品数","完成任务数","完成商品数"],["挑货",3,12,0,0],["出库",0,0,0,0],["放置",0,0,0,0],["打标",0,0,0,0]];
3.柱状图或者折现图(Echarts的DataSet格式2);
var barOrLine2 = [{
"product":"2019-04-12","创业A订单数":"0","创业A产量":"0"},{
"product":"2019-04-13","创业A订单数":"0","创业A产量":"0"},{
"product":"2019-04-14","创业A订单数":"0","创业A产量":"0"},{
"product":"2019-04-15","创业A订单数":"0","创业A产量":"0"}]
实现代码
var swiftcharts = swiftcharts || (function() {
var utils = {
dataShow: function(JSONData, chartsType) {
// this._includeLinkStyle('');
var table = '<table class="table table-hover table-bordered table-striped text-center" style="color:#000">';
var arrData = typeof JSONData != 'object' ? JSON.parse(JSONData) : JSONData;
var row = "<tr>";
if (arrData.length >= 2) {
if (arrData[1] instanceof Array) {
for (var i = 0,
l = arrData[0].length; i < l; i++) {
row += "<th class='text-center'>" + (arrData[0][i] == 'product' ? '': arrData[0][i]) + '</th>';
}
} else {
if (chartsType === _chartsType[0]) {
var rowTd = "<tr>";
for (var i = 0,
l = arrData.length; i < l; i++) {
row += "<th class='text-center'>" + (arrData[i].name) + '</th>';
rowTd += "<td class='text-center'>" + (arrData[i].value) + '</td>';
}
table += row + "</tr>";
table += rowTd + "</tr>";
table += "</table>";
return table;
}
var ShowLabel = new Array();
if (JSONData != null) {
var keySet = Object.keys(JSONData[0]</