0

Short explanation:

I have just installed version 2.15.1 of SVGGraph (the latest at the time of writing). Now when I am setting it up I have the following error pop up:

Error 8 @ line 1331 of APP_ROOT/inc/SVGGraph/SVGGraphGridGraph.php : Undefined index: rgb(0,0,0)`

For reference my code is below (located in the base SVGGraph folder).

<?php

require_once 'SVGGraph.php';
$graph = new SVGGraph(400, 300, array('namespace' => true));

$graph->Values(1, 4, 8, 9, 16, 25, 27); 
$output = $graph->fetch('LineGraph');

And this is lines 1319 - 1350 in SVGGraphGridGraph.

if($this->show_divisions) {
  // use an array to join paths with same colour
  $div_paths = array();
  if($this->show_axis_h) {
    $points = $this->GetGridPointsX(0);
    $dx_path = $this->XAxisDivisions($points,
      $this->GetFirst($this->division_style_h, $this->division_style), 
      $this->GetFirst($this->division_size_h, $this->division_size),
      $yoff);
    if(!empty($dx_path)) {
      $dx_colour = $this->GetFirst($this->division_colour_h,
        $this->division_colour, $this->axis_colour);
      @$div_paths[$dx_colour] .= $dx_path;           //          <== Line 1331 <==
    }
  }
  if($this->show_axis_v) {
    for($i = 0; $i < $y_count; ++$i) {
      if(!is_null($this->y_axes[$i])) {
        $points = $this->GetGridPointsY($i);
        $dy_path = $this->YAxisDivisions($points,
          $i > 0 ? $this->g_width : $xoff, false, $i);
        if(!empty($dy_path)) {
          $dy_colour = $this->GetFirst(
            $this->ArrayOption($this->division_colour_v, $i),
            $this->division_colour,
            $this->ArrayOption($this->axis_colour_v, $i),
            $this->axis_colour);
          @$div_paths[$dy_colour] .= $dy_path;
        }
      }
    }
  }

Thats is. Nice and simple. Has anyone come across this error and do they have any idea how to fix it?

And for the record if I echo out $output, the graph displays fine. I dont know if that helps or not.

Jack
  • 11
  • 1
  • 7

1 Answers1

0

Below is an email from the SVGGraph author:

A quick look at line 1331 of SVGGraphGridGraph tells me roughly what the problem is:

      @$div_paths[$dx_colour] .= $dx_path;

The error message should be suppressed by the "@" sign at the start of the line, so I'm not sure why you are seeing it. Are you using something other than normal PHP? Or do you have an extension installed that disables the "@" operator?

The "@" operator is used here (and in other places) to prevent having to make the expression more complicated. Without the "@" it would look more like this:

      $div_paths[$dx_colour] = isset($div_paths[$dx_colour]) ? $div_paths[$dx_colour] . $dx_path : $dx_path;

I don't think I have used it in too many places, so it wouldn't be too much trouble to change SVGGraph to do things the long way.

Jack
  • 11
  • 1
  • 7