| 85 |
*/ |
*/ |
| 86 |
function drawing_graph_canvas($config) { |
function drawing_graph_canvas($config) { |
| 87 |
$canvas = array( |
$canvas = array( |
| 88 |
'#type' => 'drawing_canvas', |
'#type' => 'canvas', |
| 89 |
'#width' => isset($config['canvas_width']) ? $config['canvas_width'] : $config['width'], |
'#width' => isset($config['canvas_width']) ? $config['canvas_width'] : $config['width'], |
| 90 |
'#height' => isset($config['canvas_height']) ? $config['canvas_height'] : $config['height'], |
'#height' => isset($config['canvas_height']) ? $config['canvas_height'] : $config['height'], |
| 91 |
); |
); |
| 92 |
$canvas_id = isset($config['canvas_id']) ? $config['canvas_id'] : 'plot'; |
$canvas_id = isset($config['canvas_id']) ? $config['canvas_id'] : 'plot'; |
| 93 |
|
|
| 94 |
$canvas[$canvas_id] = array( |
$canvas[$canvas_id] = array( |
| 95 |
'#type' => 'drawing_group', |
'#type' => 'group', |
| 96 |
'#id' => $canvas_id, |
'#id' => $canvas_id, |
| 97 |
'#stroke' => 'black', |
'#stroke' => 'black', |
| 98 |
'#stroke-width' => 2, |
'#stroke-width' => 2, |
| 103 |
function drawing_graph_build_axislabels($chart, $config) { |
function drawing_graph_build_axislabels($chart, $config) { |
| 104 |
/* legends */ |
/* legends */ |
| 105 |
$canvas['xlabel'] = array( |
$canvas['xlabel'] = array( |
| 106 |
'#type' => 'drawing_text', |
'#type' => 'text', |
| 107 |
'#stroke' => $config['theme']['label'], |
'#stroke' => $config['theme']['label'], |
| 108 |
'#cx' => $config['width']/2, |
'#cx' => $config['width']/2, |
| 109 |
'#cy' => $config['height'] - 20, |
'#cy' => $config['height'] - 20, |
| 110 |
'#value' => $chart['xlabel'], |
'#value' => $chart['xlabel'], |
| 111 |
); |
); |
| 112 |
$canvas['ylabel'] = array( |
$canvas['ylabel'] = array( |
| 113 |
'#type' => 'drawing_text', |
'#type' => 'text', |
| 114 |
'#stroke' => $config['theme']['label'], |
'#stroke' => $config['theme']['label'], |
| 115 |
'#cx' => '0', |
'#cx' => '0', |
| 116 |
'#cy' => $config['height']/2, |
'#cy' => $config['height']/2, |
| 128 |
*/ |
*/ |
| 129 |
function drawing_graph_build_axes($canvas, $chart, $config) { |
function drawing_graph_build_axes($canvas, $chart, $config) { |
| 130 |
$canvas['plot']['axes'] = array( |
$canvas['plot']['axes'] = array( |
| 131 |
'#type' => 'drawing_polyline', |
'#type' => 'polyline', |
| 132 |
'#stroke' => 'black', |
'#stroke' => 'black', |
| 133 |
'#stroke-width' => '2', |
'#stroke-width' => '2', |
| 134 |
'#fill' => 'none', |
'#fill' => 'none', |
| 152 |
for($i = $dx; $i< $config['width'] - 50; $i += $dx) { |
for($i = $dx; $i< $config['width'] - 50; $i += $dx) { |
| 153 |
$cx1 = $i; |
$cx1 = $i; |
| 154 |
$output[] = array( |
$output[] = array( |
| 155 |
'#type' => 'drawing_line', |
'#type' => 'line', |
| 156 |
'#cx1' => $cx1, |
'#cx1' => $cx1, |
| 157 |
'#cy1' => 0, |
'#cy1' => 0, |
| 158 |
'#cx2' => $cx1, |
'#cx2' => $cx1, |
| 174 |
/* |
/* |
| 175 |
for($cy1 = $dy; $cy1 < $config['height']; $cy1 += $dy) { |
for($cy1 = $dy; $cy1 < $config['height']; $cy1 += $dy) { |
| 176 |
$output[] = array( |
$output[] = array( |
| 177 |
'#type' => 'drawing_line', |
'#type' => 'line', |
| 178 |
'#cx1' => -$config['ytics_height']/2, //correction for plotarea shift |
'#cx1' => -$config['ytics_height']/2, //correction for plotarea shift |
| 179 |
'#cx2' => $config['ytics_height']/2, |
'#cx2' => $config['ytics_height']/2, |
| 180 |
'#cy1' => $cy1, |
'#cy1' => $cy1, |
| 188 |
/* |
/* |
| 189 |
for($cy1 = $dy2; $cy1 < $config['height']; $cy1 += $dy2) { |
for($cy1 = $dy2; $cy1 < $config['height']; $cy1 += $dy2) { |
| 190 |
$output['helpers'][] = array( |
$output['helpers'][] = array( |
| 191 |
'#type' => 'drawing_line', |
'#type' => 'line', |
| 192 |
'#cx1' => $config['ytics_height']/2, |
'#cx1' => $config['ytics_height']/2, |
| 193 |
'#cx2' => $config['width'], |
'#cx2' => $config['width'], |
| 194 |
'#cy1' => $cy1, |
'#cy1' => $cy1, |
| 227 |
if(($i%$nth)) { continue; } //only print every nth value, to avoid overcrowding |
if(($i%$nth)) { continue; } //only print every nth value, to avoid overcrowding |
| 228 |
$n++; |
$n++; |
| 229 |
$output[$n]['0'] = array( // numeric order to manipulate rendering order |
$output[$n]['0'] = array( // numeric order to manipulate rendering order |
| 230 |
'#type' => 'drawing_text', |
'#type' => 'text', |
| 231 |
'#cx' => $value[0] + $dx, |
'#cx' => $value[0] + $dx, |
| 232 |
'#cy' => 400 - ($value[1] + $dy), //because of the screw-up transformations |
'#cy' => 400 - ($value[1] + $dy), //because of the screw-up transformations |
| 233 |
'#value' => $value[0] . ', ' . $value[1], |
'#value' => $value[0] . ', ' . $value[1], |
| 241 |
); |
); |
| 242 |
/*$output[$n]['labelbg'] = array(*/ |
/*$output[$n]['labelbg'] = array(*/ |
| 243 |
$output[$n]['1'] = array( |
$output[$n]['1'] = array( |
| 244 |
'#type' => 'drawing_rectangle', |
'#type' => 'rectangle', |
| 245 |
'#cx' => $value[0], |
'#cx' => $value[0], |
| 246 |
'#cy' => $value[1], |
'#cy' => $value[1], |
| 247 |
'#height' => 20, |
'#height' => 20, |
| 270 |
|
|
| 271 |
foreach($points as $value) { |
foreach($points as $value) { |
| 272 |
$output[] = array( |
$output[] = array( |
| 273 |
'#type' => 'drawing_rectangle', |
'#type' => 'rectangle', |
| 274 |
'#fill' => $config['theme']['fill'], |
'#fill' => $config['theme']['fill'], |
| 275 |
'#stroke' => 'none', |
'#stroke' => 'none', |
| 276 |
'#height' => $config['height'] * $value[1]/$ymax, |
'#height' => $config['height'] * $value[1]/$ymax, |
| 285 |
|
|
| 286 |
function _drawing_graph_build_line_plot($points) { |
function _drawing_graph_build_line_plot($points) { |
| 287 |
$output = array( |
$output = array( |
| 288 |
'#type' => 'drawing_polyline', |
'#type' => 'polyline', |
| 289 |
'#fill' => 'none', |
'#fill' => 'none', |
| 290 |
); |
); |
| 291 |
foreach($points as $value) { |
foreach($points as $value) { |
| 301 |
$n = 1; |
$n = 1; |
| 302 |
foreach($points as $value) { |
foreach($points as $value) { |
| 303 |
$output[] = array( |
$output[] = array( |
| 304 |
'#type' => 'drawing_circle', |
'#type' => 'circle', |
| 305 |
'#cx' => $value[0], |
'#cx' => $value[0], |
| 306 |
'#cy' => $value[1], |
'#cy' => $value[1], |
| 307 |
'#r' => 5, |
'#r' => 5, |
| 320 |
*/ |
*/ |
| 321 |
function drawing_graph_build_piechart($canvas, $chart, $config) { |
function drawing_graph_build_piechart($canvas, $chart, $config) { |
| 322 |
$canvas['plot'] = array( |
$canvas['plot'] = array( |
| 323 |
'#type' => 'drawing_group', |
'#type' => 'group', |
| 324 |
'#stroke' => 'black', |
'#stroke' => 'black', |
| 325 |
'#stroke-width' => 2, |
'#stroke-width' => 2, |
| 326 |
'#transform' => array( |
'#transform' => array( |
| 368 |
$L = $A; |
$L = $A; |
| 369 |
|
|
| 370 |
$canvas['plot']['slice_'.$n] = array( |
$canvas['plot']['slice_'.$n] = array( |
| 371 |
'#type' => 'drawing_path', |
'#type' => 'path', |
| 372 |
'#fill' => $theme[$n]['fill'], |
'#fill' => $theme[$n]['fill'], |
| 373 |
'#explicit' => TRUE, |
'#explicit' => TRUE, |
| 374 |
'#points' => $d[$n], |
'#points' => $d[$n], |
| 378 |
$dist = $config['labels']['inside'] ? 2/3 * $r : $r *1.1; |
$dist = $config['labels']['inside'] ? 2/3 * $r : $r *1.1; |
| 379 |
$coordinates = drawing_graph_rad_to_crd($ang - $stepsize/2, $dist); |
$coordinates = drawing_graph_rad_to_crd($ang - $stepsize/2, $dist); |
| 380 |
$canvas['plot']['label_'.$n] = array( |
$canvas['plot']['label_'.$n] = array( |
| 381 |
'#type' => 'drawing_text', |
'#type' => 'text', |
| 382 |
'#value' => $points[0], |
'#value' => $points[0], |
| 383 |
'#cx' => $coordinates[0], |
'#cx' => $coordinates[0], |
| 384 |
'#cy' => $coordinates[1], |
'#cy' => $coordinates[1], |
| 409 |
*/ |
*/ |
| 410 |
function drawing_graph_build_stackbar($canvas, $chart, $config) { |
function drawing_graph_build_stackbar($canvas, $chart, $config) { |
| 411 |
$canvas['plot'] = array( |
$canvas['plot'] = array( |
| 412 |
'#type' => 'drawing_group', |
'#type' => 'group', |
| 413 |
'#stroke' => 'black', |
'#stroke' => 'black', |
| 414 |
'#stroke-width' => 2, |
'#stroke-width' => 2, |
| 415 |
); |
); |
| 432 |
foreach($values as $label => $point) { |
foreach($values as $label => $point) { |
| 433 |
$height = $point/$sum * $config['height']; |
$height = $point/$sum * $config['height']; |
| 434 |
$canvas['plot']['label_'.$n] = array( |
$canvas['plot']['label_'.$n] = array( |
| 435 |
'#type' => 'drawing_text', |
'#type' => 'text', |
| 436 |
'#value' => $label, |
'#value' => $label, |
| 437 |
'#stroke' => 'none', |
'#stroke' => 'none', |
| 438 |
'#cx' => $dist, |
'#cx' => $dist, |
| 439 |
'#cy' => $height_prev + $height/2, |
'#cy' => $height_prev + $height/2, |
| 440 |
); |
); |
| 441 |
$canvas['plot']['stack_'.$n] = array( |
$canvas['plot']['stack_'.$n] = array( |
| 442 |
'#type' => 'drawing_rectangle', |
'#type' => 'rectangle', |
| 443 |
'#fill' => $theme[$n]['fill'], |
'#fill' => $theme[$n]['fill'], |
| 444 |
'#cx' => 0, |
'#cx' => 0, |
| 445 |
'#cy' => $height_prev, |
'#cy' => $height_prev, |