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
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
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?
#3
I cannot confirm at the moment, but I believe that was how google renders the nil values. Will have to take a look
#4
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
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
Patch applied and it worked for me. Thx.