I'm not sure why but no matter what I do, there is a margin at the top of the chart that I can't get rid of. I attached an image of the line chart example to show what I mean. The y-axis goes from 0-5 and the highest point on both lines is 5, but the lines only reach about 4.8. I'd say about 10% at the top is not reachable by any line on the chart which means the chart is never accurate.

$chart = array(
      '#chart_id' => 'test_chart',
      '#title' => chart_title(t('Servings'), 'cc0000', 15),
      '#type' => CHART_TYPE_LINE,
      '#size' => chart_size(400, 200),
      '#adjust_resolution' => TRUE,
    );
    
  $chart['#data']['fruits'] = array(1, 3, 5, 4, 2);
  $chart['#data']['meats']  = array(2, 2, 4, 3, 1);
  $chart['#data']['dairy']  = array(5, 2, 3, 1, 2);

  $chart['#legends'][] = t('Fruits');
  $chart['#legends'][] = t('Meats');
  $chart['#legends'][] = t('Dairy');

  $chart['#data_colors'][] = '00ff00';
  $chart['#data_colors'][] = 'ff0000';
  $chart['#data_colors'][] = '0000ff';

  $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][0][] = chart_mixed_axis_range_label(0, 5);
  $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][1][] = chart_mixed_axis_label(t('Count'), 95);
  
  $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] = chart_mixed_axis_label(t('Mon'));
  $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] = chart_mixed_axis_label(t('Tue'));
  $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] = chart_mixed_axis_label(t('Wed'));
  $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] = chart_mixed_axis_label(t('Thu'));  
  $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] = chart_mixed_axis_label(t('Fri'));
  $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][2][] = chart_mixed_axis_label(t('Days of the week'), 50);

$displaychart = theme('chart', array('chart' => $chart));
CommentFileSizeAuthor
chart.png15.72 KBErnestoJaboneta

Comments

13rac1’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.