No graph data points and NULL

kefo - May 31, 2008 - 07:50
Project:Chart API
Version:5.x-1.2
Component:Code
Category:task
Priority:minor
Assigned:tjholowaychuk
Status:needs review
Description

There is difference between NULL and 'NULL' values. Why is used placeholder 'NULL' on the row 366 in chart.module?
if ($v != 'NULL'){

If this module is used as API, it would be usefull naturaly represent no graph data points with NULL and then with -1

#1

tjholowaychuk - June 2, 2008 - 14:47
Priority:normal» minor
Assigned to:Anonymous» tjholowaychuk
Status:active» postponed

Im aware of this, to be honest I do not remember why I chose to go with a string. Certainly not a big issue and I would agree that this could most likely be changed.

#2

Vote_Sizing_Steve - December 1, 2008 - 01:22

I'm wrestling with what might be this issue. If I use the sample on the google wiki page http://code.google.com/p/drupal-chart-api/wiki/Examples, but lower the y values of some points to 0:

$chart = array(
      '#chart_id' => 'test_chart',
      '#title' => chart_title(t('Servings'), 'cc0000', 15),
      '#type' => CHART_TYPE_LINE,
      '#size' => chart_size(400, 200),
      '#adjust_resolution' => TRUE,
    );
   
  $chart['#data']['fruits'] = array(1, 0, 5, 4, 2);
  $chart['#data']['meats']  = array(2, 2, 4, 3, 1);
  $chart['#data']['dairy']  = array(5, 2, 3, 1, 0);

  $chart['#legends'][] = t('Fruits');
  $chart['#legends'][] = t('Meats');
  $chart['#legends'][] = t('Dairy');

  $chart['#data_colors'][] = '00ff00';
  $chart['#data_colors'][] = 'ff0000';
  $chart['#data_colors'][] = '0000ff';

  $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][0][] = chart_mixed_axis_range_label(0, 5);
  $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][1][] = chart_mixed_axis_label(t('Count'), 95);
 
  $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] = chart_mixed_axis_label(t('Mon'));
  $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] = chart_mixed_axis_label(t('Tue'));
  $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] = chart_mixed_axis_label(t('Wed'));
  $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] = chart_mixed_axis_label(t('Thu')); 
  $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] = chart_mixed_axis_label(t('Fri'));
  $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][2][] = chart_mixed_axis_label(t('Days of the week'), 50);

  echo chart_render($chart);

... the connecting lines disappear (see attachment). Is there a setting somewhere I've set wrong, or is this a bug?

AttachmentSize
Chart tester.png 13.82 KB

#3

tjholowaychuk - December 3, 2008 - 16:51

I cannot confirm at the moment, but I believe that was how google renders the nil values. Will have to take a look

#4

Vote_Sizing_Steve - December 12, 2008 - 23:07

Here's the work-around I wrote, which seems to work:

function Google_Chart_x( $y =0, $Max_y =0 ){
  return(
    ( 98 * $y / $Max_y ) + 1 ) ; }

#5

sivaji - January 13, 2009 - 18:44

there is a bug in char module code, whenever the $chart['#data']['fruits'][$i] = 0 value -1 is returned.

it works after applying this patch http://drupal.org/files/issues/chart.module.patch

#6

toemaz - February 16, 2009 - 14:23
Status:postponed» needs review

Patch applied and it worked for me. Thx.

 
 

Drupal is a registered trademark of Dries Buytaert.