'Dashboard not a constructor' error with Google Charts










1















I am a naive React Developer and facing some difficulty with getting gooogle chart work with react. I am using Google Charts in a ReactJs component with ControlWrapper as shown below.



componentDidMount: function()
google.charts.load('current', 'packages':['corechart', 'controls']);
this.drawCharts();
,
componentDidUpdate: function()
google.charts.load('current', 'packages':['corechart', 'controls']);
this.drawCharts();
,
drawCharts: function()
var cmpt = this;
//Removed detailed code from here due to copyright issues

//adding controls----------------

let dashboard = new google.visualization.Dashboard( document.getElementById(cmpt.props.widgetId) );
let controlId = '$this.props.widgetId_control';
var controlWrapper = new google.visualization.ControlWrapper(
'controlType' : 'NumberRangeFilter',
'containerId' : controlId,
'options' :
'filterColumnLabel' : xDataSysName

);
var barChart = new google.visualization.ChartWrapper(
'chartType': 'BarChart',
'containerId': this.props.widgetId,
'options': options
);

dashboard.bind(controlWrapper, barChart);
dashboard.draw(data);

if(linkColumn)
let selectionEventHandler = function()
window.location = data.getValue(barChart.getSelection()[0]['row'], 1 );
;
google.visualization.events.addListener(barChart, 'select', selectionEventHandler);


},


This is not the whole piece of code but should be enough for the issue I'm facing.



First time I load the page, I get the error in the console saying



google.visualization.Dashboard is not a constructor



I reload the page hitting SHIFT+F5, the error goes away and components load just fine except ones that are dependent on controlWrapper throwing the error as follows



google.visualization.controlWrapper is not a constructor



which never goes away even after reloading the page. I referred to this discussion and tried their solution but I am still getting these error in the manner mentioned above. Please help me figure out how to fix it. Also, I am not able to comprehend why dashboard error goes away on a reload.










share|improve this question




























    1















    I am a naive React Developer and facing some difficulty with getting gooogle chart work with react. I am using Google Charts in a ReactJs component with ControlWrapper as shown below.



    componentDidMount: function()
    google.charts.load('current', 'packages':['corechart', 'controls']);
    this.drawCharts();
    ,
    componentDidUpdate: function()
    google.charts.load('current', 'packages':['corechart', 'controls']);
    this.drawCharts();
    ,
    drawCharts: function()
    var cmpt = this;
    //Removed detailed code from here due to copyright issues

    //adding controls----------------

    let dashboard = new google.visualization.Dashboard( document.getElementById(cmpt.props.widgetId) );
    let controlId = '$this.props.widgetId_control';
    var controlWrapper = new google.visualization.ControlWrapper(
    'controlType' : 'NumberRangeFilter',
    'containerId' : controlId,
    'options' :
    'filterColumnLabel' : xDataSysName

    );
    var barChart = new google.visualization.ChartWrapper(
    'chartType': 'BarChart',
    'containerId': this.props.widgetId,
    'options': options
    );

    dashboard.bind(controlWrapper, barChart);
    dashboard.draw(data);

    if(linkColumn)
    let selectionEventHandler = function()
    window.location = data.getValue(barChart.getSelection()[0]['row'], 1 );
    ;
    google.visualization.events.addListener(barChart, 'select', selectionEventHandler);


    },


    This is not the whole piece of code but should be enough for the issue I'm facing.



    First time I load the page, I get the error in the console saying



    google.visualization.Dashboard is not a constructor



    I reload the page hitting SHIFT+F5, the error goes away and components load just fine except ones that are dependent on controlWrapper throwing the error as follows



    google.visualization.controlWrapper is not a constructor



    which never goes away even after reloading the page. I referred to this discussion and tried their solution but I am still getting these error in the manner mentioned above. Please help me figure out how to fix it. Also, I am not able to comprehend why dashboard error goes away on a reload.










    share|improve this question


























      1












      1








      1








      I am a naive React Developer and facing some difficulty with getting gooogle chart work with react. I am using Google Charts in a ReactJs component with ControlWrapper as shown below.



      componentDidMount: function()
      google.charts.load('current', 'packages':['corechart', 'controls']);
      this.drawCharts();
      ,
      componentDidUpdate: function()
      google.charts.load('current', 'packages':['corechart', 'controls']);
      this.drawCharts();
      ,
      drawCharts: function()
      var cmpt = this;
      //Removed detailed code from here due to copyright issues

      //adding controls----------------

      let dashboard = new google.visualization.Dashboard( document.getElementById(cmpt.props.widgetId) );
      let controlId = '$this.props.widgetId_control';
      var controlWrapper = new google.visualization.ControlWrapper(
      'controlType' : 'NumberRangeFilter',
      'containerId' : controlId,
      'options' :
      'filterColumnLabel' : xDataSysName

      );
      var barChart = new google.visualization.ChartWrapper(
      'chartType': 'BarChart',
      'containerId': this.props.widgetId,
      'options': options
      );

      dashboard.bind(controlWrapper, barChart);
      dashboard.draw(data);

      if(linkColumn)
      let selectionEventHandler = function()
      window.location = data.getValue(barChart.getSelection()[0]['row'], 1 );
      ;
      google.visualization.events.addListener(barChart, 'select', selectionEventHandler);


      },


      This is not the whole piece of code but should be enough for the issue I'm facing.



      First time I load the page, I get the error in the console saying



      google.visualization.Dashboard is not a constructor



      I reload the page hitting SHIFT+F5, the error goes away and components load just fine except ones that are dependent on controlWrapper throwing the error as follows



      google.visualization.controlWrapper is not a constructor



      which never goes away even after reloading the page. I referred to this discussion and tried their solution but I am still getting these error in the manner mentioned above. Please help me figure out how to fix it. Also, I am not able to comprehend why dashboard error goes away on a reload.










      share|improve this question
















      I am a naive React Developer and facing some difficulty with getting gooogle chart work with react. I am using Google Charts in a ReactJs component with ControlWrapper as shown below.



      componentDidMount: function()
      google.charts.load('current', 'packages':['corechart', 'controls']);
      this.drawCharts();
      ,
      componentDidUpdate: function()
      google.charts.load('current', 'packages':['corechart', 'controls']);
      this.drawCharts();
      ,
      drawCharts: function()
      var cmpt = this;
      //Removed detailed code from here due to copyright issues

      //adding controls----------------

      let dashboard = new google.visualization.Dashboard( document.getElementById(cmpt.props.widgetId) );
      let controlId = '$this.props.widgetId_control';
      var controlWrapper = new google.visualization.ControlWrapper(
      'controlType' : 'NumberRangeFilter',
      'containerId' : controlId,
      'options' :
      'filterColumnLabel' : xDataSysName

      );
      var barChart = new google.visualization.ChartWrapper(
      'chartType': 'BarChart',
      'containerId': this.props.widgetId,
      'options': options
      );

      dashboard.bind(controlWrapper, barChart);
      dashboard.draw(data);

      if(linkColumn)
      let selectionEventHandler = function()
      window.location = data.getValue(barChart.getSelection()[0]['row'], 1 );
      ;
      google.visualization.events.addListener(barChart, 'select', selectionEventHandler);


      },


      This is not the whole piece of code but should be enough for the issue I'm facing.



      First time I load the page, I get the error in the console saying



      google.visualization.Dashboard is not a constructor



      I reload the page hitting SHIFT+F5, the error goes away and components load just fine except ones that are dependent on controlWrapper throwing the error as follows



      google.visualization.controlWrapper is not a constructor



      which never goes away even after reloading the page. I referred to this discussion and tried their solution but I am still getting these error in the manner mentioned above. Please help me figure out how to fix it. Also, I am not able to comprehend why dashboard error goes away on a reload.







      reactjs charts google-visualization google-chartwrapper






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 16 '18 at 14:53







      pyroCoder

















      asked Nov 15 '18 at 9:19









      pyroCoderpyroCoder

      1716




      1716






















          1 Answer
          1






          active

          oldest

          votes


















          1














          need to wait until google charts has fully loaded before trying to use any constructors,

          this is done by providing a callback function.



          try changing the load statement as follows...



          componentDidMount: function()
          google.charts.load('current', packages:['corechart', 'controls'], callback: this.drawCharts);
          ,
          componentDidUpdate: function()
          google.charts.load('current', packages:['corechart', 'controls'], callback: this.drawCharts);
          ,





          share|improve this answer























          • Seems to be working just fine with your solution. Thank you so much.

            – pyroCoder
            Nov 16 '18 at 14:58










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53316056%2fdashboard-not-a-constructor-error-with-google-charts%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          need to wait until google charts has fully loaded before trying to use any constructors,

          this is done by providing a callback function.



          try changing the load statement as follows...



          componentDidMount: function()
          google.charts.load('current', packages:['corechart', 'controls'], callback: this.drawCharts);
          ,
          componentDidUpdate: function()
          google.charts.load('current', packages:['corechart', 'controls'], callback: this.drawCharts);
          ,





          share|improve this answer























          • Seems to be working just fine with your solution. Thank you so much.

            – pyroCoder
            Nov 16 '18 at 14:58















          1














          need to wait until google charts has fully loaded before trying to use any constructors,

          this is done by providing a callback function.



          try changing the load statement as follows...



          componentDidMount: function()
          google.charts.load('current', packages:['corechart', 'controls'], callback: this.drawCharts);
          ,
          componentDidUpdate: function()
          google.charts.load('current', packages:['corechart', 'controls'], callback: this.drawCharts);
          ,





          share|improve this answer























          • Seems to be working just fine with your solution. Thank you so much.

            – pyroCoder
            Nov 16 '18 at 14:58













          1












          1








          1







          need to wait until google charts has fully loaded before trying to use any constructors,

          this is done by providing a callback function.



          try changing the load statement as follows...



          componentDidMount: function()
          google.charts.load('current', packages:['corechart', 'controls'], callback: this.drawCharts);
          ,
          componentDidUpdate: function()
          google.charts.load('current', packages:['corechart', 'controls'], callback: this.drawCharts);
          ,





          share|improve this answer













          need to wait until google charts has fully loaded before trying to use any constructors,

          this is done by providing a callback function.



          try changing the load statement as follows...



          componentDidMount: function()
          google.charts.load('current', packages:['corechart', 'controls'], callback: this.drawCharts);
          ,
          componentDidUpdate: function()
          google.charts.load('current', packages:['corechart', 'controls'], callback: this.drawCharts);
          ,






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 15 '18 at 13:21









          WhiteHatWhiteHat

          37.9k61681




          37.9k61681












          • Seems to be working just fine with your solution. Thank you so much.

            – pyroCoder
            Nov 16 '18 at 14:58

















          • Seems to be working just fine with your solution. Thank you so much.

            – pyroCoder
            Nov 16 '18 at 14:58
















          Seems to be working just fine with your solution. Thank you so much.

          – pyroCoder
          Nov 16 '18 at 14:58





          Seems to be working just fine with your solution. Thank you so much.

          – pyroCoder
          Nov 16 '18 at 14:58



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53316056%2fdashboard-not-a-constructor-error-with-google-charts%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

          Museum of Modern and Contemporary Art of Trento and Rovereto