我正在尝试使用图表创建条形图,这是一个使用谷歌图表工具的 drupal 模块。
我不知道如何在栏下放置标签。标签应该是“a”、“b”等。出于某种原因,只有第一个标签“a”显示在 x 轴上,并且它的直线显示在图形的中心。这是我的代码:
$chart = array(
'#chart_id' => 'test_chart2',
'#title' => chart_title(t('Bar Chart'), '0000ee', 15),
'#type' => CHART_TYPE_BAR_V_GROUPED,
'#size' => chart_size(400, 200),
'#grid_lines' => chart_grid_lines(10, 10),
'#bar_size' => chart_bar_size(25, 5),
);
$chart['#data'][] = array(10);
$chart['#data'][] = array(20);
$chart['#data'][] = array(30);
$chart['#data'][] = array(40);
$chart['#data'][] = array(50);
$chart['#data'][] = array(60);
$chart['#data'][] = array(70);
$chart['#data'][] = array(80);
$chart['#data_colors'][] = chart_unique_color('test_a');
$chart['#data_colors'][] = chart_unique_color('test_b');
$chart['#data_colors'][] = chart_unique_color('test_c');
$chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][0][] = chart_mixed_axis_range_label(0, 200);
$chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][3][] = chart_mixed_axis_label(t('Hours'), 95);
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][4][] = chart_mixed_axis_label(t('a'));
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][5][] = chart_mixed_axis_label(t('b'));
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][6][] = chart_mixed_axis_label(t('c'));
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][7][] = chart_mixed_axis_label(t('d'));
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][8][] = chart_mixed_axis_label(t('e'));
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][9][] = chart_mixed_axis_label(t('f'));
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][10][] = chart_mixed_axis_label(t('g'));
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][11][] = chart_mixed_axis_label(t('h'));
return chart_render($chart);