Forum Replies Created by pieter

Viewing 3 posts - 1 through 3 (of 3 total)
  • in reply to: How to create a line Graph with two lines #15516

    Hi Bivek,

    Okay, I tried a bit:

            <script type="text/javascript">
     
                $(function () {
                      
                    var chart = new CanvasJS.Chart("chartContainer", {
                        theme: "theme2",
                        zoomEnabled: true,
                        animationEnabled: true,
                        title: {
                            text: "Historical Population Graph:" 
                        },
                        subtitles:[
                            {   text: "(Try Zooming & Panning)" }
                        ],
                        data: [
                        {
                            type: "line",                
                              
                            dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK);?>
                            
                        
                        
                        },
                        
                        {       
                        type: "line",
                                 dataPoints: <?php echo json_encode($dataPoints2, JSON_NUMERIC_CHECK);?>
                                 
                        }
                        ]
                        
                    });
                    chart.render();
                });
            </script>

    This code doesnt work yet. It still works for graphs with one line. If I put the “[]” parentheses around each dataPoints (as done in the example), the code isnt working for one line graphs.

    in reply to: How to create a line Graph with two lines #15497

    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 7 years, 4 months ago by pieter.
    in reply to: Pie charts cut off legends when space is taller #15489

    Hello Hannah,
    Sorry I do not have the answer for your question, but can you please say how you start a thread? Yeah it sounds banal and simple but I do not see the button where to make a thread, and I like to make a thread on this forum as I have a question.

    Thanks for answering

Viewing 3 posts - 1 through 3 (of 3 total)