Dear Fellow Developers...

I am a .NET Developer.  I am trying to display a simple pie chart.  Instead 
of the pie chart being displayed, the following message appears in its 
place: Table has no columns.

Please see the ASPX file below and the jsonString returned from the jQuery 
AJAX call below.  What am I doing wrong?

Let me know what other information may be required.

---------- ASPX File ----------

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml";>
<head><title>

</title>
    <!--Load the AJAX API-->
    <script type="text/javascript" 
src="https://www.gstatic.com/charts/loader.js";></script>
    <script type="text/javascript" 
src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript">

        // Load the Visualization API and the piechart package.
        google.charts.load('current', { 'packages': ['corechart'] });

        // Set a callback to run when the Google Visualization API is 
loaded.
        google.charts.setOnLoadCallback(drawChart);

        function drawChart() {
            var jsonString = $.ajax({
                url: "Default.aspx/UnitsDispensed",
                dataType: "json",
                async: false,
                data: "{source:'Pharmacy', vendor:'Biogen', 
product:'Tecfidera', timeframe:'Last Week'}",
                contentType: "application/json; charset=utf-8",
                type: "POST",
                failure: function (response) {
                    alert(response.d);
                }
            }).responseText;

            // Create our data table out of JSON data loaded from server.
            var data = new google.visualization.DataTable(jsonString);

            // Instantiate and draw our chart, passing in some options.
            var chart = new 
google.visualization.PieChart(document.getElementById('chart_div'));
            chart.draw(data, { width: 400, height: 240 });
        }
    </script>
</head>
<body>
    <form method="post" action="./Default.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" 
value="3o0D1+y9raAljLe6bYS3KM3XkDOGhlpfinivcAA/OI/tEFSHfzFy1u+r1EX2fGA0INUVNZXcpJZKvoqjodiCgh/sId1Ovl/fUQomnThI+J0="
 
/>
</div>

        <!--Div that will hold the pie chart-->
        <div id="chart_div"></div>
    
<div class="aspNetHidden">

<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" 
value="CA0B0334" />
</div></form>

<!-- Visual Studio Browser Link -->
<script type="application/json" id="__browserLink_initializationData">
    {"appName":"Internet 
Explorer","requestId":"c3ce39fbc27c4baeb1d08aefa3ebdfa7"}
</script>
<script type="text/javascript" 
src="http://localhost:58288/e79f396490d348ba9b79300932de5b53/browserLink"; 
async="async"></script>
<!-- End Browser Link -->

</body>
</html>

---------- jsonString ----------

"{cols: [{id: 'Pharmacy', type: 'string'},{id: 'Units Dispensed', type: 
'string'}],rows: [{c: [{v: 'Caresite SpecialtyRx -Surehealth'},{v: 
'420'}]},{c: [{v: 'Carolina Health Care System'},{v: '120'}]},{c: [{v: 
'Chartwell Pennsylvania L.P.'},{v: '1,146'}]},{c: [{v: 'Cleveland Clinic 
Foundation'},{v: '660'}]},{c: [{v: 'Credena Health, LLC'},{v: 
'2,262'}]},{c: [{v: 'Fairview Specialty Pharmacy Services'},{v: 
'2,036'}]},{c: [{v: 'Henry Ford Health System'},{v: '716'}]},{c: [{v: 
'MS-Rx, LLC'},{v: '1,080'}]},{c: [{v: 'Rush University Medical Center'},{v: 
'240'}]},{c: [{v: 'UMass Memorial Specialty Pharmacy'},{v: '7'}]},{c: [{v: 
'UNC Health Care'},{v: '720'}]},{c: [{v: 'Vanderbilt Univ Hospital 
Phcy'},{v: '900'}]}]}"

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/48f8c4fc-71f0-4770-b754-fbd4dd8ffc85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to