PEEL Shopping
Open source ecommerce : PEEL Shopping
flot.php
Go to the documentation of this file.
1 <?php
2 // This file should be in UTF8 without BOM - Accents examples: éèê
3 // +----------------------------------------------------------------------+
4 // | Copyright (c) 2004-2015 Advisto SAS, service PEEL - contact@peel.fr |
5 // +----------------------------------------------------------------------+
6 // | This file is part of PEEL Shopping 8.0.0, which is subject to an |
7 // | opensource GPL license: you are allowed to customize the code |
8 // | for your own needs, but must keep your changes under GPL |
9 // | More information: https://www.peel.fr/lire/licence-gpl-70.html |
10 // +----------------------------------------------------------------------+
11 // | Author: Advisto SAS, RCS 479 205 452, France, https://www.peel.fr/ |
12 // +----------------------------------------------------------------------+
13 // $Id: flot.php 46935 2015-09-18 08:49:48Z gboussin $
14 if (!defined('IN_PEEL')) {
15  die();
16 }
17 
29 function get_flot_chart($width, $height, $url, $chart_type = 'bar', $base = '', $x_format = 'raw')
30 {
31  $output = '';
32  $id = 'chart_'.md5($url);
33  $js_by_chart_type = array('bar'=>array('time.min', 'resize.min'), 'line'=>array('time.min', 'resize.min'), 'pie'=>array('pie.min', 'resize.min'));
34  if(empty($base)){
35  $base = $GLOBALS['wwwroot'] . '/modules/chart/';
36  }
37  if($chart_type == 'bar') {
38  $plot = 'jQuery.plot(jQuery("#'.$id.'"), [data],
39  {
40  series: {
41  bars: {
42  show: true,
43  barWidth: .9,
44  fill: 0.9,
45  align: "center"
46  }
47  },';
48  if($x_format == 'date_format_short' || $x_format == 'date_format_veryshort') {
49  $plot .= 'xaxis: {
50  mode: "time",
51  timeformat: "'.$GLOBALS[$x_format].'",
52  timezone: "browser"
53  },';
54  }
55  $plot .= 'grid: {
56  hoverable: true,
57  clickable: true
58  }
59  }
60  );
61 ';
62  } else if($chart_type == 'line') {
63  $plot = 'jQuery.plot(jQuery("#'.$id.'"), [data],
64  {
65  series: {
66  lines: {
67  show: true,
68  },
69  points: {
70  show: true
71  }
72  },';
73  if($x_format == 'date_format_short' || $x_format == 'date_format_veryshort') {
74  $plot .= 'xaxis: {
75  mode: "time",
76  timeformat: "'.$GLOBALS[$x_format].'",
77  timezone: "browser"
78  },';
79  }
80  $plot .= '
81  yaxis: {
82  min: 0
83  },
84  grid: {
85  hoverable: true,
86  clickable: true
87  }
88  }
89  );
90 ';
91  } elseif($chart_type == 'pie') {
92  $plot = '
93  jQuery.plot(jQuery("#'.$id.'"),data,{
94  series: {
95  ' . $chart_type.': {
96  show: true,
97  innerRadius: 0,
98  radius: 0.8,
99  tilt: 1,
100  label: {
101  show: true,
102  radius: 1.0,
103  tilt:0.8,
104  formatter: function(label, series)
105  {
106  return \'<div style="font-size:8pt;text-align:center;padding:2px;color:white;">\' + label + \'<br/>\' + Math.round(series.percent) + \'% (\' + series.data[0][1] + \')</div>\';
107  },
108  background:
109  {
110  opacity: 0.6
111  }
112  },
113  combine: {
114  color: "#999999",
115  threshold: 0.03
116  }
117  }
118  },
119  legend: {
120  show: false
121  },
122  grid: {
123  hoverable: true,
124  clickable: true
125  }
126 });';
127  }
128  if(!empty($plot)) {
129  // return the HTML as a string
130  if(empty($GLOBALS['js_files_pageonly']['jquery.flot.min.js'])) {
131  $output .='<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="' . $GLOBALS['wwwroot_in_admin'] . '/modules/chart/js/excanvas.min.js"></script><![endif]-->
132 ';
133  $GLOBALS['js_files_pageonly']['jquery.flot.min.js'] = $GLOBALS['wwwroot_in_admin'] . '/modules/chart/js/jquery.flot.min.js';
134  }
135  foreach($js_by_chart_type[$chart_type] as $this_js) {
136  $GLOBALS['js_files_pageonly']['jquery.flot_'.$this_js.'.js'] = $GLOBALS['wwwroot_in_admin'] . '/modules/chart/js/jquery.flot.'.$this_js.'.js';
137  }
138  $GLOBALS['js_ready_content_array'][] = '
139 jQuery.ajax({
140  type:"GET",
141  dataType:"json",
142  url:"'.$url.'",
143  success: function(data) {
144  if(window.console) {
145  console.log(data);
146  }
147  '.$plot.'
148  }
149 });';
150  $output .='
151 <div id="'.$id.'" style="height:300px; width:100%"></div>';
152  }
153  return $output;
154 }
155 
if(!defined('IN_PEEL')) get_flot_chart($width, $height, $url, $chart_type= 'bar', $base= '', $x_format= 'raw')
get_flot_chart()
Definition: flot.php:29
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
Definition: chart-data.php:160
$GLOBALS['page_columns_count']
$id
Definition: articles.php:22

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:41:27 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.