user2561233
user2561233

Reputation:

One or more participants failed to draw()

this is my code i want to have one combochart with dashbord but i have this error :

One or more participants failed to draw()× janv. 2013janv. 2013févr. 2013févr. 2013mars 2013mars 2013avr. 2013avr. 2013mai 2013mai 2013juin 2013juin 2013juil. 2013juil. 2013août 2013août 2013


!function($) {


    google.load('visualization', '1.1', {packages: ['corechart']});
    google.load('visualization', '1', {packages: ['controls']});
    google.setOnLoadCallback(initialize);



       function initialize(cityName) {

            // You can manipulate the variable response
            // Success! 
            var query = new google.visualization.Query('http://api.XXX.com/XXX/datasource?table=montmorin');


            query.setQuery("select (cost_reportings_timestamp), sum (cost_reportings_cost) group by (cost_reportings_timestamp)  pivot ecoadmin_zone_name");
              //Send the query with a callback function.
            query.send(drawDashboard);
        //console.log(response);
        }

       function drawDashboard(response) {
            // it's a good idea to include something like this to catch errors

            if (response.isError()) {
                alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
                return;
            }

            var data = response.getDataTable();
            console.log(data);
            var namePicker= new google.visualization.ControlWrapper({
                controlType: 'ChartRangeFilter',
                containerId: 'filter_div',

                options: {
                    // Filter by the date axis.
                    filterColumnLabel: 'cost_reportings_timestamp',
                    ui: {
                        chartType: 'LineChart',
                        chartOptions: {
                            chartArea: {
                                width: '90%'
                            },
                            hAxis: {
                                baselineColor: 'none'
                            }
                        },
                        // Display a single series that shows the closing value of the stock.
                        // Thus, this view has two columns: the date (axis) and the stock value (line series).
                        chartView: {
                            columns: [0,1]
                        }
                    }
                },
                //Initial range: 2010 to 2021
                state: {
                    range: {
                        start: new Date(2012),
                        end: new Date(2019)
                    }
                }
            })

         // Define a bar chart
            var pieChart = new google.visualization.ChartWrapper({
                chartType: 'ComboChart',
                containerId: 'chart_div',

                options: {
                    width: 400,
                    height: 300,
                    seriesType: 'bars',
                    isStacked:'True',
                    hAxis: {
                        minValue: 0,
                        maxValue: 60
                    },
                    chartArea: {
                        top: 0,
                        right: 0,
                        bottom: 0
                    },
                },
                view: {columns: [0, 1, 2, 3]}
            });

            var dashboard = new google.visualization.Dashboard(document.getElementById('dashboard_div')).
            bind(namePicker, pieChart).
            draw(data);

       }         
}(jQuery);

could you explain me ??????

and this is the format of my JSON :

google.visualization.Query.setResponse({"version":"0.6","status":"ok","sig":"266867977","table":{"cols":[{"id":"ecoadmin_building_name","label":"ecoadmin_building_name","type":"string","pattern":""},{"id":"ecoadmin_zone_name","label":"ecoadmin_zone_name","type":"string","pattern":""},{"id":"cost_reportings_cost","label":"cost_reportings_cost","type":"number","pattern":""},{"id":"cost_reportings_timestamp","label":"cost_reportings_timestamp","type":"date","pattern":""}],"rows":[{"c":[{"v":"Mairie de Montmorin"},{"v":"Bureau de M. le Maire"},{"v":0.0},{"v":new Date(2012,11,8)}]},{"c":[{"v":"Mairie de Montmorin"},{"v":"Bureau de M. le Maire"},{"v":0.0},{"v":new Date(2012,11,9)}]},{"c":[{"v":"Mairie de Montmorin"},{"v":"Bureau de M. le Maire"},{"v":0.453663},{"v":new Date(2012,11,10)}]},{"c":[{"v":"Mairie de Montmorin"},{"v":"Bureau de M. le Maire"},{"v":0.458649},{"v":new Date(2012,11,11)}]},{"c":[{"v":"Mairie de Montmorin"},{"v":"Bureau de M. le Maire"},{"v":0.44573},{"v":new Date(2012,11,12)}]},{"c":[{"v":"Mairie de Montmorin"},{"v":"Bureau de M. le Maire"},{"v":1.09863},{"v":new Date(2012,11,13)}]},{"c":[{"v":"Mairie de Montmorin"},{"v":"Bureau de M. le Maire"},{"v":0.429977},{"v":new Date(2012,11,14)}]},{"c":[{"v":"Mairie de Montmorin"},{"v":"Bureau de M. le Maire"},{"v":1.13331E-4},{"v":new Date(2012,11,15)}]},{"c":[{"v":"Mairie de Montmorin"},{"v":"Bureau de M. le Maire"},{"v":0.0},{"v":new Date(2012,11,16)}]},{"c":[{"v":"Mairie de Montmorin"},{"v":"Bureau de M. le Maire"},{"v":0.471569},{"v":new Date(2012,11,17)}]}

Upvotes: 0

Views: 1474

Answers (1)

Sergey G
Sergey G

Reputation: 1221

The problem with your JSON is that there is no 'table' property in the JSON representation, 'cols' and 'rows' are direct peers of 'version'. So your fixed JSON should look as follows:

google.visualization.Query.setResponse({
  "version": "0.6",
  "status": "ok",
  "sig": "266867977",
  "cols": [{
      "id": "ecoadmin_building_name",
      "label": "ecoadmin_building_name",
      "type": "string",
      "pattern": ""
    }, {
      "id": "ecoadmin_zone_name",
      "label": "ecoadmin_zone_name",
      "type": "string",
      "pattern": ""
    }, {
      "id": "cost_reportings_cost",
      "label": "cost_reportings_cost",
      "type": "number",
      "pattern": ""
    }, {
      "id": "cost_reportings_timestamp",
      "label": "cost_reportings_timestamp",
      "type": "date",
      "pattern": ""
    }
  ],
  "rows": [
    {"c": [{"v": "Mairie de Montmorin"}, {"v": "Bureau de M. le Maire"}, {"v": 0.0}, {"v": new Date(2012, 11, 8)}]},
    {"c": [{"v": "Mairie de Montmorin"}, {"v": "Bureau de M. le Maire"}, {"v": 0.0}, {"v": new Date(2012, 11, 9)}]},
    {"c": [{"v": "Mairie de Montmorin"}, {"v": "Bureau de M. le Maire"}, {"v": 0.453663}, {"v": new Date(2012, 11, 10)}]},
    {"c": [{"v": "Mairie de Montmorin"}, {"v": "Bureau de M. le Maire"}, {"v": 0.458649}, {"v": new Date(2012, 11, 11)}]},
    {"c": [{"v": "Mairie de Montmorin"}, {"v": "Bureau de M. le Maire"}, {"v": 0.44573}, {"v": new Date(2012, 11, 12)}]},
    {"c": [{"v": "Mairie de Montmorin"}, {"v": "Bureau de M. le Maire"}, {"v": 1.09863}, {"v": new Date(2012, 11, 13)}]},
    {"c": [{"v": "Mairie de Montmorin"}, {"v": "Bureau de M. le Maire"}, {"v": 0.429977}, {"v": new Date(2012, 11, 14)}]},
    {"c": [{"v": "Mairie de Montmorin"}, {"v": "Bureau de M. le Maire"}, {"v": 1.13331E-4}, {"v": new Date(2012, 11, 15)}]},
    {"c": [{"v": "Mairie de Montmorin"}, {"v": "Bureau de M. le Maire"}, {"v": 0.0}, {"v": new Date(2012, 11, 16)}]},
    {"c": [{"v": "Mairie de Montmorin"}, {"v": "Bureau de M. le Maire"}, {"v": 0.471569}, {"v": new Date(2012, 11, 17)}]}
  ]
});

Upvotes: 1

Related Questions