Home Forums Chart Support Graph a CSV file Reply To: Graph a CSV file

#8723

sid
        function processData(allText) {
                var allLinesArray = allText.split('\n');
                if(allLinesArray.length>0){
                        var dataPoints = [];
                        var dataPoints2= [];
                        for (var i = 1; i <= allLinesArray.length-1; i++) {
                                var rowData = allLinesArray[i].split(',');
                                dataPoints.push({label:rowData[0],y:parseInt(rowData[1])});
                        }
                        for (var i = 1; i <= allLinesArray.length-1; i++) {
                                var rowData = allLinesArray[i].split(',');
                                dataPoints2.push({label:rowData[0],y:parseInt(rowData[2])});
                        }
                        drawChart(dataPoints,dataPoints2);
                        

                }
        }

        function drawChart( dataPoints,dataPoints2) {
                var chart = new CanvasJS.Chart("chartContainer", {
                theme: "theme2",
                title:{
                        text: "Gati Chart"
                },
                zoomEnabled:true,
                data: [
                {
                        type: "line",
                        dataPoints: dataPoints
                },
                
                
                {
                        type: "line",
                        dataPoints: dataPoints2
                }]
                });

                chart.render();
        }

I am tring to plot 2 line graphs, using the above code I get 2 line blue for dataPoints and red for daatPoints2.But I am getting a straight line for dataPoints and correct line graph for dataPoints2, can you suggest whats wrong with my code? On hovering the blue line, it gives me correct values in tooltip but why is it coming as a straight line?