Home forums Using CanvasJS How to create a line Graph with two lines Reply To: How to create a line Graph with two lines

#15497

pieter
Member

I thought I add some code, which is above the code given above.

  $dataPoints = array();
        $y = 40;
        for($i = $sy; $i <= $ey; $i++){
            $y += rand(0, 10) - 5; 
            array_push($dataPoints, array("x" => $i, "y" => $_SESSION["{$var}"][$i-$sy]));
        }
        
    if ($var=="bd")
    {
      $dataPoints = array();
        $y = 40;
        for($i = $sy; $i <= $ey; $i++){
            $y += rand(0, 10) - 5; 
            array_push($dataPoints, array("x" => $i, "y" => $_SESSION["{$br}"][$i-$sy]));
        }
        
      $dataPoints2 = array();
              $y = 40;
        for($i = $sy; $i <= $ey; $i++){
            $y += rand(0, 10) - 5; 
            array_push($dataPoints2, array("x" => $i, "y" => $_SESSION["{$dr}"][$i-$sy]));
        }
    }
    ?>

Here I fill dataPoints2. As mentioned in the OP, the code works fine for one line graphs (so if var is NOT “bd”).

  • This reply was modified 1 month, 2 weeks ago by  pieter.