PageRenderTime 65ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/app/protected/extensions/fusioncharts/FusionChartMaker.php

https://bitbucket.org/mstowe/zurmo
PHP | 2136 lines | 1699 code | 201 blank | 236 comment | 94 complexity | 91bcac6eb6f287e0938da7de419d81af MD5 | raw file
Possible License(s): GPL-3.0, BSD-3-Clause, LGPL-3.0, LGPL-2.1, BSD-2-Clause
  1. <?php
  2. class FusionChartMaker
  3. {
  4. var $chartType; # Chart Friendly Name
  5. var $chartID; # ID of the Chart for JS interactivity(optional)
  6. var $SWFFile; # Name of the required FusionCharts SWF file
  7. var $SWFPath; # relative path of FusionCharts SWF files
  8. var $width; # FusionCharts width
  9. var $height; # FusionCharts height
  10. # attribute Delimiter
  11. var $del;
  12. # Chart XML string
  13. var $strXML;
  14. # Chart Series Types : 1 => single series, 2=> multi-series, 5=>Gantt (
  15. # For Future Use : 3=> scatter and bubble, 4=> MSStacked
  16. var $seriesType;
  17. # Charts Atribute array
  18. var $chartParams = array(); #List of Chart Parameters
  19. var $chartParamsCounter; #Number of Chart parameters
  20. var $categoriesParam; # Categories Parameter Setting
  21. var $categoryNames = array(); # Category array for storing Category set
  22. var $categoryNamesCounter; # Category array counter
  23. var $dataset = array(); # dataset array
  24. var $datasetParam = array(); # dataset parameter setting array
  25. var $datasetCounter; # dataset array counter
  26. var $setCounter; # set array counter
  27. # trendLines array
  28. var $trendLines = array(); # trendLines array
  29. var $tLineCounter; # trendLines array counter
  30. #chart messages
  31. var $chartMSG;
  32. var $chartSWF = array(); # Charts SWF array
  33. var $arr_FCColors = array(); # Color Set to be applied to dataplots
  34. var $UserColorON; # User define color define true or false
  35. var $userColorCounter;
  36. // Cache Control
  37. var $noCache;
  38. var $DataBaseType; # DataBase Type
  39. var $encodeChars; # XML for dataXML or dataURL
  40. #############============ For Gantt Chart ============================
  41. # Gantt categories
  42. var $GT_categories = array();
  43. var $GT_categories_Counter;
  44. var $GT_categoriesParam = array();
  45. var $GT_subcategories_Counter;
  46. # Gantt processes
  47. var $GT_processes = array();
  48. var $GT_processes_Counter;
  49. var $GT_processes_Param;
  50. # Gantt Tasks
  51. var $GT_Tasks = array();
  52. var $GT_Tasks_Counter;
  53. var $GT_Tasks_Param;
  54. # Gantt Connectors
  55. var $GT_Connectors = array();
  56. var $GT_Connectors_Counter;
  57. var $GT_Connectors_Param;
  58. # Gantt Milestones
  59. var $GT_Milestones = array();
  60. var $GT_Milestones_Counter;
  61. var $GT_Milestones_Param;
  62. # Gantt datatable
  63. var $GT_datatable = array();
  64. var $GT_datatable_Counter;
  65. var $GT_datatableParam;
  66. var $GT_dataColumnParam = array();
  67. var $GT_subdatatable_Counter;
  68. #------- For Futute Use (start)----------------
  69. # Gantt legend
  70. var $GT_legend = array();
  71. var $GT_legend_Counter;
  72. var $GT_legend_Param;
  73. #------- For Futute Use (end)----------------
  74. var $wMode;
  75. # Advanced Chart settings
  76. var $JSC = array();
  77. #############============ For Future Use (start)============================
  78. # dataset for MSStackedColumn2D
  79. var $MSSDataset = array(); # dataset array for MSStackedColumn2D
  80. var $MSSDatasetParams = array(); # MSSDataset parameter setting
  81. var $MSSDatasetCounter; # MSSDataset array counter
  82. var $MSSSubDatasetCounter; # ms sub dataset array counter
  83. var $MSSSetCounter; # msset array counter
  84. # lineset
  85. var $lineSet = array(); # lineSet array
  86. var $lineSetParam = array(); # lineSet Parameter setting array
  87. var $lineCounter; # line array counter
  88. var $lineSetCounter; # lineset array counter
  89. var $lineIDCounter; # lineID counter;
  90. # vtrendLines array
  91. var $vtrendLines = array(); # vtrendLines array
  92. var $vtLineCounter; # vtrendLines array counter
  93. # style array
  94. var $styles = array(); # styles array
  95. var $styleDefCounter; # define counter
  96. var $styleAppCounter; # apply counter
  97. #############============ For Future Use (end)============================
  98. # FusionCharts Constructor, its take 4 Parameters.
  99. # when we create object of FusionCharts, then Constructor will auto run and initialize
  100. # chats array parameter like chartType, width, height, chartsID
  101. function FusionChartMaker($chartType="column2d",$width="400",$height="300",$chartID="",$isTransparent=""){
  102. $this->wMode=$isTransparent;
  103. # Setting All Charts Array
  104. $this->setChartArrays();
  105. #initialise colorList
  106. $this->colorInit();
  107. # Setting Chart name
  108. $this->chartType=strtolower($chartType);
  109. # Getting Charts Series Type
  110. $this->getSeriesType();
  111. # Setting Charts Width and Height
  112. $this->width=$width;
  113. $this->height=$height;
  114. # Setting ChartID, Defult is Charts Name
  115. if ($chartID==""){
  116. $chartCounter=@$_SESSION['chartcount'];
  117. if($chartCounter<=0 || $chartCounter==null){
  118. $chartCounter=1;
  119. }
  120. $this->chartID=$chartType . $chartCounter;
  121. $_SESSION['chartcount']=++$chartCounter;
  122. }else{
  123. $this->chartID=$chartID;
  124. }
  125. # Setting Defult Parameter Delimiter to ';'
  126. $this->del=";";
  127. # Setting Default SWF Path
  128. $this->SWFPath="";
  129. $this->SWFFile=$this->SWFPath . "FCF_" . $this->chartSWF[$this->chartType][0] . ".swf";
  130. # Initialize categoriesParam
  131. $this->categoriesParam="";
  132. $this->categoryNamesCounter=1;
  133. # Creating Category Array
  134. $this->createCategory($this->categoryNamesCounter);
  135. # Initialize Dataset Variables
  136. $this->datasetCounter=0;
  137. $this->setCounter= 0;
  138. if($this->seriesType>1){
  139. $this->setCounter++;
  140. }
  141. # Initialize MSSDataset Variables
  142. if($this->seriesType==4){
  143. $this->MSSDatasetCounter=0;
  144. $this->MSSSubDatasetCounter=0;
  145. $this->MSSSetCounter=0;
  146. $this->lineCounter=0;
  147. $this->lineSetCounter=0;
  148. $this->lineIDCounter=0;
  149. }
  150. # vTrendLines Array inisialize
  151. if($this->seriesType==3){
  152. $this->vtLineCounter=1;
  153. $this->createvTrendLines($this->vtLineCounter);
  154. }
  155. # TrendLines Array inisialize
  156. $this->tLineCounter=1;
  157. $this->createTrendLines($this->tLineCounter);
  158. # Styles Array inisialize
  159. $this->styleDefCounter=1;
  160. $this->styleAppCounter=1;
  161. $this->createStyles("definition");
  162. $this->createSubStyles("definition","style");
  163. $this->createSubStylesParam("definition","style",$this->styleDefCounter);
  164. $this->GT_categories_Counter=0;
  165. $this->GT_subcategories_Counter=0;
  166. $this->GT_processes_Counter=0;
  167. $this->GT_processes_Param="";
  168. $this->GT_Tasks_Counter=0;
  169. $this->GT_Tasks_Param="";
  170. # Gantt Connectors
  171. $this->GT_Connectors_Counter=0;
  172. $this->GT_Connectors_Param="";
  173. # Gantt datatable
  174. $this->GT_datatable_Counter=0;
  175. $this->GT_datatableParam="";
  176. $this->GT_subdatatable_Counter=0;
  177. # Gantt legend
  178. $this->GT_legend_Counter=0;
  179. $this->GT_legend_Param="";
  180. $this->chartMSG="";
  181. # XML store Variables
  182. $this->strXML="";
  183. $this->UserColorON = false;
  184. $this->userColorCounter=0;
  185. $this->noCache=false;
  186. $this->DataBaseType="mysql";
  187. // JS Constructor
  188. $this->JSC["debugmode"]=false; # debugmode default is false
  189. $this->JSC["registerwithjs"]=false; # registerwithJS default is false
  190. $this->JSC["bgcolor"]=""; # bgcolor default not set
  191. $this->JSC["scalemode"]="noScale"; # scalemode default noScale
  192. $this->JSC["lang"]="EN"; # Language default EN
  193. // dataXML type encode
  194. $this->encodeChars=true;
  195. }
  196. ##------------ PUBLIC FUNCTIONS ----------------------------------------------------------------
  197. # Special Character
  198. function encodeXMLChars($option=true){
  199. $this->$encodeChars=$option;
  200. }
  201. # Setting Parameter Delimiter, Defult Parameter Separator is ";"
  202. function setParamDelimiter($strDel){
  203. $this->del=$strDel;
  204. }
  205. # Database type set like ORACLE and MYSQL
  206. function setDataBaseType($dbType){
  207. $this->DataBaseType=strtolower($dbType);
  208. }
  209. # Setting path of SWF file. file name like FCF_Column3D.swf. where FCF_ is common for all SWF file
  210. function setSWFPath($SWFPath){
  211. $this->SWFPath=$SWFPath;
  212. $this->SWFFile=$this->SWFPath . "FCF_" . $this->chartSWF[$this->chartType][0] . ".swf";
  213. }
  214. # We can add or change single Chart parameter by setChartParam function
  215. # its take Parameter Name and its Value
  216. function setChartParam($paramName, $paramValue){
  217. $this->chartParams[$paramName]=$this->encodeSpecialChars($paramValue);
  218. }
  219. # We can add or change Chart parameter sets by setChartParams function
  220. # its take parameterset [ caption=xyz caption;subCaption=abcd abcd abcd;xAxisName=x axis;yAxisName=y's axis;bgColor=f2fec0;animation=1 ]
  221. # Defult Parameter Separator is ";"
  222. function setChartParams($strParam){
  223. $listArray=explode($this->del,$strParam);
  224. foreach ($listArray as $valueArray) {
  225. $paramValue=explode("=",$valueArray,2);
  226. if($this->validateParam($paramValue)==true){
  227. $this->chartParams[$paramValue[0]]=$this->encodeSpecialChars($paramValue[1]);
  228. }
  229. }
  230. }
  231. # Setting Categories Parameter into categoriesParam variables
  232. function setCategoriesParams($strParam){
  233. $this->categoriesParam .= $this->ConvertParamToXMLAttribute($strParam);
  234. }
  235. # Function addCategoryFromDatabase adding Category from dataset
  236. function addCategoryFromDatabase($query_result, $categoryColumn){
  237. if($this->DataBaseType=="mysql"){
  238. # fetching recordset till eof
  239. while($row = mysql_fetch_array($query_result)){
  240. # add category
  241. $this->addCategory($row[$categoryColumn],"","" );
  242. }
  243. }elseif($this->DataBaseType=="oracle"){
  244. # fetching recordset till eof
  245. while(OCIFetchInto($query_result, $row, OCI_ASSOC)){
  246. # add category
  247. $this->addCategory($row[$categoryColumn],"","" );
  248. }
  249. }
  250. }
  251. # Function addCategoryFromArray adding Category from Array
  252. function addCategoryFromArray($categoryArray){
  253. # convert array to category set
  254. foreach ($categoryArray as $value) {
  255. # adding category
  256. $this->addCategory($value);
  257. }
  258. }
  259. # Function for create set and catagory, dataset , set from array
  260. function addChartDataFromArray($dataArray, $dataCatArray=""){
  261. if(is_array($dataArray)){
  262. if ($this->seriesType==1){
  263. # Single series Array
  264. # aa[..][..]="name" aa[..][..]="value"
  265. foreach($dataArray as $arrayvalue){
  266. if(is_array($arrayvalue)){
  267. $this->addChartData($arrayvalue[1],"name=" . $arrayvalue[0] );
  268. }
  269. }
  270. }else{
  271. # Multi series Array
  272. if(is_array($dataCatArray)){
  273. foreach($dataCatArray as $value){
  274. $this->addCategory($value);
  275. }
  276. }
  277. foreach($dataArray as $arrayvalue){
  278. if(is_array($arrayvalue)){
  279. $i=0;
  280. $aaa[0]="";$aaa[1]="";
  281. foreach($arrayvalue as $value){
  282. if($i>=2){
  283. $this->addChartData($value);
  284. }else{
  285. $aaa[$i]=$value;
  286. }
  287. if($i==1){
  288. $this->addDataset($aaa[0],$aaa[1]);
  289. }
  290. $i++;
  291. }
  292. }
  293. }
  294. }
  295. }
  296. }
  297. # Function addCategory adding Category and vLine element
  298. function addCategory($label="",$catParam="",$vlineParam = "" ){
  299. $strCatXML="";
  300. $strParam="";
  301. $label=$this->encodeSpecialChars($label);
  302. # cheking vlineParam equal blank
  303. if($vlineParam==""){
  304. # cheking catParam not blank
  305. if($catParam!=""){
  306. $strParam = $this->ConvertParamToXMLAttribute($catParam);
  307. }
  308. # adding label and parameter set to category
  309. $strCatXML ="<category name='" . $label . "' " . $strParam . " />";
  310. }else{
  311. $strParam = $this->ConvertParamToXMLAttribute($vlineParam);
  312. # adding parameter set to vLine
  313. $strCatXML="<vLine " . $strParam . " />";
  314. }
  315. # storing into categoryNames array
  316. $this->categoryNames[$this->categoryNamesCounter]=$strCatXML;
  317. # Increase Counter
  318. $this->categoryNamesCounter++;
  319. }
  320. # adding dataset array element
  321. function addDataset($seriesName, $strParam=""){
  322. $this->datasetCounter++;
  323. $this->createDataset($this->datasetCounter);
  324. $this->setCounter++;
  325. $this->createDataValues($this->datasetCounter,"_" . $this->setCounter);
  326. $seriesName=$this->encodeSpecialChars($seriesName);
  327. # creating seriesName and dataset parameter set
  328. $tempParam="";
  329. $tempParam ="seriesName='" . $seriesName . "' ";
  330. $tempParam .= $this->ConvertParamToXMLAttribute($strParam);
  331. $colorParam="";
  332. $pos = strpos(strtolower($tempParam), " color");
  333. if ($pos === false) {
  334. $colorParam=" color='" . $this->getColor($this->datasetCounter-1) . "'";
  335. }
  336. # setting datasetParam array
  337. $this->datasetParam[$this->datasetCounter]=$tempParam . $colorParam;
  338. }
  339. # Function addChartData adding set data element
  340. function addChartData($value="",$setParam="",$vlineParam = "" ){
  341. $strSetXML="";
  342. # Choosing dataset depend on seriesType and getting XML set
  343. if($this->seriesType>=1 and $this->seriesType<=2){
  344. $strSetXML=$this->setSSMSDataArray($value,$setParam,$vlineParam);
  345. }elseif ($this->seriesType==3){
  346. $strSetXML=$this->setScatterBubbleDataArray($value,$setParam,$vlineParam);
  347. }elseif (($this->seriesType==4)){
  348. $strSetXML=$this->setSSMSDataArray($value,$setParam,$vlineParam);
  349. }
  350. # Adding xml set to dataset array and Increase set counter
  351. if ($this->seriesType==1){
  352. $this->dataset[$this->setCounter]=$strSetXML;
  353. $this->setCounter++;
  354. }elseif($this->seriesType>1 and $this->seriesType<4){
  355. $this->dataset[$this->datasetCounter]["_" . $this->setCounter]=$strSetXML;
  356. $this->setCounter++;
  357. }elseif($this->seriesType==4){
  358. $this->MSSDataset[$this->MSSDatasetCounter][$this->MSSSubDatasetCounter][$this->MSSSetCounter]=$strSetXML;
  359. $this->MSSSetCounter++;
  360. }
  361. }
  362. # The addDatasetsFromDatabase() function adds dataset and set elements from -
  363. # database, by Default, from MySql recordset. You can use setDatabaseType() function -
  364. # to set the type of database to work on.
  365. function addDatasetsFromDatabase($query_result, $ctrlField, $valueField,$datsetParamArray="",$link=""){
  366. # Initialize variables
  367. $paramset="";
  368. $tempContrl="";
  369. if(is_array($datsetParamArray)==false){
  370. $datsetParamArray=array();
  371. }
  372. # Calculate total no of array elements in datsetParamArray
  373. $arrLimit=count($datsetParamArray);
  374. $i=1;
  375. $tempParam="";
  376. if($this->DataBaseType=="mysql"){
  377. ##### For My SQL Connection
  378. $FieldArray=explode($this->del,$valueField);
  379. if(count($FieldArray)>1){
  380. ### Muli Series
  381. # fetching recordset
  382. while($row = mysql_fetch_array($query_result)){
  383. # Add Category
  384. $this->addCategory($row[$ctrlField]);
  385. }
  386. $k=0;
  387. # Add daatset for multiple fields
  388. foreach ($FieldArray as $FieldName) {
  389. if($k<$arrLimit){
  390. $tempParam = $datsetParamArray[$k];
  391. }else{
  392. $tempParam="";
  393. }
  394. # Add Dataset with adddataset() function
  395. $this->addDataset($FieldName,$tempParam);
  396. # rewind query result
  397. mysql_data_seek($query_result,0);
  398. while($row = mysql_fetch_array($query_result)){
  399. # Generating URL link
  400. if($link==""){
  401. $paramset="";
  402. }else{
  403. # Generating URL link from getLinkFromPattern
  404. $paramset="link=" . urlencode($this->getLinkFromPattern($row,$link));
  405. }
  406. # add value to dataset
  407. $this->addChartData($row[$FieldName], $paramset, "");
  408. }
  409. $k++;
  410. }
  411. }else{
  412. ### Single Series
  413. # fetching recordset
  414. while($row = mysql_fetch_array($query_result)){
  415. # Creating Control break depending on ctrlField
  416. # if ctrlField value changes then dataset will be Generated
  417. if ($tempContrl!=$row[$ctrlField]){
  418. if($i<=$arrLimit){
  419. $tempParam = $datsetParamArray[$i-1];
  420. }else{
  421. $tempParam="";
  422. }
  423. # Add Dataset with adddataset() function
  424. $this->addDataset($row[$ctrlField],$tempParam);
  425. $tempContrl=$row[$ctrlField];
  426. $i++;
  427. }
  428. # Generating URL link
  429. if($link==""){
  430. $paramset="";
  431. }else{
  432. # Generating URL link from getLinkFromPattern
  433. $paramset="link=" . urlencode($this->getLinkFromPattern($row,$link));
  434. }
  435. # add value to dataset
  436. $this->addChartData($row[$valueField], $paramset, "");
  437. }
  438. }
  439. }elseif($this->DataBaseType=="oracle"){
  440. # For Oracle Connection
  441. # fetching recordset
  442. while(OCIFetchInto($query_result, $row, OCI_ASSOC)){
  443. # Create Control break depending on ctrlField
  444. # if ctrlField value changes then dataset will be Generated
  445. if ($tempContrl!=$row[$ctrlField]){
  446. if($i<=$arrLimit){
  447. $tempParam = $datsetParamArray[$i-1];
  448. }else{
  449. $tempParam="";
  450. }
  451. # add Dataset
  452. $this->addDataset($row[$ctrlField],$tempParam);
  453. $tempContrl=$row[$ctrlField];
  454. $i++;
  455. }
  456. # Generating URL link
  457. if($link==""){
  458. $paramset="";
  459. }else{
  460. # Generating URL link from getLinkFromPattern
  461. $paramset="link=" . urlencode($this->getLinkFromPattern($row,$link));
  462. }
  463. # add value to dataset
  464. $this->addChartData($row[$valueField], $paramset, "");
  465. }
  466. }
  467. }
  468. # addDataFromDatabase funcion take 5 parameter like query_result, label field, value field
  469. # and initialize dataset variables and link
  470. function addDataFromDatabase($query_result, $db_field_ChartData,$db_field_CategoryNames="", $strParam="",$LinkPlaceHolder=""){
  471. $paramset="";
  472. if($this->DataBaseType=="mysql"){
  473. # fetching recordset till eof
  474. while($row = mysql_fetch_array($query_result)){
  475. if($LinkPlaceHolder==""){
  476. $paramset="";
  477. }else{
  478. # Getting link
  479. $paramset="link=" . urlencode($this->getLinkFromPattern($row,$LinkPlaceHolder));
  480. }
  481. if ($strParam=""){
  482. $strParam=$paramset;
  483. }else{
  484. $strParam .= ";" . $paramset;
  485. }
  486. # covert to set element and save to $partXML
  487. if($db_field_CategoryNames==""){
  488. $data=@$row[$db_field_ChartData];
  489. if($strParam!="")
  490. $this->addChartData($this->encodeSpecialChars($data),$strParam);
  491. else
  492. $this->addChartData($this->encodeSpecialChars($data));
  493. }
  494. else{
  495. $data=@$row[$db_field_ChartData];
  496. $label=@$row[$db_field_CategoryNames];
  497. $this->addChartData($this->encodeSpecialChars($data),"name=" . $this->encodeSpecialChars($label) . ";" .$strParam,"" );
  498. }
  499. }
  500. }elseif($this->DataBaseType=="oracle"){
  501. # fetching recordset till eof
  502. while(OCIFetchInto($query_result, $row, OCI_ASSOC)){
  503. if($LinkPlaceHolder==""){
  504. $paramset="";
  505. }else{
  506. # Getting link
  507. $paramset="link=" . urlencode($this->getLinkFromPattern($row,$LinkPlaceHolder));
  508. }
  509. if ($strParam=""){
  510. $strParam=$paramset;
  511. }else{
  512. $strParam .= ";" . $paramset;
  513. }
  514. # covert to set element and save to $partXML
  515. if($db_field_CategoryNames==""){
  516. $data=@$row[$db_field_ChartData];
  517. if($strParam!="")
  518. $this->addChartData($this->encodeSpecialChars($data),$strParam);
  519. else
  520. $this->addChartData($this->encodeSpecialChars($data));
  521. }
  522. else{
  523. $data=@$row[$db_field_ChartData];
  524. $label=@$row[$db_field_CategoryNames];
  525. $this->addChartData($this->encodeSpecialChars($data),"name=" . $this->encodeSpecialChars($label) . ";" .$strParam,"" );
  526. }
  527. }
  528. }
  529. }
  530. # setTLine create TrendLine parameter
  531. function addTrendLine($strParam){
  532. $listArray=explode($this->del,$strParam);
  533. foreach ($listArray as $valueArray) {
  534. $paramValue=explode("=",$valueArray,2);
  535. if($this->validateParam($paramValue)==true){
  536. $this->trendLines[$this->tLineCounter][$paramValue[0]]=$this->encodeSpecialChars($paramValue[1]);
  537. }
  538. }
  539. $this->tLineCounter++;
  540. }
  541. #this function sets chart messages
  542. function setChartMessage($strParam){
  543. $this->chartMSG="?";
  544. $listArray=explode($this->del,$strParam);
  545. foreach ($listArray as $valueArray) {
  546. $paramValue=explode("=",$valueArray,2);
  547. if($this->validateParam($paramValue)==true){
  548. $this->chartMSG.=$paramValue[0] . "=" . $this->encodeSpecialChars($paramValue[1]) . "&";
  549. }
  550. }
  551. $this->chartMSG=substr($this->chartMSG,0,strlen($this->chartMSG)-1);
  552. }
  553. #### - This function is mostly for Future USE -----------------------------
  554. # set JS constructor of FusionCharts.js
  555. function setAddChartParams($debugMode, $registerWithJS=0, $c="", $scaleMode="", $lang=""){
  556. $this->JSC["debugmode"]=$debugMode;
  557. $this->JSC["registerwithjs"]=$registerWithJS;
  558. $this->JSC["bgcolor"]=$c;
  559. $this->JSC["scalemode"]=$scaleMode;
  560. $this->JSC["lang"]=$lang;
  561. }
  562. # The function SetInitParam() adds extra chart settings
  563. function setInitParam($tname,$tvalue){
  564. $trimName= strtolower(str_replace(" ","",$tname));
  565. $this->JSC[$trimName]=$tvalue;
  566. }
  567. # getXML render all class arrays to XML output
  568. function getXML(){
  569. $this->strXML="";
  570. $strChartParam="";
  571. $strChartParam=$this->getChartParamsXML();
  572. if($this->seriesType==1){
  573. if(gettype(strpos($this->chartType,"line"))!="boolean"){
  574. if(strpos($strChartParam,"lineColor")===false){
  575. $colorSet=$this->getColor(0);
  576. $this->setChartParams("lineColor=" . $colorSet );
  577. }
  578. }
  579. if(gettype(strpos($this->chartType,"area"))!="boolean"){
  580. if(strpos($strChartParam,"areaBgColor")===false){
  581. $colorSet=$this->getColor(0);
  582. $this->setChartParams("areaBgColor=" . $colorSet );
  583. }
  584. }
  585. }
  586. # calling getChartParamsXML function for chart parameter
  587. $this->strXML = "<graph " . $this->getChartParamsXML() . " >";
  588. if ($this->seriesType >= 0 and $this->seriesType <= 4) {
  589. # calling getCategoriesXML function for Category element
  590. $this->strXML .= $this->getCategoriesXML();
  591. # calling getDatasetXML function for set element
  592. $this->strXML .= $this->getDatasetXML();
  593. # calling getvTrendLinesXML function for vTrendLines element
  594. if($this->seriesType==3){
  595. $this->strXML .= $this->getvTrendLinesXML();
  596. }
  597. # Calling getLinesetXML
  598. if($this->seriesType==4){
  599. $this->strXML .= $this->getLinesetXML();
  600. }
  601. # calling getTrendLinesXML function for TrendLines element
  602. $this->strXML .= $this->getTrendLinesXML();
  603. # calling getStylesXML function for Styles element
  604. $this->strXML .= $this->getStylesXML();
  605. }else if($this->seriesType == 5) {
  606. $this->strXML .= $this->getGanttCategoriesXML();
  607. $this->strXML .= $this->getProcessesXML();
  608. $this->strXML .= $this->getGanttDatatableXML();
  609. $this->strXML .= $this->getTasksXML();
  610. $this->strXML .= $this->getConnectorsXML();
  611. $this->strXML .= $this->getMilestonesXML();
  612. # calling getTrendLinesXML function for TrendLines element
  613. $this->strXML .= $this->getTrendLinesXML();
  614. # calling getStylesXML function for Styles element
  615. $this->strXML .= $this->getStylesXML();
  616. $this->strXML .= $this->getLegendXML();
  617. }
  618. # Closing Chart element
  619. $this->strXML .= "</graph>";
  620. $this->strXML = chr(239) . chr(187) . chr(191) . '<?xml version="1.0" encoding="UTF-8"?>' . $this->strXML;
  621. # Return XML output
  622. return $this->strXML;
  623. }
  624. # set wMode
  625. function setwMode($isTransparent=""){
  626. $this->wMode=$isTransparent;
  627. }
  628. # Function getXML render all class arrays to XML output
  629. function renderChart($isHTML=false, $display=true){
  630. $this->strXML=$this->getXML();
  631. $this->SWFFile=$this->SWFPath . "FCF_" . $this->chartSWF[$this->chartType][0] . ".swf";
  632. if($this->noCache==true){
  633. if($this->chartMSG==""){
  634. $this->chartMSG = "?nocache=" . microtime();
  635. }else{
  636. $this->chartMSG .= "&nocache=" . microtime();
  637. }
  638. }
  639. # print the charts
  640. if($isHTML==false){
  641. if($display){
  642. print $this->renderChartJS($this->SWFFile . $this->chartMSG,"",$this->strXML,$this->chartID, $this->width, $this->height,$this->JSC["debugmode"], $this->JSC["registerwithjs"],$this->wMode);
  643. }else{
  644. return $this->renderChartJS($this->SWFFile . $this->chartMSG,"",$this->strXML,$this->chartID, $this->width, $this->height,$this->JSC["debugmode"], $this->JSC["registerwithjs"],$this->wMode);
  645. }
  646. }else{
  647. if($display){
  648. print $this->renderChartHTML($this->SWFFile . $this->chartMSG,"",$this->strXML,$this->chartID, $this->width, $this->height,$this->JSC["debugmode"], $this->JSC["registerwithjs"],$this->wMode);
  649. }else{
  650. return $this->renderChartHTML($this->SWFFile . $this->chartMSG,"",$this->strXML,$this->chartID, $this->width, $this->height,$this->JSC["debugmode"], $this->JSC["registerwithjs"],$this->wMode);
  651. }
  652. }
  653. }
  654. # Sets whether chart SWF files are not to be cached
  655. function setOffChartCaching($swfNoCache=false){
  656. $this->noCache=$swfNoCache;
  657. }
  658. # Renders Chart form External XML data source
  659. function renderChartFromExtXML($dataXML){
  660. print $this->renderChartJS($this->SWFFile,"",$dataXML,$this->chartID, $this->width, $this->height, $this->JSC["debugmode"], $this->JSC["registerwithjs"], $this->wMode);
  661. }
  662. // RenderChartJS renders the JavaScript + HTML code required to embed a chart.
  663. // This function assumes that you've already included the FusionCharts JavaScript class
  664. // in your page.
  665. // $chartSWF - SWF File Name (and Path) of the chart which you intend to plot
  666. // $strURL - If you intend to use dataURL method for this chart, pass the URL as this parameter. Else, set it to "" (in case of dataXML method)
  667. // $strXML - If you intend to use dataXML method for this chart, pass the XML data as this parameter. Else, set it to "" (in case of dataURL method)
  668. // $chartId - Id for the chart, using which it will be recognized in the HTML page. Each chart on the page needs to have a unique Id.
  669. // $chartWidth - Intended width for the chart (in pixels)
  670. // $chartHeight - Intended height for the chart (in pixels)
  671. // $debugMode - Whether to start the chart in debug mode
  672. // $registerWithJS - Whether to ask chart to register itself with JavaScript
  673. // $setTransparent - Transparent mode
  674. function renderChartJS($chartSWF, $strURL, $strXML, $chartId, $chartWidth, $chartHeight, $debugMode=false, $registerWithJS=false, $setTransparent="") {
  675. //First we create a new DIV for each chart. We specify the name of DIV as "chartId"Div.
  676. //DIV names are case-sensitive.
  677. // The Steps in the script block below are:
  678. //
  679. // 1)In the DIV the text "Chart" is shown to users before the chart has started loading
  680. // (if there is a lag in relaying SWF from server). This text is also shown to users
  681. // who do not have Flash Player installed. You can configure it as per your needs.
  682. //
  683. // 2) The chart is rendered using FusionCharts Class. Each chart's instance (JavaScript) Id
  684. // is named as chart_"chartId".
  685. //
  686. // 3) Check whether to provide data using dataXML method or dataURL method
  687. // save the data for usage below
  688. $strHTML="";
  689. if ($strXML=="")
  690. $tempData = "\t//Set the dataURL of the chart\n\tchart_$chartId.setDataURL(\"$strURL\");";
  691. else
  692. $tempData = "\t//Provide entire XML data using dataXML method\n\tchart_$chartId.setDataXML(\"$strXML\");";
  693. // Set up necessary variables for the RENDERCHART
  694. $chartIdDiv = $chartId . "Div";
  695. $ndebugMode = $this->boolToNum($debugMode);
  696. $nregisterWithJS = $this->boolToNum($registerWithJS);
  697. $nsetTransparent=($setTransparent?"true":"false");
  698. // Create a string for output by the caller
  699. $strHTML .= "\n<!-- START Script Block for Chart $chartId --> \n\n";
  700. $strHTML .= "<div id=\"$chartIdDiv\">\n";
  701. $strHTML .= "\tChart.\n";
  702. $strHTML .= "</div>\n";
  703. $strHTML .= "<script type=\"text/javascript\" >\n";
  704. //Instantiate the Chart
  705. $strHTML .= "\tvar chart_$chartId = new FusionChartMaker(\"$chartSWF\", \"$chartId\", \"$chartWidth\", \"$chartHeight\", \"$ndebugMode\", \"$nregisterWithJS\", \"" . $this->JSC["bgcolor"] . "\",\"" . $this->JSC["scalemode"] . "\",\"" . $this->JSC["lang"] . "\"); \n";
  706. if($nsetTransparent=="true"){
  707. $strHTML .= "\tchart_$chartId.setTransparent(\"$nsetTransparent\");\n";
  708. }
  709. $strHTML .= $tempData . "\n";
  710. //Finally, render the chart.
  711. $strHTML .= "\tchart_$chartId.render(\"$chartIdDiv\");\n";
  712. $strHTML .= "</script>\n\n";
  713. $strHTML .= "<!-- END Script Block for Chart $chartId -->\n";
  714. return $strHTML;
  715. }
  716. //RenderChartHTML function renders the HTML code for the JavaScript. This
  717. //method does NOT embed the chart using JavaScript class. Instead, it uses
  718. //direct HTML embedding. So, if you see the charts on IE 6 (or above), you'll
  719. //see the "Click to activate..." message on the chart.
  720. // $chartSWF - SWF File Name (and Path) of the chart which you intend to plot
  721. // $strURL - If you intend to use dataURL method for this chart, pass the URL as this parameter. Else, set it to "" (in case of dataXML method)
  722. // $strXML - If you intend to use dataXML method for this chart, pass the XML data as this parameter. Else, set it to "" (in case of dataURL method)
  723. // $chartId - Id for the chart, using which it will be recognized in the HTML page. Each chart on the page needs to have a unique Id.
  724. // $chartWidth - Intended width for the chart (in pixels)
  725. // $chartHeight - Intended height for the chart (in pixels)
  726. // $debugMode - Whether to start the chart in debug mode
  727. // $registerWithJS - Whether to ask chart to register itself with JavaScript
  728. // $setTransparent - Transparent mode
  729. function renderChartHTML($chartSWF, $strURL, $strXML, $chartId, $chartWidth, $chartHeight, $debugMode=false,$registerWithJS=false, $setTransparent="") {
  730. // Generate the FlashVars string based on whether dataURL has been provided or dataXML.
  731. $strHTML="";
  732. $strFlashVars = "&chartWidth=" . $chartWidth . "&chartHeight=" . $chartHeight . "&debugMode=" . $this->boolToNum($debugMode);
  733. $strFlashVars .= "&scaleMode=" . $this->JSC["scalemode"] . "&lang=" . $this->JSC["lang"];
  734. if ($strXML=="")
  735. // DataURL Mode
  736. $strFlashVars .= "&dataURL=" . $strURL;
  737. else
  738. //DataXML Mode
  739. $strFlashVars .= "&dataXML=" . $strXML;
  740. $nregisterWithJS = $this->boolToNum($registerWithJS);
  741. if($setTransparent!=""){
  742. $nsetTransparent=($setTransparent==false?"opaque":"transparent");
  743. }else{
  744. $nsetTransparent="window";
  745. }
  746. $strHTML .= "\n<!-- START Code Block for Chart $chartId -->\n\n";
  747. $HTTP="http";
  748. if(strtolower($_SERVER['HTTPS'])=="on")
  749. {
  750. $HTTP="https";
  751. }
  752. $Strval = $_SERVER['HTTP_USER_AGENT'];
  753. $pos=strpos($Strval,"MSIE");
  754. if($pos===false){
  755. $strHTML .= "<embed src=\"$chartSWF\" FlashVars=\"$strFlashVars&registerWithJS=$nregisterWithJS\" quality=\"high\" width=\"$chartWidth\" height=\"$chartHeight\" name=\"$chartId\" " . ($this->JSC["bgcolor"]!="")? " bgcolor=\"" . $this->JSC["bgcolor"] . "\"":"" . " allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\" pluginspage=\"$HTTP://www.macromedia.com/go/getflashplayer\" wmode=\"$nsetTransparent\" \n";
  756. }else{
  757. $strHTML .= "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"$HTTP://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"$chartWidth\" height=\"$chartHeight\" id=\"$chartId\"> \n";
  758. $strHTML .= "\t<param name=\"allowScriptAccess\" value=\"always\" /> \n";
  759. $strHTML .= "\t<param name=\"movie\" value=\"$chartSWF\" /> \n";
  760. $strHTML .= "\t<param name=\"FlashVars\" value=\"$strFlashVars&registerWithJS=$nregisterWithJS\" /> \n";
  761. $strHTML .= "\t<param name=\"quality\" value=\"high\" /> \n";
  762. $strHTML .= "\t<param name=\"wmode\" value=\"$nsetTransparent\" /> \n";
  763. //Set background color
  764. if($this->JSC["bgcolor"] !="") {
  765. $strHTML .= "\t<param name=\"bgcolor\" value=\"" . $this->JSC["bgcolor"] . "\" /> \n";
  766. }
  767. $strHTML .= "</object>\n";
  768. $strHTML .= "<!-- END Code Block for Chart $chartId -->\n";
  769. }
  770. return $strHTML;
  771. }
  772. // The function boolToNum() function converts boolean values to numeric (1/0)
  773. function boolToNum($bVal) {
  774. return (($bVal==true) ? 1 : 0);
  775. }
  776. ##------------ PRIVATE FUNCTIONS ----------------------------------------------------------------
  777. # getDatasetXML create set chart xml
  778. function getDatasetXML(){
  779. # Calling dataset function depending on seriesType
  780. switch ($this->seriesType){
  781. case 1 :
  782. return $this->getSSDatasetXML();
  783. break;
  784. case 2 :
  785. return $this->getMSDatasetXML();
  786. break;
  787. case 3 :
  788. return $this->getMSDatasetXML();
  789. break;
  790. case 4 :
  791. return $this->getMSStackedDatasetXML();
  792. break;
  793. }
  794. }
  795. # By getChartParamsXML, we can fetch charts array and convert into XML
  796. # and return like "caption='xyz' xAxisName='x side' ............
  797. function getChartParamsXML(){
  798. $partXML="";
  799. # feching charts each array and converting into chat parameter
  800. foreach($this->chartParams as $part_type => $part_name){
  801. $partXML .= $part_type . "='" . $this->encodeSpecialChars($part_name) . "' ";
  802. }
  803. # Return Chart Parameter
  804. return $partXML;
  805. }
  806. # Function getCategoriesXML for getting Category part XML
  807. function getCategoriesXML(){
  808. if($this->seriesType>1){
  809. $partXML="";
  810. # adding categories parameter
  811. $partXML="<categories " . $this->categoriesParam . " >";
  812. if($this->categoryNamesCounter>1){
  813. foreach($this->categoryNames as $part_type => $part_name){
  814. if($part_name!=""){
  815. # adding elements
  816. if($part_name!="Array"){
  817. $partXML .= $part_name;
  818. }
  819. }
  820. }
  821. }
  822. # Closing <categories>
  823. $partXML .="</categories>";
  824. return $partXML;
  825. }
  826. }
  827. # creating single set element
  828. # <set value='30' />
  829. # <set value='26' />
  830. function getSSDatasetXML(){
  831. if($this->seriesType==1){
  832. $partXML="";
  833. foreach($this->dataset as $part_type => $part_name){
  834. if($part_name!=""){
  835. # adding elements
  836. if($part_name!="Array"){
  837. $partXML .= $part_name;
  838. }
  839. }
  840. }
  841. return $partXML;
  842. }
  843. }
  844. # getMSDatasetXML for getting datset part XML
  845. # <dataset seriesName='Product A' color='AFD8F8' showValues='0'>
  846. # <set value='30' />
  847. # <set value='26' />
  848. # </dataset>
  849. function getMSDatasetXML(){
  850. if($this->seriesType>1){
  851. $partXML="";
  852. foreach($this->dataset as $part_type => $part_name){
  853. $partXML .="<dataset " . $this->datasetParam[$part_type] . " >";
  854. foreach($this->dataset[$part_type] as $part_type1 => $part_name1){
  855. if($part_name1!=""){
  856. # Adding elements
  857. if($part_name1!="Array"){
  858. $partXML .= $part_name1;
  859. }
  860. }
  861. }
  862. $partXML .="</dataset>";
  863. }
  864. return $partXML;
  865. }
  866. }
  867. # getTrendLinesXML create XML output depending on trendLines array
  868. # <trendLines>
  869. # <line startValue='700000' color='009933' displayvalue='Target' />
  870. # </trendLines>
  871. function getTrendLinesXML(){
  872. $partXML="";
  873. $lineXML="";
  874. # fetching trendLines array
  875. foreach($this->trendLines as $l_type => $l_name){
  876. # staring line element
  877. $lineXML .="<line ";
  878. # fetching trendLines array with in array element
  879. foreach($this->trendLines[$l_type] as $part_type => $part_name){
  880. $lineXML .= $part_type . "='" . $this->encodeSpecialChars($part_name) . "' ";
  881. }
  882. # close line element
  883. $lineXML .=" />";
  884. }
  885. # if line element present then adding $lineXML with in trendLines element
  886. $pos = strpos($lineXML, "=");
  887. if ($pos!==false){
  888. $partXML = "<trendLines>" . $lineXML . "</trendLines>";
  889. }else{
  890. # return nothing
  891. $partXML="";
  892. }
  893. # return trendLines xml
  894. return $partXML;
  895. }
  896. # adding set element to dataset element for seriesType 1 and 2
  897. function setSSMSDataArray($value="",$setParam="",$vlineParam = "" ){
  898. $strSetXML="";
  899. $strParam="";
  900. $color=0;
  901. if($vlineParam==""){
  902. if($setParam!=""){
  903. $strParam = $this->ConvertParamToXMLAttribute($setParam);
  904. }
  905. $colorSet="";
  906. if ($this->UserColorON == true){
  907. if($this->seriesType==1 && (gettype(strpos($this->chartType,"line"))=="boolean" && gettype(strpos($this->chartType,"area"))=="boolean")){
  908. if(strpos(strtolower($strParam)," color")===false){
  909. $colorSet=" color='" . $this->getColor($this->setCounter) . "' ";
  910. }
  911. }
  912. }else{
  913. if($this->seriesType==1 && (gettype(strpos($this->chartType,"pie"))=="boolean" && gettype(strpos($this->chartType,"line"))=="boolean" && gettype(strpos($this->chartType,"area"))=="boolean")){
  914. if(strpos(strtolower($strParam)," color")===false){
  915. $colorSet=" color='" . $this->getColor($this->setCounter) . "' ";
  916. }
  917. }
  918. }
  919. # setting set parameter
  920. $strSetXML ="<set value='" . $value . "' " . $strParam . $colorSet . " />";
  921. }else{
  922. $strParam = $this->ConvertParamToXMLAttribute($strParam);
  923. # setting vline parameter
  924. $strSetXML="<vLine " . $strParam . " />";
  925. }
  926. return $strSetXML;
  927. }
  928. ## - - - - - - Array Init Functions - - --- - -- - - - - - - -- - - - - -
  929. # Function createCategory create array element with in Categories
  930. function createCategory($catID){
  931. $this->categoryNames[$catID]= array();
  932. }
  933. # createDataset dataset array element
  934. function createDataset($dataID){
  935. $this->dataset[$dataID]= array();
  936. }
  937. # creating set dataset array element
  938. function createDataValues($datasetID, $dataID){
  939. $this->dataset[$datasetID][$dataID]= array();
  940. }
  941. # createTrendLines create TrendLines array
  942. function createTrendLines($lineID){
  943. $this->trendLines[$lineID] = array();
  944. }
  945. # setTLine create TrendLine parameter
  946. function setTLine($lineID,$paramName, $paramValue){
  947. $this->trendLines[$lineID][$paramName]=$paramValue;
  948. }
  949. # ----- ---------- ----- Misc utility functions ---- ------ -----------
  950. # converting ' and " to %26apos; and &quot;
  951. function encodeSpecialChars($strValue){
  952. $pattern="/%(?![\da-f]{2}|[\da-f]{4})/i";
  953. $strValue=preg_replace($pattern, "%25", $strValue);
  954. if ($this->encodeChars==true){
  955. $strValue=str_replace("&","%26",$strValue);
  956. $strValue=str_replace("'","%26apos;",$strValue);
  957. $strValue=str_replace("\"","%26quot;",$strValue);
  958. $strValue=preg_replace("/\<a/i", "%26lt;A", $strValue);
  959. $strValue=preg_replace("/\<\/a/i", "%26lt;/A", $strValue);
  960. $strValue=preg_replace("/\<i/i", "%26lt;I", $strValue);
  961. $strValue=preg_replace("/\<\/i/i", "%26lt;/I", $strValue);
  962. $strValue=preg_replace("/\<u/i", "%26lt;U", $strValue);
  963. $strValue=preg_replace("/\<\/u/i", "%26lt;/U", $strValue);
  964. $strValue=preg_replace("/\<li/i", "%26lt;LI", $strValue);
  965. $strValue=preg_replace("/\<\/li/i", "%26lt;/LI", $strValue);
  966. $strValue=preg_replace("/\<font/i", "%26lt;FONT", $strValue);
  967. $strValue=preg_replace("/\<\/font/i", "%26lt;/FONT", $strValue);
  968. $strValue=preg_replace("/\<p/i", "%26lt;P", $strValue);
  969. $strValue=preg_replace("/\<\/p/i", "%26lt;/P", $strValue);
  970. $strValue=preg_replace("/\<br/i", "%26lt;BR", $strValue);
  971. $strValue=preg_replace("/\<b/i", "%26lt;B", $strValue);
  972. $strValue=preg_replace("/\<\/b/i", "%26lt;/B", $strValue);
  973. $strValue=str_replace("<", "%ab",$strValue);
  974. $strValue=str_replace(">", "%26gt;",$strValue);
  975. }else{
  976. $strValue=str_replace("'","&apos;",$strValue);
  977. $strValue=str_replace("\"","&quot;",$strValue);
  978. $strValue=preg_replace("/\<a/i", "&lt;A", $strValue);
  979. $strValue=preg_replace("/\<\/a/i", "&lt;/A", $strValue);
  980. $strValue=preg_replace("/\<i/i", "&lt;I", $strValue);
  981. $strValue=preg_replace("/\<\/i/i", "&lt;/I", $strValue);
  982. $strValue=preg_replace("/\<u/i", "&lt;U", $strValue);
  983. $strValue=preg_replace("/\<\/u/i", "&lt;/U", $strValue);
  984. $strValue=preg_replace("/\<li/i", "&lt;LI", $strValue);
  985. $strValue=preg_replace("/\<\/li/i", "&lt;/LI", $strValue);
  986. $strValue=preg_replace("/\<font/i", "&lt;FONT", $strValue);
  987. $strValue=preg_replace("/\<\/font/i", "&lt;/FONT", $strValue);
  988. $strValue=preg_replace("/\<p/i", "&lt;P", $strValue);
  989. $strValue=preg_replace("/\<\/p/i", "&lt;/P", $strValue);
  990. $strValue=preg_replace("/\<br/i", "&lt;BR", $strValue);
  991. $strValue=preg_replace("/\<b/i", "&lt;B", $strValue);
  992. $strValue=preg_replace("/\<\/b/i", "&lt;/B", $strValue);
  993. $strValue=str_replace("<","%ab",$strValue);
  994. $strValue=str_replace(">", "&gt;",$strValue);
  995. }
  996. $strValue=str_replace("=","%3d",$strValue);
  997. $strValue=str_replace("+","%2b",$strValue);
  998. $strValue=str_replace("�","%a2",$strValue);
  999. $strValue=str_replace("�","%a3",$strValue);
  1000. $strValue=str_replace("�","%E2%82%AC",$strValue);
  1001. $strValue=str_replace("�","%a5",$strValue);
  1002. $strValue=str_replace("?","%e2%82%a3",$strValue);
  1003. return $strValue;
  1004. }
  1005. # Its convert pattern link to original link
  1006. # abcd.php?cid=##Field_name_1##&pname=##Field_name_2##
  1007. function getLinkFromPattern($row,$tempLink){
  1008. # convert link into array break on '##'
  1009. $aa=explode("##",$tempLink);
  1010. # Reading array
  1011. foreach($aa as $v){
  1012. # Finding '=' into array
  1013. $pos = strpos($v, "=");
  1014. # not found '='
  1015. if($pos === false){
  1016. if($v!=""){
  1017. $pet="##" . $v . "##";
  1018. $tempLink=str_replace($pet,$row[$v],$tempLink);
  1019. }
  1020. }
  1021. }
  1022. return $tempLink;
  1023. }
  1024. # convertion of semi colon(;) separeted paramater to XML attribute
  1025. function ConvertParamToXMLAttribute($strParam){
  1026. $xmlParam="";
  1027. $listArray=explode($this->del,$strParam);
  1028. foreach ($listArray as $valueArray) {
  1029. $paramValue=explode("=",$valueArray,2);
  1030. if($this->validateParam($paramValue)==true){
  1031. # creating parameter set
  1032. $xmlParam .= $paramValue[0] . "='" . $this->encodeSpecialChars($paramValue[1]) . "' ";
  1033. }
  1034. }
  1035. # Return
  1036. return $xmlParam;
  1037. }
  1038. function validateParam($paramValue){
  1039. if(count($paramValue)>=2){
  1040. if(trim($paramValue[0])==""){
  1041. return false;
  1042. }
  1043. return true;
  1044. }else{
  1045. return false;
  1046. }
  1047. }
  1048. # Getting Charts series type from charts array. 1 => single series, 2=> multi-series, 3=> scatter and bubble, 4=> MSStacked. defult 1 => single series
  1049. function getSeriesType(){
  1050. $sValue=1;
  1051. if(is_array($this->chartSWF[$this->chartType])){
  1052. $sValue=$this->chartSWF[$this->chartType][1];
  1053. }else{
  1054. $sValue=1;
  1055. }
  1056. $this->seriesType=$sValue;
  1057. }
  1058. #this function returns a color from a list of colors
  1059. function getColor($counter){
  1060. $strColor="";
  1061. if ($this->UserColorON == false){
  1062. $strColor=$this->arr_FCColors[$counter % count($this->arr_FCColors)];
  1063. }else{
  1064. $strColor=$this->UserColor[$counter % count($this->UserColor)];
  1065. }
  1066. return $strColor;
  1067. }
  1068. # Clear User Color
  1069. function ClearUserColor()
  1070. {
  1071. $this->UserColorON = false;
  1072. }
  1073. # add User Colors
  1074. function addColors($ColorList)
  1075. {
  1076. $listArray=explode($this->del, $ColorList);
  1077. $this->UserColorON = true;
  1078. foreach ($listArray as $valueArray) {
  1079. $this->UserColor[$this->userColorCounter]=$valueArray;
  1080. $this->userColorCounter++;
  1081. }
  1082. }
  1083. ### ----- Pupulate Color and Chart SWF array ------ ------- ---------------------
  1084. function colorInit(){
  1085. $this->arr_FCColors[] = "AFD8F8";
  1086. $this->arr_FCColors[] = "F6BD0F";
  1087. $this->arr_FCColors[] = "8BBA00";
  1088. $this->arr_FCColors[] = "FF8E46";
  1089. $this->arr_FCColors[] = "008E8E";
  1090. $this->arr_FCColors[] = "D64646";
  1091. $this->arr_FCColors[] = "8E468E";
  1092. $this->arr_FCColors[] = "588526";
  1093. $this->arr_FCColors[] = "B3AA00";
  1094. $this->arr_FCColors[] = "008ED6";
  1095. $this->arr_FCColors[] = "9D080D";
  1096. $this->arr_FCColors[] = "A186BE";
  1097. $this->arr_FCColors[] = "CC6600";
  1098. $this->arr_FCColors[] = "FDC689";
  1099. $this->arr_FCColors[] = "ABA000";
  1100. $this->arr_FCColors[] = "F26D7D";
  1101. $this->arr_FCColors[] = "FFF200";
  1102. $this->arr_FCColors[] = "0054A6";
  1103. $this->arr_FCColors[] = "F7941C";
  1104. $this->arr_FCColors[] = "CC3300";
  1105. $this->arr_FCColors[] = "006600";
  1106. $this->arr_FCColors[] = "663300";
  1107. $this->arr_FCColors[] = "6DCFF6";
  1108. }
  1109. # Setting FusionCharts SWF file array list and series
  1110. function setChartArrays(){
  1111. $this->chartSWF['area2d'][0]="Area2D";
  1112. $this->chartSWF['area2d'][1]=1;
  1113. $this->chartSWF['bar2d'][0]="Bar2D";
  1114. $this->chartSWF['bar2d'][1]=1;
  1115. $this->chartSWF['column2d'][0]="Column2D";
  1116. $this->chartSWF['column2d'][1]=1;
  1117. $this->chartSWF['column3d'][0]="Column3D";
  1118. $this->chartSWF['column3d'][1]=1;
  1119. $this->chartSWF['doughnut2d'][0]="Doughnut2D";
  1120. $this->chartSWF['doughnut2d'][1]=1;
  1121. $this->chartSWF['doughnut3d'][0]="Doughnut3D";
  1122. $this->chartSWF['doughnut3d'][1]=1;
  1123. $this->chartSWF['line'][0]="Line";
  1124. $this->chartSWF['line'][1]=1;
  1125. $this->chartSWF['pie2d'][0]="Pie2D";
  1126. $this->chartSWF['pie2d'][1]=1;
  1127. $this->chartSWF['pie3d'][0]="Pie3D";
  1128. $this->chartSWF['pie3d'][1]=1;
  1129. $this->chartSWF['funnel'][0]="Funnel";
  1130. $this->chartSWF['funnel'][1]=1;
  1131. $this->chartSWF['msarea'][0]="MSArea";
  1132. $this->chartSWF['msarea'][1]=2;
  1133. $this->chartSWF['msarea2d'][0]="MSArea2D";
  1134. $this->chartSWF['msarea2d'][1]=2;
  1135. $this->chartSWF['msbar2d'][0]="MSBar2D";
  1136. $this->chartSWF['msbar2d'][1]=2;
  1137. $this->chartSWF['mscolumn2d'][0]="MSColumn2D";
  1138. $this->chartSWF['mscolumn2d'][1]=2;
  1139. $this->chartSWF['mscolumn3d'][0]="MSColumn3D";
  1140. $this->chartSWF['mscolumn3d'][1]=2;
  1141. $this->chartSWF['mscolumn3dlinedy'][0]="MSColumn3DLineDY";
  1142. $this->chartSWF['mscolumn3dlinedy'][1]=2;
  1143. $this->chartSWF['mscolumnLine3D'][0]="MSColumnLine3D";
  1144. $this->chartSWF['mscolumnLine3D'][1]=2;
  1145. $this->chartSWF['mscombi2d'][0]="MSCombi2D";
  1146. $this->chartSWF['mscombi2d'][1]=2;
  1147. $this->chartSWF['mscombidy2d'][0]="MSCombiDY2D";
  1148. $this->chartSWF['mscombidy2d'][1]=2;
  1149. $this->chartSWF['msline'][0]="MSLine";
  1150. $this->chartSWF['msline'][1]=2;
  1151. $this->chartSWF['scrollarea2d'][0]="ScrollArea2D";
  1152. $this->chartSWF['scrollarea2d'][1]=2;
  1153. $this->chartSWF['scrollcolumn2d'][0]="ScrollColumn2D";
  1154. $this->chartSWF['scrollcolumn2d'][1]=2;
  1155. $this->chartSWF['scrollcombi2d'][0]="ScrollCombi2D";
  1156. $this->chartSWF['scrollcombi2d'][1]=2;
  1157. $this->chartSWF['scrollcombidy2d'][0]="ScrollCombiDY2D";
  1158. $this->chartSWF['scrollcombidy2d'][1]=2;
  1159. $this->chartSWF['scrollline2d'][0]="ScrollLine2D";
  1160. $this->chartSWF['scrollline2d'][1]=2;
  1161. $this->chartSWF['scrollstackedcolumn2d'][0]="ScrollStackedColumn2D";
  1162. $this->chartSWF['scrollstackedcolumn2d'][1]=2;
  1163. $this->chartSWF['stackedarea2d'][0]="StackedArea2D";
  1164. $this->chartSWF['stackedarea2d'][1]=2;
  1165. $this->chartSWF['stackedbar2d'][0]="StackedBar2D";
  1166. $this->chartSWF['stackedbar2d'][1]=2;
  1167. $this->chartSWF['stackedbar3d'][0]="StackedBar3D";
  1168. $this->chartSWF['stackedbar3d'][1]=2;
  1169. $this->chartSWF['stackedcolumn2d'][0]="StackedColumn2D";
  1170. $this->chartSWF['stackedcolumn2d'][1]=2;
  1171. $this->chartSWF['stackedcolumn3d'][0]="StackedColumn3D";
  1172. $this->chartSWF['stackedcolumn3d'][1]=2;
  1173. $this->chartSWF['stackedcolumn3dlinedy'][0]="StackedColumn3DLineDY";
  1174. $this->chartSWF['stackedcolumn3dlinedy'][1]=2;
  1175. $this->chartSWF['mscolumn2dlinedy'][0]="MSColumn2DLineDY";
  1176. $this->chartSWF['mscolumn2dlinedy'][1]=2;
  1177. $this->chartSWF['bubble'][0]="Bubble";
  1178. $this->chartSWF['bubble'][1]=3;
  1179. $this->chartSWF['scatter'][0]="Scatter";
  1180. $this->chartSWF['scatter'][1]=3;
  1181. $this->chartSWF['msstackedcolumn2dlinedy'][0]="MSStackedColumn2DLineDY";
  1182. $this->chartSWF['msstackedcolumn2dlinedy'][1]=4;
  1183. $this->chartSWF['msstackedcolumn2d'][0]="MSStackedColumn2D";
  1184. $this->chartSWF['msstackedcolumn2d'][1]=2;
  1185. $this->chartSWF['gantt'][0]="Gantt";
  1186. $this->chartSWF['gantt'][1]=5;
  1187. }
  1188. ####################### GANTT CHART (start) ######################################
  1189. # ----------- Public Functions -----------------------------------------------
  1190. # Function addCategory adding Category and vLine element
  1191. function addGanttCategorySet($catParam=""){
  1192. $this->GT_categories_Counter++;
  1193. $this->GT_categories[$this->GT_categories_Counter]= array();
  1194. $strParam="";
  1195. # cheking catParam not blank
  1196. if($catParam!=""){
  1197. $strParam = $this->ConvertParamToXMLAttribute($catParam);
  1198. }
  1199. $this->GT_categoriesParam[$this->GT_categories_Counter]=$strParam;
  1200. }
  1201. # Function addGanttCategory adding Category
  1202. function addGanttCategory($label="",$catParam=""){
  1203. $strCatXML="";
  1204. $strParam="";
  1205. # cheking catParam not blank
  1206. if($catParam!=""){
  1207. $strParam = $this->ConvertParamToXMLAttribute($catParam);
  1208. }
  1209. # adding label and parameter set to category
  1210. $strCatXML ="<category name='" . $label . "' " . $strParam . " />";
  1211. # storing into GT_categories array
  1212. $this->GT_categories[$this->GT_categories_Counter][$this->GT_subcategories_Counter]=$strCatXML;
  1213. # Increase Counter
  1214. $this->GT_subcategories_Counter++;
  1215. }
  1216. # Setting Process Parameter into categoriesParam variables
  1217. function setGanttProcessesParams($strParam){
  1218. $this->GT_processes_Param .= $this->ConvertParamToXMLAttribute($strParam);
  1219. }
  1220. # Function addGanttProcess adding Process
  1221. function addGanttProcess($label="",$catParam=""){
  1222. $strCatXML="";
  1223. $strParam="";
  1224. # cheking catParam not blank
  1225. if($catParam!=""){
  1226. $strParam = $this->ConvertParamToXMLAttribute($catParam);
  1227. }
  1228. # adding label and parameter set to category
  1229. $strCatXML ="<process name='" . $label . "' " . $strParam . " />";
  1230. # storing into categoryNames array
  1231. $this->GT_processes[$this->GT_processes_Counter]=$strCatXML;
  1232. # Increase Counter
  1233. $this->GT_processes_Counter++;
  1234. }
  1235. # Setting Tasks Parameter into TaskParam variables
  1236. function setGanttTasksParams($strParam){
  1237. $this->GT_Tasks_Param .= $this->ConvertParamToXMLAttribute($strParam);
  1238. }
  1239. # Function addGanttTasks adding Tasks
  1240. function addGanttTask($label="",$catParam=""){
  1241. $strCatXML="";
  1242. $strParam="";
  1243. # cheking catParam not blank
  1244. if($catParam!=""){
  1245. $strParam = $this->ConvertParamToXMLAttribute($catParam);
  1246. }
  1247. # adding label and parameter set to category
  1248. $strCatXML ="<task name='" . $label . "' " . $strParam . " />";
  1249. # storing into GT_Tasks array
  1250. $this->GT_Tasks[$this->GT_Tasks_Counter]=$strCatXML;
  1251. # Increase Counter
  1252. $this->GT_Tasks_Counter++;
  1253. }
  1254. # Setting Tasks Parameter into ConnectorsParam variables
  1255. function setGanttConnectorsParams($strParam){
  1256. $this->GT_Connectors_Param .= $this->ConvertParamToXMLAttribute($strParam);
  1257. }
  1258. # Function addGanttConnector adding Connector
  1259. function addGanttConnector($From,$To,$catParam=""){
  1260. $strCatXML="";
  1261. $strParam="";
  1262. # cheking catParam not blank
  1263. if($catParam!=""){
  1264. $strParam = $this->ConvertParamToXMLAttribute($catParam);
  1265. }
  1266. # adding label and parameter set to category
  1267. $strCatXML ="<connector fromTaskId='" . $From . "' toTaskId='" . $To . "' " . $strParam . " />";
  1268. # storing into GT_Connectors array
  1269. $this->GT_Connectors[$this->GT_Connectors_Counter]=$strCatXML;
  1270. # Increase Counter
  1271. $this->GT_Connectors_Counter++;
  1272. }
  1273. # Setting Milestones Parameter into MilestonesParam variables
  1274. function setGanttMilestonesParams($strParam){
  1275. $this->GT_Milestones_Param .= $this->ConvertParamToXMLAttribute($strParam);
  1276. }
  1277. # Function addGanttMilestones adding Milestones
  1278. function addGanttMilestone($taskID,$catParam=""){
  1279. $strCatXML="";
  1280. $strParam="";
  1281. # cheking catParam not blank
  1282. if($catParam!=""){
  1283. $strParam = $this->ConvertParamToXMLAttribute($catParam);
  1284. }
  1285. # adding label and parameter set to Milestones
  1286. $strCatXML ="<milestone taskId='" . $taskID . "' " . $strParam . " />";
  1287. # storing into GT_Milestones array
  1288. $this->GT_Milestones[$this->GT_Milestones_Counter]=$strCatXML;
  1289. # Increase Counter
  1290. $this->GT_Milestones_Counter++;
  1291. }
  1292. # Setting Legend Parameter into LegendParam variables
  1293. function setGanttLegendParams($strParam){
  1294. $this->GT_legend_Param .= $this->ConvertParamToXMLAttribute($strParam);
  1295. }
  1296. # Function addGanttLegendItem adding LegendItem
  1297. function addGanttLegendItem($label,$catParam=""){
  1298. $strCatXML="";
  1299. $strParam="";
  1300. # cheking catParam not blank
  1301. if($catParam!=""){
  1302. $strParam = $this->ConvertParamToXMLAttribute($catParam);
  1303. }
  1304. # adding label and parameter set to LegendItem
  1305. $strCatXML ="<item label='" . $label . "' " . $strParam . " />";
  1306. # storing into GT_legend array
  1307. $this->GT_legend[$this->GT_legend_Counter]=$strCatXML;
  1308. # Increase Counter
  1309. $this->GT_legend_Counter++;
  1310. }
  1311. # Setting Datatable Parameter into DatatableParam variables
  1312. function setGanttDatatableParams($strParam){
  1313. $this->GT_datatableParam .= $this->ConvertParamToXMLAttribute($strParam);
  1314. }
  1315. # Function addGanttDatacolumn adding Datacolumn
  1316. function addGanttDatacolumn($catParam=""){
  1317. $this->GT_datatable_Counter++;
  1318. $this->GT_datatable[$this->GT_datatable_Counter]= array();
  1319. $strParam="";
  1320. # cheking catParam not blank
  1321. if($catParam!=""){
  1322. $strParam = $this->ConvertParamToXMLAttribute($catParam);
  1323. }
  1324. $this->GT_dataColumnParam[$this->GT_datatable_Counter]=$strParam;
  1325. }
  1326. # Function addGanttColumnText adding ColumnText
  1327. function addGanttColumnText($label="",$catParam=""){
  1328. $strCatXML="";
  1329. $strParam="";
  1330. # cheking catParam not blank
  1331. if($catParam!=""){
  1332. $strParam = $this->ConvertParamToXMLAttribute($catParam);
  1333. }
  1334. # adding label and parameter set to category
  1335. $strCatXML ="<text label='" . $label . "' " . $strParam . " />";
  1336. # storing into GT_datatable array
  1337. $this->GT_datatable[$this->GT_datatable_Counter][$this->GT_subdatatable_Counter]=$strCatXML;
  1338. # Increase Counter
  1339. $this->GT_subdatatable_Counter++;
  1340. }
  1341. ### ------------- Gantt Private Functoins ----------------------------------------------------------------------
  1342. #-- Gantt array init ------------------------------------------------
  1343. # Function createCategory create array element with in Categories
  1344. function createGanttCategory($catID){
  1345. $this->GT_categories[$catID]= array();
  1346. }
  1347. # Function createGanttDatatable create array element with in Datatable
  1348. function createGanttDatatable($catID){
  1349. $this->GT_datatable[$catID]= array();
  1350. }
  1351. #-- GANTT XML genetators -------------------------------------------
  1352. # Function getCategoriesXML for getting Category part XML
  1353. function getGanttCategoriesXML(){
  1354. $partXML="";
  1355. foreach($this->GT_categories as $part_type => $part_name){
  1356. # adding categories parameter
  1357. $partXML .="<categories " . $this->GT_categoriesParam[$part_type] . " >";
  1358. foreach($this->GT_categories[$part_type] as $part_type1 => $part_name1){
  1359. if($part_name1!=""){
  1360. # adding elements
  1361. $partXML .= $part_name1;
  1362. }
  1363. }
  1364. # Closing <categories>
  1365. $partXML .="</categories>";
  1366. }
  1367. return $partXML;
  1368. }
  1369. # Function getProcessesXML for getting Processes part XML
  1370. function getProcessesXML(){
  1371. $partXML="";
  1372. # adding processes parameter
  1373. $partXML="<processes " . $this->GT_processes_Param . " >";
  1374. foreach($this->GT_processes as $part_type => $part_name){
  1375. if($part_name!=""){
  1376. # adding elements
  1377. $partXML .= $part_name;
  1378. }
  1379. }
  1380. # Closing <categories>
  1381. $partXML .="</processes>";
  1382. return $partXML;
  1383. }
  1384. # Function getProcessesXML for getting Processes part XML
  1385. function getTasksXML(){
  1386. $partXML="";
  1387. # adding processes parameter
  1388. $partXML="<tasks " . $this->GT_Tasks_Param . " >";
  1389. foreach($this->GT_Tasks as $part_type => $part_name){
  1390. if($part_name!=""){
  1391. # adding elements
  1392. $partXML .= $part_name;
  1393. }
  1394. }
  1395. # Closing <tasks>
  1396. $partXML .="</tasks>";
  1397. return $partXML;
  1398. }
  1399. # Function getConnectorsXML for getting Connectors part XML
  1400. function getConnectorsXML(){
  1401. $c=0;
  1402. $partXML="";
  1403. # adding connectors parameter
  1404. $partXML="<connectors " . $this->GT_Connectors_Param . " >";
  1405. foreach($this->GT_Connectors as $part_type => $part_name){
  1406. if($part_name!=""){
  1407. # adding elements
  1408. $partXML .= $part_name;
  1409. $c++;
  1410. }
  1411. }
  1412. # Closing <connectors>
  1413. $partXML .="</connectors>";
  1414. if ($c>0){
  1415. return $partXML;
  1416. }else{
  1417. return "";
  1418. }
  1419. }
  1420. # Function getMilestonesXML for getting Milestones part XML
  1421. function getMilestonesXML(){
  1422. $c=0;
  1423. $partXML="";
  1424. # adding Milestones parameter
  1425. $partXML="<milestones " . $this->GT_Milestones_Param . " >";
  1426. foreach($this->GT_Milestones as $part_type => $part_name){
  1427. if($part_name!=""){
  1428. # adding elements
  1429. $partXML .= $part_name;
  1430. $c++;
  1431. }
  1432. }
  1433. # Closing <milestones>
  1434. $partXML .="</milestones>";
  1435. if ($c>0) {
  1436. return $partXML;
  1437. }else{
  1438. return "";
  1439. }
  1440. }
  1441. # Function getLegendXML for getting Legend part XML
  1442. function getLegendXML(){
  1443. $c=0;
  1444. $partXML="";
  1445. # adding Legend parameter
  1446. $partXML="<legend " . $this->GT_legend_Param . " >";
  1447. foreach($this->GT_legend as $part_type => $part_name){
  1448. if($part_name!=""){
  1449. # adding elements
  1450. $partXML .= $part_name;
  1451. $c++;
  1452. }
  1453. }
  1454. # Closing <milestones>
  1455. $partXML .="</legend>";
  1456. if ($c>0) {
  1457. return $partXML;
  1458. }else{
  1459. return "";
  1460. }
  1461. }
  1462. # Function getGanttDatatableXML for getting Category part XML
  1463. function getGanttDatatableXML(){
  1464. $partXML="";
  1465. foreach($this->GT_datatable as $part_type => $part_name){
  1466. # adding dataColumn parameter
  1467. $partXML .="<dataColumn " . $this->GT_dataColumnParam[$part_type] . " >";
  1468. foreach($this->GT_datatable[$part_type] as $part_type1 => $part_name1){
  1469. if($part_name1!=""){
  1470. # adding elements
  1471. $partXML .= $part_name1;
  1472. }
  1473. }
  1474. # Closing <dataColumn>
  1475. $partXML .="</dataColumn>";
  1476. }
  1477. $allPart="<dataTable " . $this->GT_datatableParam . " >" . $partXML . "</dataTable>";
  1478. return $allPart;
  1479. }
  1480. ####################### GANTT CHART (end) ######################################
  1481. #====================== For Future Use (start) =====================================
  1482. ##---------PUBLIC functions ----------------------------------------------------
  1483. # adding Lineset array and parameter to it
  1484. function addLineset($seriesName, $strParam){
  1485. $this->createLineset();
  1486. $this->lineSetCounter++;
  1487. $this->lineSet[$this->lineCounter][$this->lineSetCounter]= array();
  1488. $tempParam="";
  1489. $tempParam ="seriesName='" . $seriesName . "' ";
  1490. $tempParam .= $this->ConvertParamToXMLAttribute($strParam);
  1491. $this->lineIDCounter++;
  1492. # setting lineSetParam array with Parameter set
  1493. $this->lineSetParam [$this->lineSetCounter]=$tempParam;
  1494. }
  1495. # adding Line's Set data
  1496. function addLinesetData($value="",$setParam="",$vlineParam = "" ){
  1497. $strSetXML="";
  1498. # getting parameter set
  1499. $strSetXML=$this->setSSMSDataArray($value,$setParam,$vlineParam);
  1500. # setting paramter to lineSet array
  1501. $this->lineSet[$this->lineCounter][$this->lineSetCounter][$this->lineIDCounter]=$strSetXML;
  1502. # Increase lineIDCounter
  1503. $this->lineIDCounter++;
  1504. }
  1505. # adding ms dataset and parameter
  1506. function addMSSSubDataset($seriesName, $strParam){
  1507. $this->MSSSubDatasetCounter++;
  1508. $this->MSSDataset[$this->MSSDatasetCounter][$this->MSSSubDatasetCounter]= array();
  1509. $tempParam="";
  1510. # creating seriesName
  1511. $tempParam ="seriesName='" . $seriesName . "' ";
  1512. $tempParam .= $this->ConvertParamToXMLAttribute($strParam);
  1513. $this->MSSSetCounter++;
  1514. # adding Parameter to MSSDatasetParams array
  1515. $this->MSSDatasetParams[$this->MSSDatasetCounter][$this->MSSSubDatasetCounter]=$tempParam;
  1516. }
  1517. # adding set element to dataset element for seriesType 3
  1518. function setScatterBubbleDataArray($value="",$setParam="",$vlineParam = "" ){
  1519. $strSetXML="";
  1520. $strParam="";
  1521. if($vlineParam==""){
  1522. if($setParam!=""){
  1523. $strParam = $this->ConvertParamToXMLAttribute($setParam);
  1524. }
  1525. # adding Parameter into set elements
  1526. $strSetXML ="<set x='" . $value . "' " . $strParam . " />";
  1527. }else{
  1528. # Parameter for vLine
  1529. $strParam = $this->ConvertParamToXMLAttribute($vlineParam);
  1530. # adding vLine element
  1531. $strSetXML="<vLine " . $strParam . " />";
  1532. }
  1533. return $strSetXML;
  1534. }
  1535. # setvTLine create TrendLine parameter
  1536. function setVTrendLines($strParam){
  1537. $listArray=explode($this->del,$strParam);
  1538. foreach ($listArray as $valueArray) {
  1539. $paramValue=explode("=",$valueArray,2);
  1540. if($this->validateParam($paramValue)==true){
  1541. $this->vtrendLines[$this->vtLineCounter][$paramValue[0]]=$this->encodeSpecialChars($paramValue[1]);
  1542. }
  1543. }
  1544. $this->vtLineCounter++;
  1545. }
  1546. # setSubStylesParam create sub styles array to store parameters
  1547. function addStyleDef($styleName,$styleType,$strParam){
  1548. $this->styles["definition"]["style"][$this->styleDefCounter]["name"]= $styleName;
  1549. $this->styles["definition"]["style"][$this->styleDefCounter]["type"]= $styleType;
  1550. $listArray=explode($this->del,$strParam);
  1551. foreach ($listArray as $valueArray) {
  1552. $paramValue=explode("=",$valueArray,2);
  1553. if($this->validateParam($paramValue)==true){
  1554. $this->styles["definition"]["style"][$this->styleDefCounter][$paramValue[0]]= $this->encodeSpecialChars($paramValue[1]);
  1555. }
  1556. }
  1557. $this->styleDefCounter++;
  1558. }
  1559. # apply styles
  1560. function addStyleApp($toObject,$styles){
  1561. $this->styles["application"]["apply"][$this->styleAppCounter]["toObject"]= $toObject;
  1562. $this->styles["application"]["apply"][$this->styleAppCounter]["styles"]= $styles;
  1563. $this->styleAppCounter++;
  1564. }
  1565. ##---------PRIVATE functions ----------------------------------------------------
  1566. ## - -- - - XML generators - - - - ---- - -- - - - -
  1567. # Function getLinesetXML for getting Lineset XML
  1568. function getLinesetXML(){
  1569. # if seriesType MSStackedColumn2DLineDY (4) then linset element will be Generate
  1570. if($this->seriesType==4){
  1571. $partXML="";
  1572. # Fetching lineSet array and Generating lineset xml element
  1573. foreach($this->lineSet as $part_type => $part_name){
  1574. $partXML .= "<lineset " . $this->lineSetParam[$part_type] . " >";
  1575. foreach($this->lineSet[$part_type] as $part_type1 => $part_name1){
  1576. foreach($this->lineSet[$part_type][$part_type1] as $part_type2 => $part_name2){
  1577. if ($part_type2!=""){
  1578. $partXML .= $part_name2;
  1579. }
  1580. }
  1581. }
  1582. $partXML .= "</lineset>";
  1583. }
  1584. return $partXML;
  1585. }
  1586. }
  1587. # Function getMSStackedDatasetXML for getting datset part XML from ms stacked chart dataset array
  1588. # <dataset>
  1589. # <dataset seriesName='Product A' color='AFD8F8' showValues='0'>
  1590. # <set value='30' />
  1591. # <set value='26' />
  1592. # </dataset>
  1593. # </dataset>
  1594. function getMSStackedDatasetXML(){
  1595. if($this->seriesType==4){
  1596. $partXML="";
  1597. foreach($this->MSSDataset as $part_type => $part_name){
  1598. $partXML .= "<dataset>";
  1599. foreach($this->MSSDataset[$part_type] as $part_type1 => $part_name1){
  1600. $partXML .= "<dataset " . $this->MSSDatasetParams[$part_type][$part_type1] . " >";
  1601. foreach($this->MSSDataset[$part_type][$part_type1] as $part_type2 => $part_name2){
  1602. if ($part_type2!=""){
  1603. $partXML .= $part_name2;
  1604. }
  1605. }
  1606. $partXML .= "</dataset>";
  1607. }
  1608. $partXML .= "</dataset>";
  1609. }
  1610. return $partXML;
  1611. }
  1612. }
  1613. # getvTrendLinesXML create XML output depending on trendLines array
  1614. # <vTrendlines>
  1615. # <line displayValue='vTrendLines' startValue='5' endValue='6' alpha='10' color='ff0000' />
  1616. # </vTrendlines>
  1617. function getvTrendLinesXML(){
  1618. $partXML="";
  1619. $lineXML="";
  1620. # fetching vtrendLines array
  1621. foreach($this->vtrendLines as $l_type => $l_name){
  1622. # staring line element
  1623. $lineXML .="<line ";
  1624. # fetching vtrendLines array with in array element
  1625. foreach($this->vtrendLines[$l_type] as $part_type => $part_name){
  1626. $lineXML .= $part_type . "='" . $this->encodeSpecialChars($part_name) . "' ";
  1627. }
  1628. # close line element
  1629. $lineXML .=" />";
  1630. }
  1631. # if line element present then adding $lineXML with in vtrendLines element
  1632. $pos = strpos($lineXML, "=");
  1633. if ($pos !== false) {
  1634. $partXML = "<vTrendlines>" . $lineXML . "</vTrendlines>";
  1635. }else{
  1636. # return nothing
  1637. $partXML="";
  1638. }
  1639. # return vtrendLines xml
  1640. return $partXML;
  1641. }
  1642. # getStylesXML create the styles XML from styles array
  1643. /*
  1644. <styles>
  1645. <definition>
  1646. <style name='CanvasAnim' type='animation' param='_xScale' start='0' duration='1' />
  1647. </definition>
  1648. <application>
  1649. <apply toObject='Canvas' styles='CanvasAnim' />
  1650. </application>
  1651. </styles>
  1652. */
  1653. function getStylesXML(){
  1654. $partXML="";
  1655. $lineXML="";
  1656. # fetching styles array
  1657. foreach($this->styles as $s_type => $s_name){
  1658. $lineXML .="<" . $s_type . ">";
  1659. # fetching styles array with in array
  1660. foreach($this->styles[$s_type] as $sub_type => $sub_name){
  1661. # creating dynamic element depend on array name
  1662. # fetching styles array with in array with array element
  1663. foreach($this->styles[$s_type][$sub_type] as $part_type => $part_name){
  1664. $lineXML .="<" . $sub_type . " ";
  1665. foreach($this->styles[$s_type][$sub_type][$part_type] as $part_type1 => $part_name1){
  1666. # adding elements parameter
  1667. $lineXML .= $part_type1 . "='" . $this->encodeSpecialChars($part_name1) . "' ";
  1668. }
  1669. $lineXML .=" />";
  1670. }
  1671. }
  1672. # closing open eleement
  1673. $lineXML .="</" . $s_type . ">";
  1674. }
  1675. # adding $lineXML with in style element
  1676. # cheking element have any attribute or not
  1677. $pos = strpos($lineXML, "=");
  1678. if ($pos !== false) {
  1679. $partXML = "<styles>" . $lineXML . "</styles>";
  1680. }else{
  1681. $partXML ="";
  1682. }
  1683. # returning the part of xml
  1684. return $partXML;
  1685. }
  1686. ## ---------- Array Init functions ----------------------------------------------
  1687. # create Lineset array
  1688. function createLineset(){
  1689. $this->lineCounter++;
  1690. $this->lineSet[$this->lineCounter]= array();
  1691. }
  1692. # creating MS-Stacked ataset array element and parameter array
  1693. function createMSSDataset(){
  1694. $this->MSSDatasetCounter++;
  1695. $this->MSSDataset[$this->MSSDatasetCounter]= array();
  1696. $this->MSSDatasetParams[$this->MSSDatasetCounter]=array();
  1697. }
  1698. # Creating set data with in datset
  1699. function createMSSSetData(){
  1700. $this->MSSSetCounter++;
  1701. $this->MSSDataset[$this->MSSDatasetCounter][$this->MSSSubDatasetCounter][$this->MSSSetCounter]= array();
  1702. }
  1703. # createStyles create array element with in styles array
  1704. function createStyles($styleID){
  1705. $this->styles[$styleID]= array();
  1706. }
  1707. # createSubStyles create array element with in styles array element with in sub styles array
  1708. # element for storing sub element parameter
  1709. function createSubStyles($styleID,$subStyle){
  1710. $this->styles[$styleID][$subStyle]= array();
  1711. }
  1712. # createvTrendLines create TrendLines array
  1713. function createvTrendLines($lineID){
  1714. $this->vtrendLines[$lineID] = array();
  1715. }
  1716. # setvTLine create TrendLine parameter
  1717. function setvTLine($lineID,$paramName, $paramValue){
  1718. $this->vtrendLines[$lineID][$paramName]=$paramValue;
  1719. }
  1720. # create sub styles param
  1721. function createSubStylesParam($styleID,$subStyle,$subParam){
  1722. $this->styles[$styleID][$subStyle][$subParam]= array();
  1723. }
  1724. # setSubStylesParam create sub styles array to store parameters
  1725. function setSubStylesParam($styleID,$subStyle,$subParam,$id,$value){
  1726. $this->styles[$styleID][$subStyle][$subParam][$id]= $value;
  1727. }
  1728. #====================== For Future Use (end) ======================================
  1729. }
  1730. ?>