Hello,
I hope this is not a product of my stupidity, but I've smashed my head against this data and it seems like the bar graph is generating the wrong output.
Attached is the dsm($chart) and a printscreen of the output graph. Below is the code I'm using to generate the function. I would really appreciate if you guys could have a look.
Thank you
function aa_custom_accounts_income_chart($year = NULL) {
if (!$year) {
$year = date('Y');
}
$chart = array(
'#chart_id' => 'accounts_main_chart',
'#title' => chart_title('Income in EUR'),
'#type' => CHART_TYPE_BAR_V_GROUPED,
'#size' => chart_size(700, 200),
'#grid_lines' => chart_grid_lines(30, 15),
'#bar_size' => chart_bar_size(15, 5),
);
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1]['Jan'] = chart_mixed_axis_label(t('Jan'));
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1]['Feb'] = chart_mixed_axis_label(t('Feb'));
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1]['Mar'] = chart_mixed_axis_label(t('Mar'));
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1]['Apr'] = chart_mixed_axis_label(t('Apr'));
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1]['May'] = chart_mixed_axis_label(t('May'));
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1]['Jun'] = chart_mixed_axis_label(t('Jun'));
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1]['Jul'] = chart_mixed_axis_label(t('Jul'));
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1]['Aug'] = chart_mixed_axis_label(t('Aug'));
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1]['Sep'] = chart_mixed_axis_label(t('Sep'));
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1]['Oct'] = chart_mixed_axis_label(t('Oct'));
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1]['Nov'] = chart_mixed_axis_label(t('Nov'));
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1]['Dec'] = chart_mixed_axis_label(t('Dec'));
$chart['#data']['billed'] = array(0,0,0,0,0,0,0,0,0,0,0,0);
$chart['#data']['paid'] = array(0,0,0,0,0,0,0,0,0,0,0,0);
$chart['#data_colors']['billed'] = chart_unique_color('test_a');
$chart['#data_colors']['paid'] = chart_unique_color('test_b');
$chart['#legends']['billed'] = t('Billed');
$chart['#legends']['paid'] = t('Paid');
$max_y = 0;
$view = views_get_view('income_by_date');
$args = array('2011', 'EUR');
$view->preview('default', $args);
foreach($view->result as $result) {
$month = date('n', $result->node_created) - 1;
$status = $result->field_field_invoice_status[0]['raw']['value'];
$chart['#data'][$status][$month] += $result->field_field_invoice_total[0]['raw']['value'];
if($chart['#data'][$status][$month] > $max_y) {
$max_y = $chart['#data'][$status][$month];
}
}
$chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][0][] = chart_mixed_axis_range_label(0, $max_y);
dsm($chart);
return theme('chart', array('chart' => $chart));
}
Comments
Comment #1
13rac1 commentedI see that the chart looks wrong, but I don't have the time to fully debug your code and determine exactly what is wrong. Can you be more specific? What exactly is wrong?
Comment #2
13rac1 commentedNo response after six weeks. Please re-open if needed.