How do I set the colorAxis of a googleVis bubble chart?











up vote
0
down vote

favorite












I try to adapt the GoogleVis bubble chart example with a continuous color scale for the bubbles based on the profit column:



library(googleVis)
Bubble <- gvisBubbleChart(Fruits, idvar="Fruit",
xvar="Sales", yvar="Expenses",
colorvar="Profit",
options=list(
## custom color
## colors = "['red', 'green', 'blue']",
## custom color scale does not work
colorAxis="{colors: ['yellow', 'red']}",
hAxis='{minValue:75, maxValue:125}'))
plot(Bubble)


However, whatevery I try with the 'colorAxis' option it does not work, while I do follow the official documentation. It seems weird, because when I look at the source code of the plot I can see that the option is set:



// jsDrawChart
function drawChartBubbleChartID2b6add84971() {
var data = gvisDataBubbleChartID2b6add84971();
var options = {};
options["colorAxis"] = {colors: ['yellow', 'red']};
options["hAxis"] = {minValue:75, maxValue:125};
var chart = new google.visualization.BubbleChart(
document.getElementById('BubbleChartID2b6add84971')
);
chart.draw(data,options);
}


What am I doing wrong? Thanks for any help.










share|improve this question




























    up vote
    0
    down vote

    favorite












    I try to adapt the GoogleVis bubble chart example with a continuous color scale for the bubbles based on the profit column:



    library(googleVis)
    Bubble <- gvisBubbleChart(Fruits, idvar="Fruit",
    xvar="Sales", yvar="Expenses",
    colorvar="Profit",
    options=list(
    ## custom color
    ## colors = "['red', 'green', 'blue']",
    ## custom color scale does not work
    colorAxis="{colors: ['yellow', 'red']}",
    hAxis='{minValue:75, maxValue:125}'))
    plot(Bubble)


    However, whatevery I try with the 'colorAxis' option it does not work, while I do follow the official documentation. It seems weird, because when I look at the source code of the plot I can see that the option is set:



    // jsDrawChart
    function drawChartBubbleChartID2b6add84971() {
    var data = gvisDataBubbleChartID2b6add84971();
    var options = {};
    options["colorAxis"] = {colors: ['yellow', 'red']};
    options["hAxis"] = {minValue:75, maxValue:125};
    var chart = new google.visualization.BubbleChart(
    document.getElementById('BubbleChartID2b6add84971')
    );
    chart.draw(data,options);
    }


    What am I doing wrong? Thanks for any help.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I try to adapt the GoogleVis bubble chart example with a continuous color scale for the bubbles based on the profit column:



      library(googleVis)
      Bubble <- gvisBubbleChart(Fruits, idvar="Fruit",
      xvar="Sales", yvar="Expenses",
      colorvar="Profit",
      options=list(
      ## custom color
      ## colors = "['red', 'green', 'blue']",
      ## custom color scale does not work
      colorAxis="{colors: ['yellow', 'red']}",
      hAxis='{minValue:75, maxValue:125}'))
      plot(Bubble)


      However, whatevery I try with the 'colorAxis' option it does not work, while I do follow the official documentation. It seems weird, because when I look at the source code of the plot I can see that the option is set:



      // jsDrawChart
      function drawChartBubbleChartID2b6add84971() {
      var data = gvisDataBubbleChartID2b6add84971();
      var options = {};
      options["colorAxis"] = {colors: ['yellow', 'red']};
      options["hAxis"] = {minValue:75, maxValue:125};
      var chart = new google.visualization.BubbleChart(
      document.getElementById('BubbleChartID2b6add84971')
      );
      chart.draw(data,options);
      }


      What am I doing wrong? Thanks for any help.










      share|improve this question















      I try to adapt the GoogleVis bubble chart example with a continuous color scale for the bubbles based on the profit column:



      library(googleVis)
      Bubble <- gvisBubbleChart(Fruits, idvar="Fruit",
      xvar="Sales", yvar="Expenses",
      colorvar="Profit",
      options=list(
      ## custom color
      ## colors = "['red', 'green', 'blue']",
      ## custom color scale does not work
      colorAxis="{colors: ['yellow', 'red']}",
      hAxis='{minValue:75, maxValue:125}'))
      plot(Bubble)


      However, whatevery I try with the 'colorAxis' option it does not work, while I do follow the official documentation. It seems weird, because when I look at the source code of the plot I can see that the option is set:



      // jsDrawChart
      function drawChartBubbleChartID2b6add84971() {
      var data = gvisDataBubbleChartID2b6add84971();
      var options = {};
      options["colorAxis"] = {colors: ['yellow', 'red']};
      options["hAxis"] = {minValue:75, maxValue:125};
      var chart = new google.visualization.BubbleChart(
      document.getElementById('BubbleChartID2b6add84971')
      );
      chart.draw(data,options);
      }


      What am I doing wrong? Thanks for any help.







      r googlevis






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 9 at 13:09









      Martin Schmelzer

      11.8k23461




      11.8k23461










      asked Nov 9 at 12:06









      Martin

      802612




      802612
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          UPDATE:



          After I added an issue on GitHub, the problem should be resolved for the current developer version on GitHub (devtools::install_github("mages/googleVis")). And indeed, it works:



          enter image description here





          The problem seems to be the data column "Profit":



          var datajson = [
          ["Apples", 98, 78, "20"],
          ["Oranges", 96, 81, "15"],
          ["Bananas", 85, 76, "9"]
          ];

          data.addColumn('string','Fruit');
          data.addColumn('number','Sales');
          data.addColumn('number','Expenses');
          data.addColumn('string','Profit');


          For reasons I do not see this column is defined as a string type column. When you change the relevant lines to



          var datajson = [
          ["Apples", 98, 78, 20],
          ["Oranges", 96, 81, 15],
          ["Bananas", 85, 76, 9]
          ];

          data.addColumn('number','Profit');


          a gradient color scale is applied to the bubbles.



          This might be a bug in the googleVis implementation since the Fruits data defines the Profit column to be numeric.






          share|improve this answer























          • Hi Martin, Thank you very much. Not only for reporting the issue, but I now also learned how I could have diagnosed the problem myself (look at the datajson). I will install the dev version!
            – Martin
            Nov 9 at 17:11













          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',
          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%2f53225425%2fhow-do-i-set-the-coloraxis-of-a-googlevis-bubble-chart%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








          up vote
          0
          down vote



          accepted










          UPDATE:



          After I added an issue on GitHub, the problem should be resolved for the current developer version on GitHub (devtools::install_github("mages/googleVis")). And indeed, it works:



          enter image description here





          The problem seems to be the data column "Profit":



          var datajson = [
          ["Apples", 98, 78, "20"],
          ["Oranges", 96, 81, "15"],
          ["Bananas", 85, 76, "9"]
          ];

          data.addColumn('string','Fruit');
          data.addColumn('number','Sales');
          data.addColumn('number','Expenses');
          data.addColumn('string','Profit');


          For reasons I do not see this column is defined as a string type column. When you change the relevant lines to



          var datajson = [
          ["Apples", 98, 78, 20],
          ["Oranges", 96, 81, 15],
          ["Bananas", 85, 76, 9]
          ];

          data.addColumn('number','Profit');


          a gradient color scale is applied to the bubbles.



          This might be a bug in the googleVis implementation since the Fruits data defines the Profit column to be numeric.






          share|improve this answer























          • Hi Martin, Thank you very much. Not only for reporting the issue, but I now also learned how I could have diagnosed the problem myself (look at the datajson). I will install the dev version!
            – Martin
            Nov 9 at 17:11

















          up vote
          0
          down vote



          accepted










          UPDATE:



          After I added an issue on GitHub, the problem should be resolved for the current developer version on GitHub (devtools::install_github("mages/googleVis")). And indeed, it works:



          enter image description here





          The problem seems to be the data column "Profit":



          var datajson = [
          ["Apples", 98, 78, "20"],
          ["Oranges", 96, 81, "15"],
          ["Bananas", 85, 76, "9"]
          ];

          data.addColumn('string','Fruit');
          data.addColumn('number','Sales');
          data.addColumn('number','Expenses');
          data.addColumn('string','Profit');


          For reasons I do not see this column is defined as a string type column. When you change the relevant lines to



          var datajson = [
          ["Apples", 98, 78, 20],
          ["Oranges", 96, 81, 15],
          ["Bananas", 85, 76, 9]
          ];

          data.addColumn('number','Profit');


          a gradient color scale is applied to the bubbles.



          This might be a bug in the googleVis implementation since the Fruits data defines the Profit column to be numeric.






          share|improve this answer























          • Hi Martin, Thank you very much. Not only for reporting the issue, but I now also learned how I could have diagnosed the problem myself (look at the datajson). I will install the dev version!
            – Martin
            Nov 9 at 17:11















          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          UPDATE:



          After I added an issue on GitHub, the problem should be resolved for the current developer version on GitHub (devtools::install_github("mages/googleVis")). And indeed, it works:



          enter image description here





          The problem seems to be the data column "Profit":



          var datajson = [
          ["Apples", 98, 78, "20"],
          ["Oranges", 96, 81, "15"],
          ["Bananas", 85, 76, "9"]
          ];

          data.addColumn('string','Fruit');
          data.addColumn('number','Sales');
          data.addColumn('number','Expenses');
          data.addColumn('string','Profit');


          For reasons I do not see this column is defined as a string type column. When you change the relevant lines to



          var datajson = [
          ["Apples", 98, 78, 20],
          ["Oranges", 96, 81, 15],
          ["Bananas", 85, 76, 9]
          ];

          data.addColumn('number','Profit');


          a gradient color scale is applied to the bubbles.



          This might be a bug in the googleVis implementation since the Fruits data defines the Profit column to be numeric.






          share|improve this answer














          UPDATE:



          After I added an issue on GitHub, the problem should be resolved for the current developer version on GitHub (devtools::install_github("mages/googleVis")). And indeed, it works:



          enter image description here





          The problem seems to be the data column "Profit":



          var datajson = [
          ["Apples", 98, 78, "20"],
          ["Oranges", 96, 81, "15"],
          ["Bananas", 85, 76, "9"]
          ];

          data.addColumn('string','Fruit');
          data.addColumn('number','Sales');
          data.addColumn('number','Expenses');
          data.addColumn('string','Profit');


          For reasons I do not see this column is defined as a string type column. When you change the relevant lines to



          var datajson = [
          ["Apples", 98, 78, 20],
          ["Oranges", 96, 81, 15],
          ["Bananas", 85, 76, 9]
          ];

          data.addColumn('number','Profit');


          a gradient color scale is applied to the bubbles.



          This might be a bug in the googleVis implementation since the Fruits data defines the Profit column to be numeric.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 9 at 15:23

























          answered Nov 9 at 13:20









          Martin Schmelzer

          11.8k23461




          11.8k23461












          • Hi Martin, Thank you very much. Not only for reporting the issue, but I now also learned how I could have diagnosed the problem myself (look at the datajson). I will install the dev version!
            – Martin
            Nov 9 at 17:11




















          • Hi Martin, Thank you very much. Not only for reporting the issue, but I now also learned how I could have diagnosed the problem myself (look at the datajson). I will install the dev version!
            – Martin
            Nov 9 at 17:11


















          Hi Martin, Thank you very much. Not only for reporting the issue, but I now also learned how I could have diagnosed the problem myself (look at the datajson). I will install the dev version!
          – Martin
          Nov 9 at 17:11






          Hi Martin, Thank you very much. Not only for reporting the issue, but I now also learned how I could have diagnosed the problem myself (look at the datajson). I will install the dev version!
          – Martin
          Nov 9 at 17:11




















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53225425%2fhow-do-i-set-the-coloraxis-of-a-googlevis-bubble-chart%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







          Popular posts from this blog

          Guess what letter conforming each word

          Port of Spain

          Run scheduled task as local user group (not BUILTIN)