@@ -15,7 +15,7 @@ class Graph extends \Magento\Backend\Block\Dashboard\AbstractDashboard
15
15
/**
16
16
* Api URL
17
17
*/
18
- const API_URL = 'http ://chart.apis.google .com/chart ' ;
18
+ const API_URL = 'https ://image-charts .com/chart ' ;
19
19
20
20
/**
21
21
* All series
@@ -76,6 +76,7 @@ class Graph extends \Magento\Backend\Block\Dashboard\AbstractDashboard
76
76
/**
77
77
* Google chart api data encoding
78
78
*
79
+ * @deprecated since the Google Image Charts API not accessible from March 14, 2019
79
80
* @var string
80
81
*/
81
82
protected $ _encoding = 'e ' ;
@@ -187,11 +188,12 @@ public function getChartUrl($directUrl = true)
187
188
{
188
189
$ params = [
189
190
'cht ' => 'lc ' ,
190
- 'chf ' => 'bg,s,ffffff ' ,
191
- 'chco ' => 'ef672f ' ,
192
191
'chls ' => '7 ' ,
193
- 'chxs ' => '0,676056,15,0,l,676056|1,676056,15,0,l,676056 ' ,
194
- 'chm ' => 'h,f2ebde,0,0:1:.1,1,-1 ' ,
192
+ 'chf ' => 'bg,s,f4f4f4|c,lg,90,ffffff,0.1,ededed,0 ' ,
193
+ 'chm ' => 'B,f4d4b2,0,0,0 ' ,
194
+ 'chco ' => 'db4814 ' ,
195
+ 'chxs ' => '0,0,11|1,0,11 ' ,
196
+ 'chma ' => '15,15,15,15 '
195
197
];
196
198
197
199
$ this ->_allSeries = $ this ->getRowsData ($ this ->_dataRows );
@@ -279,20 +281,11 @@ public function getChartUrl($directUrl = true)
279
281
$ this ->_axisLabels ['x ' ] = $ dates ;
280
282
$ this ->_allSeries = $ datas ;
281
283
282
- //Google encoding values
283
- if ($ this ->_encoding == "s " ) {
284
- // simple encoding
285
- $ params ['chd ' ] = "s: " ;
286
- $ dataDelimiter = "" ;
287
- $ dataSetdelimiter = ", " ;
288
- $ dataMissing = "_ " ;
289
- } else {
290
- // extended encoding
291
- $ params ['chd ' ] = "e: " ;
292
- $ dataDelimiter = "" ;
293
- $ dataSetdelimiter = ", " ;
294
- $ dataMissing = "__ " ;
295
- }
284
+ // Image-Charts Awesome data format values
285
+ $ params ['chd ' ] = "a: " ;
286
+ $ dataDelimiter = ", " ;
287
+ $ dataSetdelimiter = "| " ;
288
+ $ dataMissing = "_ " ;
296
289
297
290
// process each string in the array, and find the max length
298
291
$ localmaxvalue = [0 ];
@@ -306,7 +299,6 @@ public function getChartUrl($directUrl = true)
306
299
$ minvalue = min ($ localminvalue );
307
300
308
301
// default values
309
- $ yrange = 0 ;
310
302
$ yLabels = [];
311
303
$ miny = 0 ;
312
304
$ maxy = 0 ;
@@ -321,52 +313,20 @@ public function getChartUrl($directUrl = true)
321
313
$ maxy = ceil ($ maxvalue + 1 );
322
314
$ yLabels = range ($ miny , $ maxy , 1 );
323
315
}
324
- $ yrange = $ maxy ;
325
316
$ yorigin = 0 ;
326
317
}
327
318
328
319
$ chartdata = [];
329
320
330
321
foreach ($ this ->getAllSeries () as $ index => $ serie ) {
331
322
$ thisdataarray = $ serie ;
332
- if ($ this ->_encoding == "s " ) {
333
- // SIMPLE ENCODING
334
- for ($ j = 0 ; $ j < sizeof ($ thisdataarray ); $ j ++) {
335
- $ currentvalue = $ thisdataarray [$ j ];
336
- if (is_numeric ($ currentvalue )) {
337
- $ ylocation = round (
338
- (strlen ($ this ->_simpleEncoding ) - 1 ) * ($ yorigin + $ currentvalue ) / $ yrange
339
- );
340
- $ chartdata [] = substr ($ this ->_simpleEncoding , $ ylocation , 1 ) . $ dataDelimiter ;
341
- } else {
342
- $ chartdata [] = $ dataMissing . $ dataDelimiter ;
343
- }
344
- }
345
- } else {
346
- // EXTENDED ENCODING
347
- for ($ j = 0 ; $ j < sizeof ($ thisdataarray ); $ j ++) {
348
- $ currentvalue = $ thisdataarray [$ j ];
349
- if (is_numeric ($ currentvalue )) {
350
- if ($ yrange ) {
351
- $ ylocation = 4095 * ($ yorigin + $ currentvalue ) / $ yrange ;
352
- } else {
353
- $ ylocation = 0 ;
354
- }
355
- $ firstchar = floor ($ ylocation / 64 );
356
- $ secondchar = $ ylocation % 64 ;
357
- $ mappedchar = substr (
358
- $ this ->_extendedEncoding ,
359
- $ firstchar ,
360
- 1
361
- ) . substr (
362
- $ this ->_extendedEncoding ,
363
- $ secondchar ,
364
- 1
365
- );
366
- $ chartdata [] = $ mappedchar . $ dataDelimiter ;
367
- } else {
368
- $ chartdata [] = $ dataMissing . $ dataDelimiter ;
369
- }
323
+ for ($ j = 0 ; $ j < sizeof ($ thisdataarray ); $ j ++) {
324
+ $ currentvalue = $ thisdataarray [$ j ];
325
+ if (is_numeric ($ currentvalue )) {
326
+ $ ylocation = $ yorigin + $ currentvalue ;
327
+ $ chartdata [] = $ ylocation . $ dataDelimiter ;
328
+ } else {
329
+ $ chartdata [] = $ dataMissing . $ dataDelimiter ;
370
330
}
371
331
}
372
332
$ chartdata [] = $ dataSetdelimiter ;
@@ -540,6 +500,8 @@ protected function getHeight()
540
500
}
541
501
542
502
/**
503
+ * Sets data helper
504
+ *
543
505
* @param \Magento\Backend\Helper\Dashboard\AbstractDashboard $dataHelper
544
506
* @return void
545
507
*/
0 commit comments