Home Forums Chart Support Need help with JSON

Need help with JSON

Viewing 3 posts - 1 through 3 (of 3 total)
  • #8404

    http://www.fyrobe-club-sisseln.ch/labor2/parse_text_files_retentions.php

    The JSON above shall be convertet into a CanvasJS graph, i already tried the following:

    
    $.getJSON( 'parse_text_files_retentions.php', function( data ){
    
    			var chart = new CanvasJS.Chart("chartContainer", {
    				title :{
          					text: "Retention"
          				},
          				axisX: {						
          					title: "Retention time"
          				},
          				axisY: {						
          					title: "Peak signal"
          				},
    				zoomEnabled: true,
          				panEnabled: true,
                                    data: data
              		});
                            chart.render();
            });
    

    and

    
    $.getJSON( 'parse_text_files_retentions.php', function( data ){
    
    			var chart = new CanvasJS.Chart("chartContainer", {
    				title :{
          					text: "Retention"
          				},
          				axisX: {						
          					title: "Retention time"
          				},
          				axisY: {						
          					title: "Peak signal"
          				},
    				zoomEnabled: true,
          				panEnabled: true
              		});
    
    			for( x=0, y=data.length; x<y; x++ ){
    
    				//Iterate Files
    				chart.options.data[y].type = 'column';
    
    				for( i=0, j=data[y].dataPoints.length; i<j; i++ ){				
    
    					chart.options.data[y].dataPoints.push( { x : data[y].dataPoints[i].x, y : data[y].dataPoints[i].y });
    
    				}
    				
    
    			}
     
              		chart.render();
    			
    
    		});
    

    Both doesn’t work (obviously). I get a blank graph with only the correct axes and title. Where am I wrong with including the data points?

    Thank you very much in advance

    • This topic was modified 9 years, 1 month ago by Nightflyer.
    #8406

    problem solved, the values in the JSON were quotet with “”. Parsing the values with (float) helped :)

    #8411

    How can I add a click-function to a graph after the graph is created?

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

You must be logged in to reply to this topic.