Subversion Repositories php-qbpwcf

Rev

Rev 226 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

/*

        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
    Copyright (C) 2014~2026 MIN ZHI, CHEN

    This file is part of QBPWCF.

    QBPWCF is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    QBPWCF is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.

*/
namespace qbpwcf;

/*
類別說明:
應用chartJS繪圖的類別.
備註:
無.
*/
class chartJS{

        /*
        #函式說明:
        #當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$reuslt["error"],執行不正常結束的錯訊息陣列.
        #$result["function"],當前執行的函式名稱.
        #必填參數:
        #$method,物件,為物件實體或類別名稱,會自動置入該參數.
        #$arguments,陣列,為呼叫方法時所用的參數.
        #參考資料:
        #__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
        */
        public function __call($method,$arguments){

                #取得當前執行的函式
                $result["function"]=__FUNCTION__;

                #設置執行不正常
                $result["status"]="false";

                #設置執行錯誤
                $result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";

                #設置所丟入的參數
                $result["error"][]=$arguments;

                #回傳結果
                return $result;

                }#function __call end

        /*
        #函式說明:
        #當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$reuslt["error"],執行不正常結束的錯訊息陣列.
        #$result["function"],當前執行的函式名稱.
        #必填參數:
        #$method,物件,為物件實體或類別名稱,會自動置入該參數.
        #$arguments,陣列,為呼叫方法時所用的參數.
        #參考資料:
        #__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
        */
        public static function __callStatic($method,$arguments){

                #取得當前執行的函式
                $result["function"]=__FUNCTION__;

                #設置執行不正常
                $result["status"]="false";

                #設置執行錯誤
                $result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";

                #設置所丟入的參數
                $result["error"][]=$arguments;

                #回傳結果
                return $result;

                }#function __callStatic end

        /*
        #函式說明:
        #匯入chartJS的函式庫.
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$result["error"],錯誤訊息.
        #$result["content"],語法.
        #$result["function"],當前執行的函數名稱.
        #必填參數:
        #$conf["libAddr"],字串,爲ckfEditor套件的網路位置,js附檔名會自動補上.
        $conf["libAddr"]="";
        #可省略參數:
        #$conf["fileArgu"],字串,為當前檔案的路徑,預設為__FILE__.
        #$conf["fileArgu"]=__FILE__;
        #參考資料:
        #無.
        #備註:
        #無.
        */
        public static function importLib(&$conf){

                #初始化要回傳的內容
                $result=array();

                #取得當前執行的函數名稱
                $result["function"]=__FUNCTION__;

                #初始化要回傳的語法
                $result["content"]="";

                #如果沒有參數
                if(func_num_args()==0){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置執行錯誤訊息
                        $result["error"]="函數".$result["function"]."需要參數";

                        #回傳結果
                        return $result;

                        }#if end

                #取得參數
                $result["argu"]=$conf;

                #如果 $conf 不為陣列
                if(gettype($conf)!="array"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置執行錯誤訊息
                        $result["error"][]="\$conf變數須為陣列形態";

                        #如果傳入的參數為 null
                        if($conf==null){

                                #設置執行錯誤訊息
                                $result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";

                                }#if end

                        #回傳結果
                        return $result;

                        }#if end

                #檢查參數
                #函式說明:
                #檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
                #$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
                #必填寫的參數:
                #$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("libAddr");
                #$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
                #$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
                $conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
                #$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu");
                #$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
                #$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__);
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                #$conf["arrayCountEqualCheck"][]=array();
                $checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);

                #如果檢查參數失敗
                if($checkResult["status"]=="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置錯誤訊息
                        $result["error"]=$checkResult;

                        #回傳結果
                        return $result;

                        }#if end

                #如果檢查參數不通過
                if($checkResult["passed"]=="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置錯誤訊息
                        $result["error"]=$checkResult;

                        #回傳結果
                        return $result;

                        }#if end

                #匯入 $conf["libAddr"] js檔案
                #函式說明:
                #匯入js檔案
                #回傳結果:
                #$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
                #$result["functin"],字串,當前函數的名稱.
                #$result["error"],陣列,錯訊訊息.
                #$result["content"],字串,匯入css樣式的語法.
                #必填參數:
                #$conf["jsFileLocation"],陣列字串,多個js檔案的位置與名稱,每個元素代表一個js檔案的位置,js副檔名會自動補上.
                $conf["javaScript::import"]["jsFileLocation"]=array($conf["libAddr"]);
                #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
                $conf["javaScript::import"]["fileArgu"]=$conf["fileArgu"];
                #可省略參數:
                #$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,於設為"true".
                #$conf["userDir"]="true";
                #參考資料:
                #php於設常數=>http://php.net/manual/zh/language.constants.predefined.php
                $import=javaScript::import($conf["javaScript::import"]);
                unset($conf["javaScript::import"]);

                #var_dump($import);

                #如果建立匯入js檔案的語法失敗
                if($import["status"]=="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置錯誤訊息
                        $result["error"]=$import;

                        #回傳結果
                        return $result;

                        }#if end

                #取得js語法
                $result["content"]=$import["content"];

                #設置執行正常
                $result["status"]="true";

                #回傳結果
                return $result;

                }#function importLib end

        /*
        #函式說明:
        #顯示長條圖的demo.
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$result["error"],錯誤訊息.
        #$result["content"],語法.
        #$result["function"],當前執行的函數名稱.
        #必填參數:
        #$conf["libAddr"],字串,爲ckfEditor套件的網路位置,js附檔名會自動補上.
        $conf["libAddr"]="";
        #可省略參數:
        #$conf["fileArgu"],字串,為當前檔案的路徑,預設為__FILE__.
        #$conf["fileArgu"]=__FILE__;
        #參考資料:
        #Creating a Chart=>http://www.chartjs.org/docs/latest/
        #備註:
        #無.
        */
        public static function barDemo(&$conf=array()){

                #初始化要回傳的內容
                $result=array();

                #取得當前執行的函數名稱
                $result["function"]=__FUNCTION__;

                #初始化要回傳的語法
                $result["content"]="";

                #如果沒有參數
                if(func_num_args()==0){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置執行錯誤訊息
                        $result["error"]="函數".$result["function"]."需要參數";

                        #回傳結果
                        return $result;

                        }#if end

                #取得參數
                $result["argu"]=$conf;

                #如果 $conf 不為陣列
                if(gettype($conf)!="array"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置執行錯誤訊息
                        $result["error"][]="\$conf變數須為陣列形態";

                        #如果傳入的參數為 null
                        if($conf==null){

                                #設置執行錯誤訊息
                                $result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";

                                }#if end

                        #回傳結果
                        return $result;

                        }#if end

                #檢查參數
                #函式說明:
                #檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
                #$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
                #必填寫的參數:
                #$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("libAddr");
                #$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
                #$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
                $conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
                #$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu");
                #$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
                #$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__);
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                #$conf["arrayCountEqualCheck"][]=array();
                $checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);

                #如果檢查參數失敗
                if($checkResult["status"]=="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置錯誤訊息
                        $result["error"]=$checkResult;

                        #回傳結果
                        return $result;

                        }#if end

                #如果檢查參數不通過
                if($checkResult["passed"]=="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置錯誤訊息
                        $result["error"]=$checkResult;

                        #回傳結果
                        return $result;

                        }#if end

                #demo用的目標
                $demoTarget="<canvas id=\"myChart\" width=\"400\" height=\"400\"></canvas>";

                #函式說明:
                #匯入chartJS的函式庫.
                #回傳結果:
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$result["error"],錯誤訊息.
                #$result["content"],語法.
                #$result["function"],當前執行的函數名稱.
                #必填參數:
                #$conf["libAddr"],字串,爲ckfEditor套件的網路位置,js附檔名會自動補上.
                $conf["chartJS::importLib"]["libAddr"]=$conf["libAddr"];
                #可省略參數:
                #$conf["fileArgu"],字串,為當前檔案的路徑,預設為__FILE__.
                $conf["chartJS::importLib"]["fileArgu"]=$conf["fileArgu"];
                $importLib=chartJS::importLib($conf["chartJS::importLib"]);
                unset($conf["chartJS::importLib"]);

                #如果建立匯入 chart js lib 的語法失敗
                if($importLib["status"]=="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置錯誤訊息
                        $result["error"]=$importLib;

                        #回傳結果
                        return $result;

                        }#if end

                #取得匯入chart js的語法
                $result["content"]=$result["content"].$importLib["content"];

                #涵式說明:
                #將要執行的script語法透過該函式執行
                #回傳結果:
                #$result["status"],執行是否正常,"true"為正常,"false"為不正常.
                #$result["error"],錯誤訊息陣列
                #$result["function"],當前執行的函數名稱
                #$result["content"],要執行的javaScript語法
                #必填的參數:
                #$conf["script"],字串,要執行的javaScript語法,標籤「<script></script>」會自動補上.
                $conf["javaScript::toScript"]["script"]="
                        var ctx = document.getElementById(\"myChart\").getContext('2d');
                        var myChart = new Chart(ctx,
                        {
                                type: 'bar',
                                data: {
                                        labels: [\"Red\", \"Blue\", \"Yellow\", \"Green\", \"Purple\", \"Orange\"],
                                        datasets: [{
                                                label: '# of Votes',
                                                data: [12, 19, 3, 5, 2, 3],
                                                backgroundColor: [
                                                        'rgba(255, 99, 132, 0.2)',
                                                        'rgba(54, 162, 235, 0.2)',
                                                        'rgba(255, 206, 86, 0.2)',
                                                        'rgba(75, 192, 192, 0.2)',
                                                        'rgba(153, 102, 255, 0.2)',
                                                        'rgba(255, 159, 64, 0.2)'
                                                ],
                                                borderColor: [
                                                        'rgba(255,99,132,1)',
                                                        'rgba(54, 162, 235, 1)',
                                                        'rgba(255, 206, 86, 1)',
                                                        'rgba(75, 192, 192, 1)',
                                                        'rgba(153, 102, 255, 1)',
                                                        'rgba(255, 159, 64, 1)'
                                                ],
                                                borderWidth: 1
                                        }]
                                },
                                options: {
                                        scales: {
                                                yAxes: [{
                                                        ticks: {
                                                                beginAtZero:true
                                                        }
                                                }]
                                        }
                                }
                        });
                        ";
                $toScript=javaScript::toScript($conf["javaScript::toScript"]);
                unset($conf["javaScript::toScript"]);

                #如果轉換成js語法失敗
                if($toScript["status"]=="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置錯誤訊息
                        $result["error"]=$toScript;

                        #回傳結果
                        return $result;

                        }#if end

                #取得使用chart js的語法
                $result["content"]=$result["content"].$demoTarget.$toScript["content"];

                #設置執行正常
                $result["status"]="true";

                #回傳結果
                return $result;

                }#function barDemo end

        /*
        #函式說明:
        #將數據用長條圖表示.
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$result["error"],錯誤訊息.
        #$result["content"],語法.
        #$result["function"],當前執行的函數名稱.
        #必填參數:
        #$conf["libAddr"],字串,爲chartJS的位置,js附檔名會自動補上.
        $conf["libAddr"]="";
        #$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".
        $conf["data"]="";
        #$conf["canvasId"],字串,為要繪製圖表到哪個canvas元素的id.
        $conf["canvasId"]="";
        #$conf["title"],字串,圖表的標題.
        $conf["title"]="";
        #conf["yTitle"],字串,y軸標題.
        $conf["yTitle"]="";
        #conf["xTitle"],字串,x軸標題.
        $conf["xTitle"]="";
        #可省略參數:
        #$conf["fileArgu"],字串,為當前檔案的路徑,預設為__FILE__.
        #$conf["fileArgu"]=__FILE__;
        #$conf["dataUnit"],字串,數據的單位,預設為"number";
        #$conf["dataUnit"]="number";
        #$conf["yTcolor"],字串,y軸標題顏色與透明度,例如:"0,0,255,0.8"就代表紅光0,綠光0,藍光255,透明度0.2.
        #$conf["yTcolor"]="";
        #$conf["xTcolor"],字串,x軸標題顏色與透明度,例如:"0,0,255,0.8"就代表紅光0,綠光0,藍光255,透明度0.2.
        #$conf["xTcolor"]="";
        #參考資料:
        #Creating a Chart=>http://www.chartjs.org/docs/latest/
        #備註:
        #無.
        */
        public static function bar(&$conf=array()){

                #初始化要回傳的內容
                $result=array();

                #取得當前執行的函數名稱
                $result["function"]=__FUNCTION__;

                #初始化要回傳的語法
                $result["content"]="";

                #如果沒有參數
                if(func_num_args()==0){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置執行錯誤訊息
                        $result["error"]="函數".$result["function"]."需要參數";

                        #回傳結果
                        return $result;

                        }#if end

                #取得參數
                $result["argu"]=$conf;

                #如果 $conf 不為陣列
                if(gettype($conf)!="array"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置執行錯誤訊息
                        $result["error"][]="\$conf變數須為陣列形態";

                        #如果傳入的參數為 null
                        if($conf==null){

                                #設置執行錯誤訊息
                                $result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";

                                }#if end

                        #回傳結果
                        return $result;

                        }#if end

                #檢查參數
                #函式說明:
                #檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
                #$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
                #必填寫的參數:
                #$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("libAddr","data","canvasId","title","xTitle","yTitle");
                #$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string","string","string","string",);
                #$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
                $conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
                #$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu","dataUnit","xTcolor","yTcolor");
                #$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string");
                #$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__,"number","0,0,255,0.8","0,0,255,0.8");
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                #$conf["arrayCountEqualCheck"][]=array();
                $checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);

                #如果檢查參數失敗
                if($checkResult["status"]=="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置錯誤訊息
                        $result["error"]=$checkResult;

                        #回傳結果
                        return $result;

                        }#if end

                #如果檢查參數不通過
                if($checkResult["passed"]=="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置錯誤訊息
                        $result["error"]=$checkResult;

                        #回傳結果
                        return $result;

                        }#if end

                #函式說明:
                #匯入chartJS的函式庫.
                #回傳結果:
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$result["error"],錯誤訊息.
                #$result["content"],語法.
                #$result["function"],當前執行的函數名稱.
                #必填參數:
                #$conf["libAddr"],字串,爲ckfEditor套件的網路位置,js附檔名會自動補上.
                $conf["chartJS::importLib"]["libAddr"]=$conf["libAddr"];
                #可省略參數:
                #$conf["fileArgu"],字串,為當前檔案的路徑,預設為__FILE__.
                $conf["chartJS::importLib"]["fileArgu"]=$conf["fileArgu"];
                $importLib=chartJS::importLib($conf["chartJS::importLib"]);
                unset($conf["chartJS::importLib"]);

                #如果建立匯入 chart js lib 的語法失敗
                if($importLib["status"]=="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置錯誤訊息
                        $result["error"]=$importLib;

                        #回傳結果
                        return $result;

                        }#if end

                #取得匯入chart js的語法
                $result["content"]=$result["content"].$importLib["content"];

                #用空格分割
                $dataSet=explode(' ',$conf["data"]);

                #初始化儲存x軸標題的陣列
                $lables=array();

                #初始化儲存y軸數據的陣列
                $values=array();

                #兩兩一對
                for($i=0;$i<count($dataSet);$i=$i+2){

                        #取得x軸項目
                        $lables[]=$dataSet[$i];

                        #取得y軸項目
                        $values[]=$dataSet[$i+1];

                        }#for end

                #涵式說明:
                #將要執行的script語法透過該函式執行
                #回傳結果:
                #$result["status"],執行是否正常,"true"為正常,"false"為不正常.
                #$result["error"],錯誤訊息陣列
                #$result["function"],當前執行的函數名稱
                #$result["content"],要執行的javaScript語法
                #必填的參數:
                #$conf["script"],字串,要執行的javaScript語法,標籤「<script></script>」會自動補上.
                $conf["javaScript::toScript"]["script"]="
                        var ctx = document.getElementById(\"".$conf["canvasId"]."\").getContext('2d');
                        var myChart = new Chart(ctx,
                        {
                                type: 'bar',
                                data: {
                                        labels: ".json_encode($lables).",
                                        datasets: [{
                                                label: '# of ".$conf["dataUnit"]."',
                                                data: ".json_encode($values).",
                                                backgroundColor: [
                                                        'rgba(255, 99, 132, 0.2)',
                                                        'rgba(54, 162, 235, 0.2)',
                                                        'rgba(255, 206, 86, 0.2)',
                                                        'rgba(75, 192, 192, 0.2)',
                                                        'rgba(153, 102, 255, 0.2)',
                                                        'rgba(255, 159, 64, 0.2)'
                                                ],
                                                borderColor: [
                                                        'rgba(255,99,132,1)',
                                                        'rgba(54, 162, 235, 1)',
                                                        'rgba(255, 206, 86, 1)',
                                                        'rgba(75, 192, 192, 1)',
                                                        'rgba(153, 102, 255, 1)',
                                                        'rgba(255, 159, 64, 1)'
                                                ],
                                                borderWidth: 1
                                        }]
                                },
                                options:
                                {
                                        scales:
                                        {
                                                yAxes:
                                                [{
                                                        ticks:
                                                        {
                                                                beginAtZero:true
                                                        },
                                                        scaleLabel:
                                                        {
                                                                display: true,
                                                                labelString: '".$conf["yTitle"]."',
                                                                fontColor:'rgba(".$conf["yTcolor"].")',
                                                        }
                                                }],
                                                xAxes:
                                                [{
                                                        scaleLabel:
                                                        {
                                                                display: true,
                                                                labelString: '".$conf["xTitle"]."',
                                                                fontColor:'rgba(".$conf["yTcolor"].")',
                                                        }
                                                }]
                                        },
                                        title:
                                        {
                                                display: true,
                                                text: '".$conf["title"]."'
                                        },
                                        legend:
                                        {
                                                //disable class label
                                                display: false
                                        },
                                }
                        });
                        ";
                $toScript=javaScript::toScript($conf["javaScript::toScript"]);
                unset($conf["javaScript::toScript"]);

                #如果轉換成js語法失敗
                if($toScript["status"]=="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置錯誤訊息
                        $result["error"]=$toScript;

                        #回傳結果
                        return $result;

                        }#if end

                #取得使用chart js的語法
                $result["content"]=$result["content"].$toScript["content"];

                #設置執行正常
                $result["status"]="true";

                #回傳結果
                return $result;

                }#function barDemo end

        }#class chartJS end

?>