/[drupal]/contributions/modules/drawing/modules/drawing_graph/drawing_graph.module
ViewVC logotype

Diff of /contributions/modules/drawing/modules/drawing_graph/drawing_graph.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.1, Tue Apr 7 01:43:19 2009 UTC revision 1.1.2.2, Fri Apr 24 09:13:01 2009 UTC
# Line 85  function drawing_graph_stackbar($chart, Line 85  function drawing_graph_stackbar($chart,
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,
# Line 103  function drawing_graph_canvas($config) { Line 103  function drawing_graph_canvas($config) {
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,
# Line 128  function drawing_graph_build_axislabels( Line 128  function drawing_graph_build_axislabels(
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',
# Line 152  function drawing_graph_xtics($chart, $co Line 152  function drawing_graph_xtics($chart, $co
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,
# Line 174  function drawing_graph_ytics($chart, $co Line 174  function drawing_graph_ytics($chart, $co
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,
# Line 188  function drawing_graph_ytics($chart, $co Line 188  function drawing_graph_ytics($chart, $co
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,
# Line 227  function drawing_graph_build_labels($poi Line 227  function drawing_graph_build_labels($poi
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],
# Line 241  function drawing_graph_build_labels($poi Line 241  function drawing_graph_build_labels($poi
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,
# Line 270  function _drawing_graph_build_bar_plot($ Line 270  function _drawing_graph_build_bar_plot($
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,
# Line 285  function _drawing_graph_build_bar_plot($ Line 285  function _drawing_graph_build_bar_plot($
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) {
# Line 301  function drawing_graph_build_dot_plot($p Line 301  function drawing_graph_build_dot_plot($p
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,
# Line 320  function drawing_graph_build_dot_plot($p Line 320  function drawing_graph_build_dot_plot($p
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(
# Line 368  function _drawing_graph_build_pie_chart( Line 368  function _drawing_graph_build_pie_chart(
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],
# Line 378  function _drawing_graph_build_pie_chart( Line 378  function _drawing_graph_build_pie_chart(
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],
# Line 409  function drawing_graph_crd($crds) { Line 409  function drawing_graph_crd($crds) {
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      );      );
# Line 432  function _drawing_graph_build_stackbar($ Line 432  function _drawing_graph_build_stackbar($
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,

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

  ViewVC Help
Powered by ViewVC 1.1.2