I want to create a line chart displaying changes in share price over the time using Drupal Charts 7.x-2.0-rc1 API and Google Charts as a library. I tried the following code and populated the chart with some random values:
$chart = array(
'#type' => 'chart',
'#chart_type' => 'line',
'#chart_library' => 'google',
'#title' => t(''),
'#legend' => FALSE,
'#colors' => array('FF6600'),
'#width' => 480,
'#height' => 240,
'#data_labels' => TRUE,
'#raw_options' => array(
'vAxis' => array(
'viewWindowMode' => 'explicit',
'viewWindow' => array(
'min' => 1,
),
),
'hAxis' => array(
'showTextEvery' => 20
)
),
);
$data = array();
for ($i = 0; $i < 100; $i++) {
$data[$i] = array(date('H:i', strtotime("+$i minute")), (rand(5, 10) / 10) * 6);
}
$chart['price'] = array(
'#type' => 'chart_data',
'#title' => t('Share price'),
'#show_in_legend' => FALSE,
'#data' => $data,
'#decimal_count' => 2,
);
$shareChart['chart'] = $chart;
return drupal_render($shareChart);
I get the following output: chart
I want the x axis to display only cerain labels (in this example interval of 20 minutes) but 'showTextEvery' option doesn't work. Any ideas why? Maybe there is another way to achive that?