@@ -99,6 +99,7 @@ public function display()
9999 $ chartHeight = 500 ;
100100
101101 $ jsonData = json_encode ($ chartReadyData ['data ' ]);
102+ $ jsonKeys = json_encode ($ chartReadyData ['keys ' ]);
102103 $ jsonLabels = json_encode ($ chartReadyData ['labels ' ]);
103104 $ jsonLabelsAndValues = json_encode ($ chartReadyData ['labelsAndValues ' ]);
104105
@@ -128,6 +129,7 @@ public function display()
128129 <input type='hidden' class='searchFormTab' value=' $ searchFormTab' />
129130 $ autoRefresh
130131 <script>
132+ window["chartHBarKeys $ canvasId"] = $ jsonKeys;
131133 var pie = new RGraph.Pie({
132134 id: ' $ canvasId',
133135 data: $ jsonData,
@@ -203,13 +205,14 @@ public function display()
203205 function getChartData ($ query )
204206 {
205207 global $ app_list_strings , $ db ;
206- $ dataSet = array () ;
208+ $ dataSet = [] ;
207209 $ result = $ db ->query ($ query );
208210
209211 $ row = $ db ->fetchByAssoc ($ result );
210212
211- while ($ row != null ){
212- if (isset ($ row ['lead_source ' ]) && $ app_list_strings ['lead_source_dom ' ][$ row ['lead_source ' ]] ) {
213+ while ($ row != null ) {
214+ if (isset ($ row ['lead_source ' ]) && $ app_list_strings ['lead_source_dom ' ][$ row ['lead_source ' ]]) {
215+ $ row ['lead_source_key ' ] = $ row ['lead_source ' ];
213216 $ row ['lead_source ' ] = $ app_list_strings ['lead_source_dom ' ][$ row ['lead_source ' ]];
214217 }
215218 $ dataSet [] = $ row ;
@@ -218,21 +221,22 @@ function getChartData($query)
218221 return $ dataSet ;
219222 }
220223
221- protected function prepareChartData ($ data ,$ currency_symbol , $ thousands_symbol )
224+ protected function prepareChartData ($ data , $ currency_symbol , $ thousands_symbol )
222225 {
223226 //return $data;
224- $ chart ['labels ' ]=array ();
225- $ chart ['data ' ]=array ();
227+ $ chart ['labels ' ] = [];
228+ $ chart ['data ' ] = [];
229+ $ chart ['keys ' ] = [];
226230 $ total = 0 ;
227- foreach ($ data as $ i )
228- {
229- $ chart ['labelsAndValues ' ][]=$ i ['lead_source ' ].' ( ' .$ currency_symbol .(int )$ i ['total ' ].$ thousands_symbol .') ' ;
231+ foreach ($ data as $ i ) {
232+ $ chart ['labelsAndValues ' ][] = $ i ['lead_source ' ] . ' ( ' . $ currency_symbol . (int )$ i ['total ' ] . $ thousands_symbol . ') ' ;
230233 //$chart['labelsAndValues'][]=$currency_symbol.(int)$i['total'].$thousands_symbol;
231- $ chart ['labels ' ][]=$ i ['lead_source ' ];
232- $ chart ['data ' ][]=(int )$ i ['total ' ];
233- $ total +=(int )$ i ['total ' ];
234+ $ chart ['labels ' ][] = $ i ['lead_source ' ];
235+ $ chart ['keys ' ][] = $ i ['lead_source_key ' ];
236+ $ chart ['data ' ][] = (int )$ i ['total ' ];
237+ $ total += (int )$ i ['total ' ];
234238 }
235- $ chart ['total ' ]= $ total ;
239+ $ chart ['total ' ] = $ total ;
236240 return $ chart ;
237241 }
238242
0 commit comments