[Graph-dev] arbitrary number of data series

Ollie Cook ollie at uk.clara.net
Fri Jan 2 12:58:35 PST 2004


Hi,

I am having some trouble using Chart::Graph::Gnuplot when wanting to plot
a variable number of data series on the same graph.

Based on various configuration options, data is retrieved from an SQL database.
This data is massaged into an array of 'data set elements'
([\%data_set_options, \@matrix]), each element representing a data series.

The number of data series depends on the number of columns returned by the SQL
query.

The following example shows the contents of this array, with three series each
containing two data points (for demonstration purposes):

$VAR1 = [
          [
            {
              'type' => 'matrix',
              'title' => 'Total'
            },
            [
              '2003-02-19',
              100852
            ],
            [
              '2003-02-20',
              528988
            ]
          ],
          [
            {
              'type' => 'matrix',
              'title' => 'External SMTP'
            },
            [
              '2003-02-19',
              89759
            ],
            [
              '2003-02-20',
              465174
            ]
          ],
          [
            {
              'type' => 'matrix',
              'title' => 'Internal Reinjections'
            },
            [
              '2003-02-19',
              11093
            ],
            [
              '2003-02-20',
              63814
            ]
          ]
        ];

I was then hoping to be able to call gnuplot like:

  gnuplot($options, $all_series);

where $options is a hashref and $options is an arrayref to the prepared array.

However, gnuplot reports the following error when used like that:

 "Data options must be a hash."

I am guessing this is caused by me passing an arrayref of 'data set elements'
rather than a list of 'data set elements'. Is that correct?

In any case, I've been unable to find any examples of using
Chart::Graph::Gnuplot with arbitrary numbers of data series. If someone could
point me in the correct direction that would be great.

Thanks,

Ollie

-- 
Oliver Cook    Systems Administrator, Claranet UK
ollie at uk.clara.net                  020 7903 3065


More information about the Graph-dev mailing list