Subversion Repositories php-qbpwcf

Rev

Rev 3 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3 Rev 226
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 
4
 
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
6
    Copyright (C) 2015~2025 Min-Jhin,Chen
6
    Copyright (C) 2014~2025 MIN ZHI, CHEN
7
 
7
 
8
    This file is part of QBPWCF.
8
    This file is part of QBPWCF.
9
 
9
 
10
    QBPWCF is free software: you can redistribute it and/or modify
10
    QBPWCF is free software: you can redistribute it and/or modify
11
    it under the terms of the GNU General Public License as published by
11
    it under the terms of the GNU General Public License as published by
Line 28... Line 28...
28
應用chartJS繪圖的類別.
28
應用chartJS繪圖的類別.
29
備註:
29
備註:
30
無.
30
無.
31
*/
31
*/
32
class chartJS{
32
class chartJS{
33
	
33
 
34
	/*
34
	/*
35
	#函式說明:
35
	#函式說明:
36
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
36
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
37
	#回傳結果:
37
	#回傳結果:
38
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
38
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 43... Line 43...
43
	#$arguments,陣列,為呼叫方法時所用的參數.
43
	#$arguments,陣列,為呼叫方法時所用的參數.
44
	#參考資料:
44
	#參考資料:
45
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
45
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
46
	*/
46
	*/
47
	public function __call($method,$arguments){
47
	public function __call($method,$arguments){
48
		
48
 
49
		#取得當前執行的函式
49
		#取得當前執行的函式
50
		$result["function"]=__FUNCTION__;
50
		$result["function"]=__FUNCTION__;
51
		
51
 
52
		#設置執行不正常
52
		#設置執行不正常
53
		$result["status"]="false";
53
		$result["status"]="false";
54
		
54
 
55
		#設置執行錯誤
55
		#設置執行錯誤
56
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
56
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
57
		
57
 
58
		#設置所丟入的參數
58
		#設置所丟入的參數
59
		$result["error"][]=$arguments;
59
		$result["error"][]=$arguments;
60
		
60
 
61
		#回傳結果
61
		#回傳結果
62
		return $result;
62
		return $result;
63
		
63
 
64
		}#function __call end
64
		}#function __call end
65
		
65
 
66
	/*
66
	/*
67
	#函式說明:
67
	#函式說明:
68
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
68
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
69
	#回傳結果:
69
	#回傳結果:
70
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
70
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 75... Line 75...
75
	#$arguments,陣列,為呼叫方法時所用的參數.
75
	#$arguments,陣列,為呼叫方法時所用的參數.
76
	#參考資料:
76
	#參考資料:
77
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
77
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
78
	*/
78
	*/
79
	public static function __callStatic($method,$arguments){
79
	public static function __callStatic($method,$arguments){
80
		
80
 
81
		#取得當前執行的函式
81
		#取得當前執行的函式
82
		$result["function"]=__FUNCTION__;
82
		$result["function"]=__FUNCTION__;
83
		
83
 
84
		#設置執行不正常
84
		#設置執行不正常
85
		$result["status"]="false";
85
		$result["status"]="false";
86
		
86
 
87
		#設置執行錯誤
87
		#設置執行錯誤
88
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
88
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
89
		
89
 
90
		#設置所丟入的參數
90
		#設置所丟入的參數
91
		$result["error"][]=$arguments;
91
		$result["error"][]=$arguments;
92
		
92
 
93
		#回傳結果
93
		#回傳結果
94
		return $result;
94
		return $result;
95
		
95
 
96
		}#function __callStatic end
96
		}#function __callStatic end
97
	
97
 
98
	/*
98
	/*
99
	#函式說明:
99
	#函式說明:
100
	#匯入chartJS的函式庫.
100
	#匯入chartJS的函式庫.
101
	#回傳結果:
101
	#回傳結果:
102
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
102
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 113... Line 113...
113
	#無.
113
	#無.
114
	#備註:
114
	#備註:
115
	#無.
115
	#無.
116
	*/
116
	*/
117
	public static function importLib(&$conf){
117
	public static function importLib(&$conf){
118
		
118
 
119
		#初始化要回傳的內容
119
		#初始化要回傳的內容
120
		$result=array();
120
		$result=array();
121
		
121
 
122
		#取得當前執行的函數名稱
122
		#取得當前執行的函數名稱
123
		$result["function"]=__FUNCTION__;
123
		$result["function"]=__FUNCTION__;
124
		
124
 
125
		#初始化要回傳的語法
125
		#初始化要回傳的語法
126
		$result["content"]="";
126
		$result["content"]="";
127
		
127
 
128
		#如果沒有參數
128
		#如果沒有參數
129
		if(func_num_args()==0){
129
		if(func_num_args()==0){
130
			
130
 
131
			#設置執行失敗
131
			#設置執行失敗
132
			$result["status"]="false";
132
			$result["status"]="false";
133
			
133
 
134
			#設置執行錯誤訊息
134
			#設置執行錯誤訊息
135
			$result["error"]="函數".$result["function"]."需要參數";
135
			$result["error"]="函數".$result["function"]."需要參數";
136
			
136
 
137
			#回傳結果
137
			#回傳結果
138
			return $result;
138
			return $result;
139
			
139
 
140
			}#if end
140
			}#if end
141
		
141
 
142
		#取得參數
142
		#取得參數
143
		$result["argu"]=$conf;
143
		$result["argu"]=$conf;
144
		
144
 
145
		#如果 $conf 不為陣列
145
		#如果 $conf 不為陣列
146
		if(gettype($conf)!="array"){
146
		if(gettype($conf)!="array"){
147
			
147
 
148
			#設置執行失敗
148
			#設置執行失敗
149
			$result["status"]="false";
149
			$result["status"]="false";
150
			
150
 
151
			#設置執行錯誤訊息
151
			#設置執行錯誤訊息
152
			$result["error"][]="\$conf變數須為陣列形態";
152
			$result["error"][]="\$conf變數須為陣列形態";
153
 
153
 
154
			#如果傳入的參數為 null
154
			#如果傳入的參數為 null
155
			if($conf==null){
155
			if($conf==null){
156
				
156
 
157
				#設置執行錯誤訊息
157
				#設置執行錯誤訊息
158
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
158
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
159
				
159
 
160
				}#if end
160
				}#if end
161
 
161
 
162
			#回傳結果
162
			#回傳結果
163
			return $result;
163
			return $result;
164
			
164
 
165
			}#if end
165
			}#if end
166
			
166
 
167
		#檢查參數
167
		#檢查參數
168
		#函式說明:
168
		#函式說明:
169
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
169
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
170
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
170
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
171
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
171
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 177... Line 177...
177
		#必填寫的參數:
177
		#必填寫的參數:
178
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
178
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
179
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
179
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
180
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
180
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
181
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("libAddr");
181
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("libAddr");
182
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
182
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
183
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
183
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
184
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
184
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
185
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
185
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
186
		#可以省略的參數:
186
		#可以省略的參數:
187
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
187
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
188
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
188
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
189
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
189
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
190
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu");
190
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu");
191
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
191
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
192
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
192
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
193
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
193
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
194
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__);
194
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__);
195
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
195
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
196
		#$conf["arrayCountEqualCheck"][]=array();
196
		#$conf["arrayCountEqualCheck"][]=array();
197
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
197
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
198
		unset($conf["variableCheck::checkArguments"]);
198
		unset($conf["variableCheck::checkArguments"]);
199
		
199
 
200
		#如果檢查參數失敗
200
		#如果檢查參數失敗
201
		if($checkResult["status"]=="false"){
201
		if($checkResult["status"]=="false"){
202
			
202
 
203
			#設置執行失敗
203
			#設置執行失敗
204
			$result["status"]="false";
204
			$result["status"]="false";
205
			
205
 
206
			#設置錯誤訊息
206
			#設置錯誤訊息
207
			$result["error"]=$checkResult;
207
			$result["error"]=$checkResult;
208
			
208
 
209
			#回傳結果
209
			#回傳結果
210
			return $result;
210
			return $result;
211
			
211
 
212
			}#if end
212
			}#if end
213
			
213
 
214
		#如果檢查參數不通過
214
		#如果檢查參數不通過
215
		if($checkResult["passed"]=="false"){
215
		if($checkResult["passed"]=="false"){
216
			
216
 
217
			#設置執行失敗
217
			#設置執行失敗
218
			$result["status"]="false";
218
			$result["status"]="false";
219
			
219
 
220
			#設置錯誤訊息
220
			#設置錯誤訊息
221
			$result["error"]=$checkResult;
221
			$result["error"]=$checkResult;
222
			
222
 
223
			#回傳結果
223
			#回傳結果
224
			return $result;
224
			return $result;
225
			
225
 
226
			}#if end
226
			}#if end
227
						
227
 
228
		#匯入 $conf["libAddr"] js檔案  
228
		#匯入 $conf["libAddr"] js檔案
229
		#函式說明:
229
		#函式說明:
230
		#匯入js檔案 
230
		#匯入js檔案
231
		#回傳結果:
231
		#回傳結果:
232
		#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
232
		#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
233
		#$result["functin"],字串,當前函數的名稱.
233
		#$result["functin"],字串,當前函數的名稱.
234
		#$result["error"],陣列,錯訊訊息.
234
		#$result["error"],陣列,錯訊訊息.
235
		#$result["content"],字串,匯入css樣式的語法.
235
		#$result["content"],字串,匯入css樣式的語法.
Line 243... Line 243...
243
		#$conf["userDir"]="true";
243
		#$conf["userDir"]="true";
244
		#參考資料:
244
		#參考資料:
245
		#php於設常數=>http://php.net/manual/zh/language.constants.predefined.php
245
		#php於設常數=>http://php.net/manual/zh/language.constants.predefined.php
246
		$import=javaScript::import($conf["javaScript::import"]);
246
		$import=javaScript::import($conf["javaScript::import"]);
247
		unset($conf["javaScript::import"]);
247
		unset($conf["javaScript::import"]);
248
		
248
 
249
		#var_dump($import);
249
		#var_dump($import);
250
		
250
 
251
		#如果建立匯入js檔案的語法失敗
251
		#如果建立匯入js檔案的語法失敗
252
		if($import["status"]=="false"){
252
		if($import["status"]=="false"){
253
			
253
 
254
			#設置執行失敗
254
			#設置執行失敗
255
			$result["status"]="false";
255
			$result["status"]="false";
256
			
256
 
257
			#設置錯誤訊息
257
			#設置錯誤訊息
258
			$result["error"]=$import;
258
			$result["error"]=$import;
259
			
259
 
260
			#回傳結果
260
			#回傳結果
261
			return $result;
261
			return $result;
262
			
262
 
263
			}#if end
263
			}#if end
264
			
264
 
265
		#取得js語法
265
		#取得js語法
266
		$result["content"]=$import["content"];
266
		$result["content"]=$import["content"];
267
			
267
 
268
		#設置執行正常
268
		#設置執行正常
269
		$result["status"]="true";
269
		$result["status"]="true";
270
		
270
 
271
		#回傳結果
271
		#回傳結果
272
		return $result;
272
		return $result;
273
		
273
 
274
		}#function importLib end
274
		}#function importLib end
275
	
275
 
276
	/*
276
	/*
277
	#函式說明:
277
	#函式說明:
278
	#顯示長條圖的demo.
278
	#顯示長條圖的demo.
279
	#回傳結果:
279
	#回傳結果:
280
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
280
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 291... Line 291...
291
	#Creating a Chart=>http://www.chartjs.org/docs/latest/
291
	#Creating a Chart=>http://www.chartjs.org/docs/latest/
292
	#備註:
292
	#備註:
293
	#無.
293
	#無.
294
	*/
294
	*/
295
	public static function barDemo(&$conf=array()){
295
	public static function barDemo(&$conf=array()){
296
		
296
 
297
		#初始化要回傳的內容
297
		#初始化要回傳的內容
298
		$result=array();
298
		$result=array();
299
		
299
 
300
		#取得當前執行的函數名稱
300
		#取得當前執行的函數名稱
301
		$result["function"]=__FUNCTION__;
301
		$result["function"]=__FUNCTION__;
302
		
302
 
303
		#初始化要回傳的語法
303
		#初始化要回傳的語法
304
		$result["content"]="";
304
		$result["content"]="";
305
		
305
 
306
		#如果沒有參數
306
		#如果沒有參數
307
		if(func_num_args()==0){
307
		if(func_num_args()==0){
308
			
308
 
309
			#設置執行失敗
309
			#設置執行失敗
310
			$result["status"]="false";
310
			$result["status"]="false";
311
			
311
 
312
			#設置執行錯誤訊息
312
			#設置執行錯誤訊息
313
			$result["error"]="函數".$result["function"]."需要參數";
313
			$result["error"]="函數".$result["function"]."需要參數";
314
			
314
 
315
			#回傳結果
315
			#回傳結果
316
			return $result;
316
			return $result;
317
			
317
 
318
			}#if end
318
			}#if end
319
		
319
 
320
		#取得參數
320
		#取得參數
321
		$result["argu"]=$conf;
321
		$result["argu"]=$conf;
322
		
322
 
323
		#如果 $conf 不為陣列
323
		#如果 $conf 不為陣列
324
		if(gettype($conf)!="array"){
324
		if(gettype($conf)!="array"){
325
			
325
 
326
			#設置執行失敗
326
			#設置執行失敗
327
			$result["status"]="false";
327
			$result["status"]="false";
328
			
328
 
329
			#設置執行錯誤訊息
329
			#設置執行錯誤訊息
330
			$result["error"][]="\$conf變數須為陣列形態";
330
			$result["error"][]="\$conf變數須為陣列形態";
331
 
331
 
332
			#如果傳入的參數為 null
332
			#如果傳入的參數為 null
333
			if($conf==null){
333
			if($conf==null){
334
				
334
 
335
				#設置執行錯誤訊息
335
				#設置執行錯誤訊息
336
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
336
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
337
				
337
 
338
				}#if end
338
				}#if end
339
 
339
 
340
			#回傳結果
340
			#回傳結果
341
			return $result;
341
			return $result;
342
			
342
 
343
			}#if end
343
			}#if end
344
			
344
 
345
		#檢查參數
345
		#檢查參數
346
		#函式說明:
346
		#函式說明:
347
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
347
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
348
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
348
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
349
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
349
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 355... Line 355...
355
		#必填寫的參數:
355
		#必填寫的參數:
356
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
356
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
357
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
357
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
358
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
358
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
359
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("libAddr");
359
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("libAddr");
360
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
360
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
361
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
361
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
362
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
362
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
363
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
363
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
364
		#可以省略的參數:
364
		#可以省略的參數:
365
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
365
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
366
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
366
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
367
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
367
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
368
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu");
368
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu");
369
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
369
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
370
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
370
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
371
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
371
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
372
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__);
372
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__);
373
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
373
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
374
		#$conf["arrayCountEqualCheck"][]=array();
374
		#$conf["arrayCountEqualCheck"][]=array();
375
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
375
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
376
		unset($conf["variableCheck::checkArguments"]);
376
		unset($conf["variableCheck::checkArguments"]);
377
		
377
 
378
		#如果檢查參數失敗
378
		#如果檢查參數失敗
379
		if($checkResult["status"]=="false"){
379
		if($checkResult["status"]=="false"){
380
			
380
 
381
			#設置執行失敗
381
			#設置執行失敗
382
			$result["status"]="false";
382
			$result["status"]="false";
383
			
383
 
384
			#設置錯誤訊息
384
			#設置錯誤訊息
385
			$result["error"]=$checkResult;
385
			$result["error"]=$checkResult;
386
			
386
 
387
			#回傳結果
387
			#回傳結果
388
			return $result;
388
			return $result;
389
			
389
 
390
			}#if end
390
			}#if end
391
			
391
 
392
		#如果檢查參數不通過
392
		#如果檢查參數不通過
393
		if($checkResult["passed"]=="false"){
393
		if($checkResult["passed"]=="false"){
394
			
394
 
395
			#設置執行失敗
395
			#設置執行失敗
396
			$result["status"]="false";
396
			$result["status"]="false";
397
			
397
 
398
			#設置錯誤訊息
398
			#設置錯誤訊息
399
			$result["error"]=$checkResult;
399
			$result["error"]=$checkResult;
400
			
400
 
401
			#回傳結果
401
			#回傳結果
402
			return $result;
402
			return $result;
403
			
403
 
404
			}#if end
404
			}#if end
405
		
405
 
406
		#demo用的目標
406
		#demo用的目標
407
		$demoTarget="<canvas id=\"myChart\" width=\"400\" height=\"400\"></canvas>";
407
		$demoTarget="<canvas id=\"myChart\" width=\"400\" height=\"400\"></canvas>";
408
							
408
 
409
		#函式說明:
409
		#函式說明:
410
		#匯入chartJS的函式庫.
410
		#匯入chartJS的函式庫.
411
		#回傳結果:
411
		#回傳結果:
412
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
412
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
413
		#$result["error"],錯誤訊息.
413
		#$result["error"],錯誤訊息.
Line 419... Line 419...
419
		#可省略參數:
419
		#可省略參數:
420
		#$conf["fileArgu"],字串,為當前檔案的路徑,預設為__FILE__.
420
		#$conf["fileArgu"],字串,為當前檔案的路徑,預設為__FILE__.
421
		$conf["chartJS::importLib"]["fileArgu"]=$conf["fileArgu"];
421
		$conf["chartJS::importLib"]["fileArgu"]=$conf["fileArgu"];
422
		$importLib=chartJS::importLib($conf["chartJS::importLib"]);
422
		$importLib=chartJS::importLib($conf["chartJS::importLib"]);
423
		unset($conf["chartJS::importLib"]);
423
		unset($conf["chartJS::importLib"]);
424
		
424
 
425
		#如果建立匯入 chart js lib 的語法失敗
425
		#如果建立匯入 chart js lib 的語法失敗
426
		if($importLib["status"]=="false"){
426
		if($importLib["status"]=="false"){
427
			
427
 
428
			#設置執行失敗
428
			#設置執行失敗
429
			$result["status"]="false";
429
			$result["status"]="false";
430
			
430
 
431
			#設置錯誤訊息
431
			#設置錯誤訊息
432
			$result["error"]=$importLib;
432
			$result["error"]=$importLib;
433
			
433
 
434
			#回傳結果
434
			#回傳結果
435
			return $result;
435
			return $result;
436
			
436
 
437
			}#if end
437
			}#if end
438
			
438
 
439
		#取得匯入chart js的語法
439
		#取得匯入chart js的語法
440
		$result["content"]=$result["content"].$importLib["content"];
440
		$result["content"]=$result["content"].$importLib["content"];
441
		
441
 
442
		#涵式說明:
442
		#涵式說明:
443
		#將要執行的script語法透過該函式執行
443
		#將要執行的script語法透過該函式執行
444
		#回傳結果:
444
		#回傳結果:
445
		#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
445
		#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
446
		#$result["error"],錯誤訊息陣列
446
		#$result["error"],錯誤訊息陣列
Line 448... Line 448...
448
		#$result["content"],要執行的javaScript語法
448
		#$result["content"],要執行的javaScript語法
449
		#必填的參數:
449
		#必填的參數:
450
		#$conf["script"],字串,要執行的javaScript語法,標籤「<script></script>」會自動補上.
450
		#$conf["script"],字串,要執行的javaScript語法,標籤「<script></script>」會自動補上.
451
		$conf["javaScript::toScript"]["script"]="
451
		$conf["javaScript::toScript"]["script"]="
452
			var ctx = document.getElementById(\"myChart\").getContext('2d');
452
			var ctx = document.getElementById(\"myChart\").getContext('2d');
453
			var myChart = new Chart(ctx, 
453
			var myChart = new Chart(ctx,
454
			{
454
			{
455
				type: 'bar',
455
				type: 'bar',
456
				data: {
456
				data: {
457
					labels: [\"Red\", \"Blue\", \"Yellow\", \"Green\", \"Purple\", \"Orange\"],
457
					labels: [\"Red\", \"Blue\", \"Yellow\", \"Green\", \"Purple\", \"Orange\"],
458
					datasets: [{
458
					datasets: [{
Line 488... Line 488...
488
				}
488
				}
489
			});
489
			});
490
			";
490
			";
491
		$toScript=javaScript::toScript($conf["javaScript::toScript"]);
491
		$toScript=javaScript::toScript($conf["javaScript::toScript"]);
492
		unset($conf["javaScript::toScript"]);
492
		unset($conf["javaScript::toScript"]);
493
		
493
 
494
		#如果轉換成js語法失敗
494
		#如果轉換成js語法失敗
495
		if($toScript["status"]=="false"){
495
		if($toScript["status"]=="false"){
496
			
496
 
497
			#設置執行失敗
497
			#設置執行失敗
498
			$result["status"]="false";
498
			$result["status"]="false";
499
			
499
 
500
			#設置錯誤訊息
500
			#設置錯誤訊息
501
			$result["error"]=$toScript;
501
			$result["error"]=$toScript;
502
			
502
 
503
			#回傳結果
503
			#回傳結果
504
			return $result;
504
			return $result;
505
			
505
 
506
			}#if end
506
			}#if end
507
			
507
 
508
		#取得使用chart js的語法
508
		#取得使用chart js的語法
509
		$result["content"]=$result["content"].$demoTarget.$toScript["content"];
509
		$result["content"]=$result["content"].$demoTarget.$toScript["content"];
510
		
510
 
511
		#設置執行正常
511
		#設置執行正常
512
		$result["status"]="true";
512
		$result["status"]="true";
513
		
513
 
514
		#回傳結果
514
		#回傳結果
515
		return $result;
515
		return $result;
516
		
516
 
517
		}#function barDemo end
517
		}#function barDemo end
518
		
518
 
519
	/*
519
	/*
520
	#函式說明:
520
	#函式說明:
521
	#將數據用長條圖表示.
521
	#將數據用長條圖表示.
522
	#回傳結果:
522
	#回傳結果:
523
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
523
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 526... Line 526...
526
	#$result["function"],當前執行的函數名稱.
526
	#$result["function"],當前執行的函數名稱.
527
	#必填參數:
527
	#必填參數:
528
	#$conf["libAddr"],字串,爲chartJS的位置,js附檔名會自動補上.
528
	#$conf["libAddr"],字串,爲chartJS的位置,js附檔名會自動補上.
529
	$conf["libAddr"]="";
529
	$conf["libAddr"]="";
530
	#$conf["data"],字串,要繪製的數據,例如:"2017/07/09 508.25 2017/07/16 1365 2017/07/23 949 2017/07/30 455 2017/08/06 917 2017/08/13 0".
530
	#$conf["data"],字串,要繪製的數據,例如:"2017/07/09 508.25 2017/07/16 1365 2017/07/23 949 2017/07/30 455 2017/08/06 917 2017/08/13 0".
531
	$conf["data"]="";	
531
	$conf["data"]="";
532
	#$conf["canvasId"],字串,為要繪製圖表到哪個canvas元素的id.
532
	#$conf["canvasId"],字串,為要繪製圖表到哪個canvas元素的id.
533
	$conf["canvasId"]="";
533
	$conf["canvasId"]="";
534
	#$conf["title"],字串,圖表的標題.
534
	#$conf["title"],字串,圖表的標題.
535
	$conf["title"]="";
535
	$conf["title"]="";
536
	#conf["yTitle"],字串,y軸標題.
536
	#conf["yTitle"],字串,y軸標題.
Line 550... Line 550...
550
	#Creating a Chart=>http://www.chartjs.org/docs/latest/
550
	#Creating a Chart=>http://www.chartjs.org/docs/latest/
551
	#備註:
551
	#備註:
552
	#無.
552
	#無.
553
	*/
553
	*/
554
	public static function bar(&$conf=array()){
554
	public static function bar(&$conf=array()){
555
		
555
 
556
		#初始化要回傳的內容
556
		#初始化要回傳的內容
557
		$result=array();
557
		$result=array();
558
		
558
 
559
		#取得當前執行的函數名稱
559
		#取得當前執行的函數名稱
560
		$result["function"]=__FUNCTION__;
560
		$result["function"]=__FUNCTION__;
561
		
561
 
562
		#初始化要回傳的語法
562
		#初始化要回傳的語法
563
		$result["content"]="";
563
		$result["content"]="";
564
		
564
 
565
		#如果沒有參數
565
		#如果沒有參數
566
		if(func_num_args()==0){
566
		if(func_num_args()==0){
567
			
567
 
568
			#設置執行失敗
568
			#設置執行失敗
569
			$result["status"]="false";
569
			$result["status"]="false";
570
			
570
 
571
			#設置執行錯誤訊息
571
			#設置執行錯誤訊息
572
			$result["error"]="函數".$result["function"]."需要參數";
572
			$result["error"]="函數".$result["function"]."需要參數";
573
			
573
 
574
			#回傳結果
574
			#回傳結果
575
			return $result;
575
			return $result;
576
			
576
 
577
			}#if end
577
			}#if end
578
		
578
 
579
		#取得參數
579
		#取得參數
580
		$result["argu"]=$conf;
580
		$result["argu"]=$conf;
581
		
581
 
582
		#如果 $conf 不為陣列
582
		#如果 $conf 不為陣列
583
		if(gettype($conf)!="array"){
583
		if(gettype($conf)!="array"){
584
			
584
 
585
			#設置執行失敗
585
			#設置執行失敗
586
			$result["status"]="false";
586
			$result["status"]="false";
587
			
587
 
588
			#設置執行錯誤訊息
588
			#設置執行錯誤訊息
589
			$result["error"][]="\$conf變數須為陣列形態";
589
			$result["error"][]="\$conf變數須為陣列形態";
590
 
590
 
591
			#如果傳入的參數為 null
591
			#如果傳入的參數為 null
592
			if($conf==null){
592
			if($conf==null){
593
				
593
 
594
				#設置執行錯誤訊息
594
				#設置執行錯誤訊息
595
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
595
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
596
				
596
 
597
				}#if end
597
				}#if end
598
 
598
 
599
			#回傳結果
599
			#回傳結果
600
			return $result;
600
			return $result;
601
			
601
 
602
			}#if end
602
			}#if end
603
			
603
 
604
		#檢查參數
604
		#檢查參數
605
		#函式說明:
605
		#函式說明:
606
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
606
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
607
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
607
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
608
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
608
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 614... Line 614...
614
		#必填寫的參數:
614
		#必填寫的參數:
615
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
615
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
616
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
616
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
617
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
617
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
618
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("libAddr","data","canvasId","title","xTitle","yTitle");
618
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("libAddr","data","canvasId","title","xTitle","yTitle");
619
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
619
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
620
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string","string","string","string",);
620
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string","string","string","string",);
621
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
621
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
622
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
622
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
623
		#可以省略的參數:
623
		#可以省略的參數:
624
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
624
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
625
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
625
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
626
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
626
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
627
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu","dataUnit","xTcolor","yTcolor");
627
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu","dataUnit","xTcolor","yTcolor");
628
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
628
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
629
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string");
629
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string");
630
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
630
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
631
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__,"number","0,0,255,0.8","0,0,255,0.8");
631
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__,"number","0,0,255,0.8","0,0,255,0.8");
632
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
632
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
633
		#$conf["arrayCountEqualCheck"][]=array();
633
		#$conf["arrayCountEqualCheck"][]=array();
634
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
634
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
635
		unset($conf["variableCheck::checkArguments"]);
635
		unset($conf["variableCheck::checkArguments"]);
636
		
636
 
637
		#如果檢查參數失敗
637
		#如果檢查參數失敗
638
		if($checkResult["status"]=="false"){
638
		if($checkResult["status"]=="false"){
639
			
639
 
640
			#設置執行失敗
640
			#設置執行失敗
641
			$result["status"]="false";
641
			$result["status"]="false";
642
			
642
 
643
			#設置錯誤訊息
643
			#設置錯誤訊息
644
			$result["error"]=$checkResult;
644
			$result["error"]=$checkResult;
645
			
645
 
646
			#回傳結果
646
			#回傳結果
647
			return $result;
647
			return $result;
648
			
648
 
649
			}#if end
649
			}#if end
650
			
650
 
651
		#如果檢查參數不通過
651
		#如果檢查參數不通過
652
		if($checkResult["passed"]=="false"){
652
		if($checkResult["passed"]=="false"){
653
			
653
 
654
			#設置執行失敗
654
			#設置執行失敗
655
			$result["status"]="false";
655
			$result["status"]="false";
656
			
656
 
657
			#設置錯誤訊息
657
			#設置錯誤訊息
658
			$result["error"]=$checkResult;
658
			$result["error"]=$checkResult;
659
			
659
 
660
			#回傳結果
660
			#回傳結果
661
			return $result;
661
			return $result;
662
			
662
 
663
			}#if end
663
			}#if end
664
									
664
 
665
		#函式說明:
665
		#函式說明:
666
		#匯入chartJS的函式庫.
666
		#匯入chartJS的函式庫.
667
		#回傳結果:
667
		#回傳結果:
668
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
668
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
669
		#$result["error"],錯誤訊息.
669
		#$result["error"],錯誤訊息.
Line 675... Line 675...
675
		#可省略參數:
675
		#可省略參數:
676
		#$conf["fileArgu"],字串,為當前檔案的路徑,預設為__FILE__.
676
		#$conf["fileArgu"],字串,為當前檔案的路徑,預設為__FILE__.
677
		$conf["chartJS::importLib"]["fileArgu"]=$conf["fileArgu"];
677
		$conf["chartJS::importLib"]["fileArgu"]=$conf["fileArgu"];
678
		$importLib=chartJS::importLib($conf["chartJS::importLib"]);
678
		$importLib=chartJS::importLib($conf["chartJS::importLib"]);
679
		unset($conf["chartJS::importLib"]);
679
		unset($conf["chartJS::importLib"]);
680
		
680
 
681
		#如果建立匯入 chart js lib 的語法失敗
681
		#如果建立匯入 chart js lib 的語法失敗
682
		if($importLib["status"]=="false"){
682
		if($importLib["status"]=="false"){
683
			
683
 
684
			#設置執行失敗
684
			#設置執行失敗
685
			$result["status"]="false";
685
			$result["status"]="false";
686
			
686
 
687
			#設置錯誤訊息
687
			#設置錯誤訊息
688
			$result["error"]=$importLib;
688
			$result["error"]=$importLib;
689
			
689
 
690
			#回傳結果
690
			#回傳結果
691
			return $result;
691
			return $result;
692
			
692
 
693
			}#if end
693
			}#if end
694
			
694
 
695
		#取得匯入chart js的語法
695
		#取得匯入chart js的語法
696
		$result["content"]=$result["content"].$importLib["content"];
696
		$result["content"]=$result["content"].$importLib["content"];
697
				
697
 
698
		#用空格分割
698
		#用空格分割
699
		$dataSet=explode(' ',$conf["data"]);
699
		$dataSet=explode(' ',$conf["data"]);
700
		
700
 
701
		#初始化儲存x軸標題的陣列
701
		#初始化儲存x軸標題的陣列
702
		$lables=array();
702
		$lables=array();
703
		
703
 
704
		#初始化儲存y軸數據的陣列
704
		#初始化儲存y軸數據的陣列
705
		$values=array();
705
		$values=array();
706
		
706
 
707
		#兩兩一對
707
		#兩兩一對
708
		for($i=0;$i<count($dataSet);$i=$i+2){
708
		for($i=0;$i<count($dataSet);$i=$i+2){
709
			
709
 
710
			#取得x軸項目
710
			#取得x軸項目
711
			$lables[]=$dataSet[$i];
711
			$lables[]=$dataSet[$i];
712
			
712
 
713
			#取得y軸項目
713
			#取得y軸項目
714
			$values[]=$dataSet[$i+1];
714
			$values[]=$dataSet[$i+1];
715
			
715
 
716
			}#for end		
716
			}#for end
717
		
717
 
718
		#涵式說明:
718
		#涵式說明:
719
		#將要執行的script語法透過該函式執行
719
		#將要執行的script語法透過該函式執行
720
		#回傳結果:
720
		#回傳結果:
721
		#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
721
		#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
722
		#$result["error"],錯誤訊息陣列
722
		#$result["error"],錯誤訊息陣列
Line 724... Line 724...
724
		#$result["content"],要執行的javaScript語法
724
		#$result["content"],要執行的javaScript語法
725
		#必填的參數:
725
		#必填的參數:
726
		#$conf["script"],字串,要執行的javaScript語法,標籤「<script></script>」會自動補上.
726
		#$conf["script"],字串,要執行的javaScript語法,標籤「<script></script>」會自動補上.
727
		$conf["javaScript::toScript"]["script"]="
727
		$conf["javaScript::toScript"]["script"]="
728
			var ctx = document.getElementById(\"".$conf["canvasId"]."\").getContext('2d');
728
			var ctx = document.getElementById(\"".$conf["canvasId"]."\").getContext('2d');
729
			var myChart = new Chart(ctx, 
729
			var myChart = new Chart(ctx,
730
			{
730
			{
731
				type: 'bar',
731
				type: 'bar',
732
				data: {
732
				data: {
733
					labels: ".json_encode($lables).",
733
					labels: ".json_encode($lables).",
734
					datasets: [{
734
					datasets: [{
Line 751... Line 751...
751
							'rgba(255, 159, 64, 1)'
751
							'rgba(255, 159, 64, 1)'
752
						],
752
						],
753
						borderWidth: 1
753
						borderWidth: 1
754
					}]
754
					}]
755
				},
755
				},
756
				options: 
756
				options:
757
				{
757
				{
758
					scales: 
758
					scales:
759
					{
759
					{
760
						yAxes: 
760
						yAxes:
761
						[{
761
						[{
762
							ticks: 
762
							ticks:
763
							{
763
							{
764
								beginAtZero:true
764
								beginAtZero:true
765
							},	
765
							},
766
							scaleLabel: 
766
							scaleLabel:
767
							{
767
							{
768
								display: true,
768
								display: true,
769
								labelString: '".$conf["yTitle"]."',
769
								labelString: '".$conf["yTitle"]."',
770
								fontColor:'rgba(".$conf["yTcolor"].")',
770
								fontColor:'rgba(".$conf["yTcolor"].")',
771
							}						
771
							}
772
						}],
772
						}],
773
						xAxes: 
773
						xAxes:
774
						[{
774
						[{
775
							scaleLabel: 
775
							scaleLabel:
776
							{
776
							{
777
								display: true,
777
								display: true,
778
								labelString: '".$conf["xTitle"]."',
778
								labelString: '".$conf["xTitle"]."',
779
								fontColor:'rgba(".$conf["yTcolor"].")',
779
								fontColor:'rgba(".$conf["yTcolor"].")',
780
							}						
780
							}
781
						}]
781
						}]
782
					},
782
					},
783
					title: 
783
					title:
784
					{
784
					{
785
						display: true,
785
						display: true,
786
						text: '".$conf["title"]."'
786
						text: '".$conf["title"]."'
787
					},
787
					},
788
					legend: 
788
					legend:
789
					{
789
					{
790
						//disable class label
790
						//disable class label
791
						display: false
791
						display: false
792
					},
792
					},
793
				}
793
				}
794
			});
794
			});
795
			";					
795
			";
796
		$toScript=javaScript::toScript($conf["javaScript::toScript"]);
796
		$toScript=javaScript::toScript($conf["javaScript::toScript"]);
797
		unset($conf["javaScript::toScript"]);
797
		unset($conf["javaScript::toScript"]);
798
		
798
 
799
		#如果轉換成js語法失敗
799
		#如果轉換成js語法失敗
800
		if($toScript["status"]=="false"){
800
		if($toScript["status"]=="false"){
801
			
801
 
802
			#設置執行失敗
802
			#設置執行失敗
803
			$result["status"]="false";
803
			$result["status"]="false";
804
			
804
 
805
			#設置錯誤訊息
805
			#設置錯誤訊息
806
			$result["error"]=$toScript;
806
			$result["error"]=$toScript;
807
			
807
 
808
			#回傳結果
808
			#回傳結果
809
			return $result;
809
			return $result;
810
			
810
 
811
			}#if end
811
			}#if end
812
			
812
 
813
		#取得使用chart js的語法
813
		#取得使用chart js的語法
814
		$result["content"]=$result["content"].$toScript["content"];
814
		$result["content"]=$result["content"].$toScript["content"];
815
		
815
 
816
		#設置執行正常
816
		#設置執行正常
817
		$result["status"]="true";
817
		$result["status"]="true";
818
		
818
 
819
		#回傳結果
819
		#回傳結果
820
		return $result;
820
		return $result;
821
		
821
 
822
		}#function barDemo end
822
		}#function barDemo end
823
			
823
 
824
	}#class chartJS end
824
	}#class chartJS end
825
 
825
 
826
?>
826
?>