MultiDChart_wev8.js
6.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
var _MEC_ChartWidth;
if(typeof(Mobile_NS) == 'undefined'){
Mobile_NS = {};
}
Mobile_NS.MultiDChart = {};
Mobile_NS.MultiDChart.onload = function(p){
var theId = p["id"];
var result = this.getMaxSize(Number(p.width)||0, Number(p.height)||0);
var maxWidth = result.width;
var maxHeight = result.height;
_MEC_ChartWidth = $("#multiDChartContainer_" + theId).width();
$("#multiDChartContainer_"+theId).height(maxHeight);
BuildChart_ColumnMulti3D(p);
};
function BuildMultiChartWhenDataGet(p, fn){
var theId = p["id"];
var $multiDChartContainer = $("#multiDChartContainer_" + theId);
var tabSourceMaps = p["tabSourceMaps"];
var multiLJson = p['multiLJson'];
var checkFlag = true;
if(typeof(tabSourceMaps) == "undefined" || tabSourceMaps.length == 0){
var tipHtm = "<div class=\"Design_Chart_Tip\">"+multiLJson['4205']+"</div>";//图表信息设置不完整,未配置数据来源SQL
$multiDChartContainer.html(tipHtm);
return;
}else{
var tipHtm;
var _mode = p["_mode"];
var requestParam = {}, url = "";
if(_mode == "0"){
var name = "", datasource = "", datasql = "";
for(var i = 0; tabSourceMaps && i < tabSourceMaps.length; i++){
var tabSourceMap = tabSourceMaps[i];
var sql = tabSourceMap["datasql"];
if(tabSourceMap["tabName"] == ""){
tipHtm = "<div class=\"Design_Chart_Tip\">"+multiLJson['5202']+"</div>";//数据来源(输入名称)不能为空
$multiDChartContainer.html(tipHtm);
checkFlag = !checkFlag;
break;
}
if(sql == ""){
tipHtm = "<div class=\"Design_Chart_Tip\">"+multiLJson['4205']+"</div>";//图表信息设置不完整,未配置数据来源SQL
$multiDChartContainer.html(tipHtm);
checkFlag = !checkFlag;
break;
}else{
if($m_encrypt(sql) == ""){// 系统安全关键字验证不通过
tipHtm = "<div class=\"Design_Chart_Tip\">"+multiLJson['4207']+"</div>";//数据来源SQL未通过系统安全测试,请检查关键字
$multiDChartContainer.html(tipHtm);
checkFlag = !checkFlag;
break;
}
}
if(eval("/\\{(.*?)\\}/.test(sql)")){
tipHtm = "<div class=\"Design_Chart_Tip\">"+multiLJson['4206']+"</div>";//SQL中可能包含待解析的参数变量,需运行时显示
$multiDChartContainer.html(tipHtm);
checkFlag = !checkFlag;
break;
}
name += tabSourceMap["tabName"]+";";
datasource += tabSourceMap["datasource"]+";";
datasql += sql+";";
}
if(!checkFlag){
return;
}
if(name != ""){
name = name.substring(0,name.length-1);
}
if(datasource != ""){
datasource = datasource.substring(0,datasource.length-1);
}
if(datasql != ""){
datasql = datasql.substring(0,datasql.length-1);
}
requestParam["name"] = name;
requestParam["datasource"] = datasource;
url = jionActionUrl("com.weaver.formmodel.mobile.mec.servlet.MECAdminAction", "action=getMultiDDataBySQLWithChart&datasql="+$m_encrypt(datasql));
}else{
url = jionActionUrl("com.weaver.formmodel.mobile.mec.servlet.MECAction", "action=getDataForMultiChart&mec_id="+theId);
requestParam = Mobile_NS.pageParams;
}
}
$.get(url, requestParam, function(responseText){
var jObj = $.parseJSON(responseText);
var status = jObj["status"];
if(status == "0"){
var tipHtm = "<div class=\"Design_Chart_Tip\">"+multiLJson['4208']+"</div>";//查询数据来源SQL时出现错误,请检查SQL是否拼写正确
$multiDChartContainer.html(tipHtm);
}else if(status == "-1"){
var tipHtm = "<div class=\"Design_Chart_Tip\">"+multiLJson['4209']+"</div>";//加载图表时出现错误
$multiDChartContainer.html(tipHtm);
}else if(status == "1"){
var labels = jObj["labelName"];
var datas = jObj["datas"];
fn.call(this, labels, datas);
}
});
}
/**
* 当超过手机窗口的最大高度和宽度时,需要进行缩放
* @param {Object} width
* @param {Object} height
* @return {TypeName}
*/
Mobile_NS.MultiDChart.getMaxSize = function(width,height,type){
var maxWidth = $(window).width();
var maxHeight = $(window).height();
var w = 10;
if(type&&type==2){
maxWidth = $("#MEC_Design_Container").width();
maxHeight = $("#MEC_Design_Container").height();
}else{
w =20;
}
var f1 = false;
var f2 = false;
if(width<=0){
f1 = true;
}
if(height<=0){
f2 = true;
}
if(!width){
width = maxWidth;
}
if(!height){
height = maxHeight;
}
//按照宽度等比例缩放
if(width>maxWidth){
var p = maxWidth/width;
width = maxWidth;
height = height*p;
}
//按照高度进行等比例缩放
if(height>maxHeight){
var p = maxHeight/height;
height = maxHeight;
width = width*p;
}
if(f1){
width = maxWidth;
}
if(f2){
height = "";
}
var result = new Object();
result.width = width;
result.height = height;
return result;
}
function BuildChart_ColumnMulti3D(p){
BuildMultiChartWhenDataGet(p,function(labels, datas){
var theId = p["id"];
var chartWidth = p["width"] || _MEC_ChartWidth;
var chartHeight = p["height"];
if(typeof(chartHeight) == "undefined" || chartHeight == "" || parseFloat(chartHeight) <= 0){
chartHeight = 350;
}
var resetWidth = chartWidth+10;
var resetHeight = chartHeight-160;
var chart = new iChart.ColumnMulti3D({
render : 'multiDChartContainer_'+theId,
data: datas,
labels: labels,
title : {
text : p["title"],
font : p["title_font"],
color : p["title_color"],
fontsize: p["title_fontsize"],
fontweight : p["title_fontweight"]
},
width : chartWidth,
height : chartHeight,
background_color : null,
animation : true,//开启过渡动画
animation_duration:800,//800ms完成动画
align:'center',
turn_off_touchmove: true,
radius: '90%',
offsetx:10,
legend:{
enable:true,
background_color : null,
align : 'center',
valign : 'bottom',
legend_space:5,
row:1,
column:'max',
offsety:-20,
line_height:15,
padding:'0 0 0 0',
border : {
enable : false
}
},
column_width : 8,//柱形宽度
zScale:8,//z轴深度倍数
xAngle : 50,
bottom_scale:1.1,
label:{
color:'#4c4f48'
},
sub_option:{
label :false
},
tip:{
enable :true
},
text_space : 16,//坐标系下方的label距离坐标系的距离。
coordinate:{
background_color : '#d7d7d5',
grid_color : '#a4a4a2',
color_factor : 0.24,
board_deep:10,
offsety:-20,
pedestal_height:10,
left_board:false,//取消左侧面板
width:resetWidth,
height:resetHeight,
scale:[{
position:'left',
start_scale:0,
end_scale:1000,
scale_space:200,
scale_enable : false,
label:{
color:'#4c4f48'
}
}]
}
});
chart.draw();
});
}