15 if (!defined(
'IN_PEEL')) {
19 if(
vb(
$GLOBALS[
'site_parameters'][
'chart_product']) ==
'plot') {
20 require(
$GLOBALS[
'dirroot'] .
'/modules/chart/plot.php');
22 require(
$GLOBALS[
'dirroot'] .
'/modules/chart/open-flash-chart.php');
42 if(!empty($force_chart_product)) {
43 $chart_product = $force_chart_product;
45 $chart_product =
vb(
$GLOBALS[
'site_parameters'][
'chart_product']);
48 if($chart_product ==
'flot') {
52 $graph->title((str_replace(array(
',',
'&'), array(
'.',
'-'), $title)),
'{font-size:12px; padding:5px}');
54 $graph->pie(80,
'0x505050',
'{font-size: ' .
$legend_font_size .
'px; color: #404040;}');
60 $temp = array_keys(
$data);
61 foreach($temp as $key) {
64 if (str_replace(array(
',',
'&'), array(
'.',
'-'), ($key)) != $key) {
66 $key = str_replace(array(
',',
'&'), array(
'.',
'-'), ($key));
68 if (!empty($value) && !is_array($value) && (!isset(
$data[$key]) || strpos($value,
',') !==
false)) {
70 $data[$key] = str_replace(array(
',',
'&'), array(
'.',
'-'), $value);
76 foreach($temp as $key) {
87 foreach(
$data as $key => $value) {
88 if ($key !=
'Autre') {
89 $data[$key] = round($value /
$total * 100 * 100) / 100;
91 if (empty(
$data[
'Autre'])) {
100 $graph->set_tool_tip(
'#x_label#<br>#val#%');
104 $graph->set_tool_tip(
'#key#<br>#x_label#<br>#val#');
107 foreach(
$data as $data_title => $data_array) {
109 if (!empty($data_array)) {
110 foreach($data_array as $value) {
111 $value = floatval($value);
112 if ($value > $max_all_data) {
113 $max_all_data = $value;
117 if (!empty($data_array)) {
118 foreach($data_array as $value) {
119 $value = floatval($value);
120 if ($value < $min_all_data) {
121 $min_all_data = $value;
126 if (!empty(
$colors[($data_title)])) {
127 $color =
$colors[($data_title)];
128 }
elseif ($data_title ==
'FALSE') {
130 }
elseif ($data_title ==
'TRUE') {
132 }
elseif ($data_title ==
'DESACTIVATED') {
134 }
elseif ($data_title ==
'F') {
136 }
elseif ($data_title ==
'H') {
139 $r = base_convert(base_convert(
String::substr(md5($data_title), 0, 4), 16, 10) % 15, 10, 16);
140 $g = base_convert(base_convert(
String::substr(md5($data_title), 5, 4), 16, 10) % 15, 10, 16);
141 $b = base_convert(base_convert(
String::substr(md5($data_title), 9, 4), 16, 10) % 15, 10, 16);
145 if($chart_product ==
'flot') {
147 foreach($data_array as $x => $y) {
148 $bar_data[] = array($x, $y);
151 $output .= json_encode($bar_data);
153 $graph->set_data($data_array);
154 $graph->bar(80,
'0x' . $color, $data_title);
157 if($chart_product ==
'flot') {
158 $output .= json_encode($points_data_array);
161 foreach($data_array as $x => $y) {
162 $points_data_array[] =
new point(
$i, round($y), 6);
165 $graph->scatter($points_data_array, 2,
'#' . $color, $data_title, 10);
166 unset($points_data_array);
169 $pie_slice_colours[] =
'#' . $color;
171 if($chart_product ==
'flot') {
172 $output .= json_encode($data_array);
174 $graph->set_data($data_array);
175 $graph->line(2,
'0x' . $color, $data_title, 10);
179 if($chart_product ==
'flot') {
182 foreach($data_array as $x => $y) {
183 $line_data[] = array($x, $y);
186 $output .= json_encode($line_data);
188 $graph->set_data($data_array);
189 $graph->line_dot(2, 4,
'0x' . $color, $data_title, 10);
193 $x_array = array_keys($data_array);
197 $max_y = round($max_all_data);
198 if (!empty($min_all_data)) {
199 $max_y = $max_y * 1.2;
202 $max_y_base = pow(10, floor(log10(abs($max_y)))-1);
203 $max_y = round($max_y / $max_y_base) * $max_y_base;
205 $min_y = round($min_all_data * 1.2);
206 if (!empty($min_y)) {
207 $min_y_base = pow(10, floor(log10(abs($min_y)))-1);
208 $min_y = round($min_y / $min_y_base) * $min_y_base;
211 if (!empty($min_y)) {
212 if (- $min_y < $max_y * 1.3 && - $min_y > $max_y * 0.7) {
214 }
elseif (- $min_y < $max_y * 0.1) {
215 $max_y = 9 * $max_y / 10;
216 $min_y = - $max_y / 9;
217 }
elseif (- $min_y < $max_y * 0.2) {
218 $max_y = 8 * $max_y / 10;
219 $min_y = -2 * $max_y / 8;
222 if($chart_product ==
'flot') {
224 $graph->set_y_max($max_y);
225 $graph->set_y_min($min_y);
226 $graph->y_label_steps(10);
228 $graph->set_x_labels($x_array);
229 $steps = round(count($x_array) * 9 * strlen(current($x_array)) / ($width-30));
230 $graph->set_x_label_style(10,
'0x000000', 0, $steps);
233 if($chart_product ==
'flot') {
234 foreach(
$data as $title => $value) {
235 $temp =
new stdClass();
236 $temp->label = $title;
237 $temp->data = intval($value);
241 $output .= json_encode($pie_data);
244 $graph->pie_slice_colours($pie_slice_colours);
247 }
elseif($chart_product ==
'flot') {
251 if($chart_product ==
'flot') {
255 return $graph->render();
foreach(array('date1', 'date2', 'type', 'renewals', 'width') as $item) $data
static strtoupper($string)
Returns string with all alphabetic characters converted to uppercase.
advistoChart(&$data, $title=null, $all_graph_type=null, $graph_type=array(), $colors=array(), $legend_font_size=12, $width=300, $force_chart_product=null)
advistoChart()
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))
$GLOBALS['page_columns_count']
static substr($string, $start, $length=null)
Returns the portion of string specified by the start and length parameters.