Drupal: unable to set labels for x axis using Charts module -
i want create line chart displaying changes in share price on time using drupal charts 7.x-2.0-rc1 api , google charts library. tried following code , populated chart 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(); ($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 following output: chart
i want x axis display cerain labels (in example interval of 20 minutes) 'showtextevery' option doesn't work. ideas why? maybe there way achive that?
date/time values on haxis result in continuous axis  
'showtextevery' works discrete axis, resulting string values  
as such, need provide own ticks  
maybe try this, generate data, along ticks, first...  
$data = array(); $ticks = array(); $x = 0; ($i = 0; $i < 100; $i++) {     $data[$i] = array(date('h:i', strtotime("+$i minute")), (rand(5, 10) / 10) * 6);     if ($i % 20 == 0) {         $ticks[$x] = date('h:i', strtotime("+$i minute"));         $x++;     } }   then in chart definition...
$chart = array(     'haxis' => array(         'ticks' => $ticks     )      
Comments
Post a Comment