Helper Functions are available to simplify building and/or modifying the Chart API Array structure. Below is a list of all Helper Functions available in the Chart module.

chart_title($title, $color = '000000', $size = 14);

Here is an example of using this Helper Function:

$chart = array(
      '#chart_id' => 'test_chart',
      '#title' => chart_title(t('Bar Chart'), '0000ee', 15),
      '#type' => CHART_TYPE_BAR_V,
      '#size' => chart_size(400, 200),
      '#grid_lines' => chart_grid_lines(30, 15),
      '#bar_size' => chart_bar_size(15, 5), 
    );
chart_size($width, $height);

Here is an example of using this Helper Function:

$chart = array(
      '#chart_id' => 'demo_chart',
      '#type' => CHART_TYPE_BAR_H_GROUPED,
      '#size' => chart_size(60, 100),
      '#bar_size' => chart_bar_size(13, 2),
      '#adjust_resolution' => TRUE, 
    );
chart_bar_size($size = 40, $spacing = 20);

Here is an example of using this Helper Function:

$chart = array(
      '#chart_id' => 'demo_chart',
      '#type' => CHART_TYPE_BAR_H_GROUPED,
      '#size' => chart_size(60, 100),
      '#bar_size' => chart_bar_size(13, 2),
      '#adjust_resolution' => TRUE, 
    );
chart_data_colors($colors);

$chart = array(
      '#theme' => 'chart',
      '#chart_id' => 'test_chart',
      '#title' => t('chart test grid'),
      '#type' => CHART_TYPE_SCATTER,
      '#grid_lines' => $grid,
      '#chart_fill' => chart_fill('c', 'eeeeee'),
      '#data_colors' => chart_data_colors(array('184AE0', 'cc0000')),
);
chart_line_style($line_thickness = 1, $segment_length = 1, $blank_segment_length = 0);

An example of using this Helper Function is still missing ... add one now

chart_grid_lines($x_step, $y_step, $segment_length = 1, $blank_segment_length = 1);

Here is an example of using this Helper Function:

$chart = array(
      '#chart_id' => 'test_chart',
      '#title' => chart_title(t('Bar Chart'), '0000ee', 15),
      '#type' => CHART_TYPE_BAR_V,
      '#size' => chart_size(400, 200),
      '#grid_lines' => chart_grid_lines(30, 15),
      '#bar_size' => chart_bar_size(15, 5), 
    );
chart_shape_marker($index = 0, $point = 1, $type = 'o', $size = 20, $color = '000000');

$grid = array(50, 50, 1, 1);
      
$chart = array(
      '#theme' => 'chart',
      '#chart_id' => 'test_chart',
      '#title' => t('chart test grid'),
      '#type' => CHART_TYPE_SCATTER,
      '#grid_lines' => $grid,
      '#shape_markers' => array(chart_shape_marker( 1, 2,CHART_MARKER_X,35,'cc0000')),
    );
chart_range_marker($start, $end, $virtical = TRUE, $color = '000000');

An example of using this Helper Function is still missing ... add one now

chart_fill($type = 'c', $color = '000000');
$grid = array(50, 50, 1, 1);
$chart = array(
      '#theme' => 'chart',
      '#chart_id' => 'test_chart',
      '#title' => t('chart test grid'),
      '#type' => CHART_TYPE_SCATTER,
      '#grid_lines' => $grid,
      '#chart_fill' => chart_fill('c', 'eeeeee'), 
);
chart_linear_gradient($type = 'c', $color = '000000', $offset = 0);
...
chart_linear_stripes($type = 'c', $color = '000000', $angle = 0, $width = 0.25);
...
chart_unique_color($content_id, $scheme = 'default');
Creates and returns a unique color per $content_id. Making it easy to distinguish between dynamic data sets where you may not manually enter colors. When color is associated to the $content_id passed, for example array('Error' => 'ff0000') then that color will be assigned.
chart_mixed_axis_label($label, $position = NULL);
$chart = array(
      '#theme' => 'chart',
      '#chart_id' => 'test_chart',
      '#title' => t('chart test grid'),
      '#type' => CHART_TYPE_SCATTER,
      '#grid_lines' => $mygrid,
      '#chart_fill' => chart_fill('c', 'eeeeee'),
      '#mixed_axis_label_styles' => array(chart_mixed_axis_label_style(0, '468847', '20'),),
      
);
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][0][] = chart_mixed_axis_label(t('my label is on the bottom'));
   
chart_mixed_axis_range_label($start, $end);
...
chart_mixed_axis_style($index, $color, $font_size = 12, $alignment = CHART_ALIGN_CENTER);

An example of using this Helper Function is still missing ... add one now

Use cases

Here are some sample requests to illustrate some use cases for using some of these helper functions:

chart_size
chart_fill
chart_shape_marker
Add more such topics here if you find any
And some details about that them ...

Note (1): This documentation is now an enhanced version of what used to be at Utility Functions. That content over there has been integrated entirely now, and shouldn't contain anymore info that is not around here ....

Note (2): Feel free to further refine this page ... use the button here to do so ... edit