Bonjour a tous, 
Je suis actuellement sur un développement en ASP.net et je n'arrive pas a afficher un chart avec des données JSON 
Voici le code :
Webform1.aspx
	
	| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 
 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
 
<!DOCTYPE html>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head onload="Page_Load" runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
 
     <script type='text/javascript' src='https://www.google.com/jsapi'></script>
    <script type='text/javascript'>
 
        google.load('visualization', '1', { packages: ['corechart', 'bar'] });
        google.setOnLoadCallback(drawBasic);
 
        function drawBasic() {
 
        // Create the data table.
        var data = new google.visualization.DataTable();
        // récupération de la variable dans WebForm1.aspx.cs
        var datarecup = <%=dataserv%>;
        data.addColumn('string', 'Topping');
        data.addColumn('number', 'Slices');
        data.addRows(JSON.parse(datarecup));
 
        // Set chart options
        var options = {'width':900,
                       'height':500};
 
        // Instantiate and draw our chart, passing in some options.
        var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
 
        function selectHandler() {
          var selectedItem = chart.getSelection()[0];
          if (selectedItem) {
            var topping = data.getValue(selectedItem.row, 0);
            alert('The user selected ' + topping);
          }
        }
        google.visualization.events.addListener(chart, 'select', selectHandler);    
        chart.draw(data, options);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id='chart_div'></div>
    </form>
</body>
</html> | 
 WebForm1.aspx.cs
	
	| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 
 | using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        public string dataserv;
 
        protected void Page_Load(object sender, EventArgs e)
        {
            ServiceReference1.ServiceClient test = new ServiceReference1.ServiceClient();
            dataserv = test.GeTCAtemps(3);
        }
    }
} | 
 Et la chaine JSON qui arrive du service WEB : 
	
	[["Septembre",404513],["Octobre",578556],["Novembre",516610],["Décembre",644990],["Janvier",328638],["Février",404181],["Mars",836658],["Avril",893529],["Mai",596937],["Juin",174235],["Juillet",22689]]
 Merci d'avance pour votre aide car je suis totalement perdu  
						
					
Partager