After using example from http://code.google.com/p/drupal-chart-api/wiki/Examples I've got error's
Notice: Undefined index: chts in _chart_append() (line 513 of C:\xampp\htdocs\drupal\sites\all\modules\chart\chart.module).
Notice: Undefined index: chxl in _chart_append() (line 639 of C:\xampp\htdocs\drupal\sites\all\modules\chart\chart.module).
Notice: Undefined index: chxp in _chart_append() (line 659 of C:\xampp\htdocs\drupal\sites\all\modules\chart\chart.module).
Notice: Undefined index: set in _chart_append() (line 658 of C:\xampp\htdocs\drupal\sites\all\modules\chart\chart.module).
$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, 3, 5, 4, 2);
$chart['#data']['meats'] = array(2, 2, 4, 3, 1);
$chart['#data']['dairy'] = array(5, 2, 3, 1, 2);
$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 theme('chart', array('chart' => $chart));
Comments
Comment #1
Itex commentedComment #2
ununpentium commentedI, too, get this same list of errors when using the line chart example.
Comment #3
leszek.hanusz commentedsubscribing
Comment #4
SebCorbin commentedSame thing here
Comment #5
maulik.kamdar commentedHello,
I had faced similar problems when I was trying to append the Axis Labels using Chart Views.
You might wish to review the patch I had uploaded for the issue #1206306: Setting Chart Axes, Gridlines and Axis Labels in Chart using Views Plugin. It allows a user to set Axis Labels (value Range and custom Field) for Line and Bar Charts. I had made minor modifications in the Chart API for the same, as below:
I donot know if these are correct (Patch has just been uploaded for review), but it worked out pretty splendid for me.
Thanks.
Comment #6
Konstantin Komelin commentedsubscribing
Comment #7
levelos commentedHere's a patch for 7.x-1.0
Comment #8
defconjuan commentedApplied patch and still getting error. (I validated that the updates in the patch file were implemented and flushed all caches.)
Comment #9
nkschaefer commentedI looked at it - "chts" is how the Google Chart API defines the style of the chart title. If we wanted to make this fancier, we could add a property in the user-defined chart array called '#title_style' or something and come up with a default value. That would go in chart_build() -- define a default value and then later add a line that does something like _chart_append('chts', $chart['#title_style']), $data);
This seems complicated, though, and I don't know too much about how this was designed. So instead, I just changed line 513 to set chts initially, instead of trying to append to it. In other words, I deleted the dot in front of the equals sign. That fixed it.
Here's a patch that does that. I think that's all we need here.
Comment #10
nkschaefer commentedOops. I had clicked here from another issue - I should clarify that my patch only addresses the "undefined index: chts" error. That's the only one I was getting.
Comment #11
nodestroy commented#7 works for me
Comment #12
ximo commentedHere's a hotfix patch for 7.x-1.0. It's similar to #7, with an added fix for the same error on $data['chxr'] and $data['chxp'].
Comment #13
13rac1 commentedI used one change in #7, and then applied additional isset() checks for everything else. Now the chart code above works w/o notices. Isset() is the method used in the rest of the module. The 7.x-1.x-dev patch of changes is attached, if needed in 6.x.