Hi all,
first of all thanks a lot for the Charts module.

From the supplied 7.x-2.0-beta5 examples I managed to get a simple line chart using the following content of a node (PHP input format, configured for Google charts, continuous x-axis)

<p>Sample node content for a line chart using "Charts module" 7.x-2.0-beta5</p>
<?php
  $chart = array(
    '#type' => 'chart',
    '#chart_type' => 'line',
    '#title' => t('my first line chart'),
    '#legend_position' => 'bottom',
  );
  $chart['line'] = array(
    '#type' => 'chart_data',
    '#chart_type' => 'line',
    '#data' => array(array(1,7), array(2,44), array(7,66),array(7.4,88),array(8.1,33), array(9,100.5) ) ,
    '#title' => t('my line 1'),
    '#target_axis' => 'yaxis',
    '#color' => $secondary_color,
  );
  $chart['xaxis'] = array(
    '#type' => 'chart_xaxis',
  );
  $chart['yaxis'] = array(
    '#type' => 'chart_yaxis',
    '#axis_type' => 'linear',
  );
  print drupal_render($chart);
?>
<p>after the PHP block</p>

Now I'd like to add a second line and can't figure out how and where to specify it. The second line should not necessarily have to have the same x-values, nor the same amount of data points, e.g. like
array(array(1.5, 12), array(2.8, 18), array(7, 43),array(7.9, 52) )

May I kindly ask for some advice?
Thanks,
Richard.
(volunteering to contribute the solution to the modules' documentation (once it works))

Comments

richardmetzger’s picture

my oh my - sometimes it is easier than originally thought. Here is the solution:

<p>Sample node content for a line chart using "Charts module" 7.x-2.0-beta5</p>
<?php
echo "<p>sample text echoed by PHP</p>";
  $chart = array(
    '#type' => 'chart',
    '#chart_type' => 'line',
    '#title' => t('my first line chart'),
    '#legend_position' => 'bottom',
  );
  $chart['line1'] = array(
    '#type' => 'chart_data',
    '#data' => array(array(1,7), array(2,44), array(7,66),array(7.4,88),array(8.1,33), array(9,100.5) ) ,
    '#title' => t('my line 1'),
    '#color' => '#B617E5',
  );
  $chart['line2'] = array(
    '#type' => 'chart_data',
    '#data' => array(array(1.5, 12), array(2.8, 74), array(7, 43),array(7.9, 52) ),
    '#title' => t('my line 2'),
    '#color' => '#B6FFE5',
  );
  $chart['xaxis'] = array(
    '#type' => 'chart_xaxis',
  );
  $chart['yaxis'] = array(
    '#type' => 'chart_yaxis',
    '#axis_type' => 'linear',
  );
  print drupal_render($chart);
?>
<p>after the PHP block</p>
richardmetzger’s picture

Status: Active » Closed (works as designed)

Closed, problem solved (see comment)