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

#15516

pieter
Member

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.