Skip to content Skip to sidebar Skip to footer

Google Gauge Chart Not Getting Generated In ASP

I'm trying to generate a gauge chart based on changing MTBF values, However when I run the webapplication, I don't see any chart, just the button. Is my approach in the right direc

Solution 1:

There were several problems with your script comparing to this example from documentation:

  1. Loading of necessary packages was skipped
  2. Misspelled google.visualization.Gauge constructor
  3. No function drawchart - presumably there should be chart.draw

I have tried to correct your script, and here is the result (not sure if this is what you were implementing though):

string postData = @"
    google.load('visualization', '1', {packages:['gauge']});
    google.setOnLoadCallback(drawGaugeChart );

    function drawGaugeChart() {
        data = google.visualization.arrayToDataTable([['Label', 'Value'],['MTBF'," + mtbfdisplay + @"]]);
        var options = {
            width: 400, height: 120, redFrom: 90, redTo: 100, yellowFrom: 75, yellowTo: 90, minorTicks: 5
        };
        var chart = new google.visualization.Gauge(document.getElementById('chart-success'));
        chart.draw(data, options);
    }";

Solution 2:

    String posttData = @"            
                        data = google.visualization.arrayToDataTable([
                                ['Label', 'Value'],
                                ['Result', {0}]                           
                            ]);
                            var options = {
                                width: 1200, height: 500, redFrom: 90, redTo: 100, yellowFrom: 75, yellowTo: 90, minorTicks: 5
                            };

                    draw(options,data);";

 <script type="text/javascript" src="https://www.google.com/jsapi"></script>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
         <script type="text/javascript">
             google.load('visualization', '1', { packages: ['gauge'] });

             function draw(options, data) {
                 var chart = new google.visualization.Gauge(document.getElementById('chart_div'));
                 chart.draw(data, options);
             }
        </script>

Post a Comment for "Google Gauge Chart Not Getting Generated In ASP"