Forum Replies Created by StefanA

Viewing 7 posts - 1 through 7 (of 7 total)
  • in reply to: Graph a CSV file #8692

    Ok, I will try to run the code via a server. Thanks for your help.
    // Stefan

    in reply to: Graph a CSV file #8675

    Hello,
    CSV file pasted from notepad

    11/06/2014,5992
    12/06/2014,6341
    13/06/2014,6653

    in reply to: Graph a CSV file #8669

    This is really annoying. The csv chart seems so work for everybody but me. I must be really stupid. All i get is a blank web page. Can someone please help me figure it out?

    screencap of html source
    > screencap of csv
    screencap of folder

    in reply to: Graph a CSV file #8613

    I can’t get the code from reply #8604 to work. Trying to run the code locally/offline on my PC but no chart is drawn.

    in reply to: Graph a CSV file #8607

    I downloaded jquery-2.1.1.js core and put it in the same folder as the rest of the documents. Can I now simply copy your code above into a html document and run it in my browser and it will produce a chart based on my csv file?

    in reply to: Graph a CSV file #8600

    Hi,
    You must excuse my lack of knowledge when it comes to these things. What is the console? This is the code I trying to use:

    
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript" src="jquery.canvasjs.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function () {
    
    	$.ajax({
    		type: "GET",
    		url:"logg.csv",
    		dataType: "text",
    		success: function(data) {processData(data);}
    	});
    
    	function processData( allText ) {
    		var allLinesArray = allText.split("\n");
    		if( allLinesArray.length > 0 ){
    			var dataPoints = [];
    			for (var i = 0; i <= allLinesArray.length-1; i++) {
    				var rowData = allLinesArray[i].split(",");
    				dataPoints.push({ label:rowData[0], y:parseInt(rowData[1]) });
    			}
    			drawChart(dataPoints);
    		}
    	}
    
    	function drawChart( dataPoints) {
    		var chart = new CanvasJS.Chart("chartContainer", {
    			title:{
    				text: "ID"
    			},
    			axisX:{
    				labelAngle: 0,
    				labelWrap:true,
    				labelAutoFit: false,
    				labelFontSize: 15,
    				labelMaxWidth: 200,
    				labelFontColor: "black"
    			},
    			data: [
    			{
    				indexLabelPlacement: "outside",
    				indexLabelFontWeight: "bold",
    				indexLabelFontColor: "black",
    				type: "column",
    				dataPoints: dataPoints
    			}
    			]
    		});
    		chart.render();
    	}
    });
    </script>
    <script type="text/javascript" src="canvasjs.min.js"></script>
    </head>
    <body>
        <div id="chartContainer" style="height: 300px; width: 100%;">
        </div><center><b>This a test text</b></center>
    </body>
    </html>
    

    My csv file called logg.csv looks like this:
    2015-04-03,10:00,239
    2015-04-03,12:00,304
    2015-04-03,14:00,256
    2015-04-03,16:00,301

    in reply to: Graph a CSV file #8580

    Hello,
    I’m also trying to chart a csv file. Since I have no experience of javascript programming I simply copy the example code in this post and hoped for the best :)

    I must however do something fundamentally wrong since no chart is visible on my html page.

    I have a html page with with code from replay #8498. A data2.csv file and the jquery.canvasjs.min.js and canvasjs.min.js together in the same folder. Can you tell me what I have missed?

    Best Regards
    Stefan

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