title: Dataframe structure prevents bars to be displayed in ggplotly() chart
body: <p>I have the dataframe below:</p>
  <pre><code>Cum&lt;-data.frame(structure(list(Age.group = c(&quot;00-04&quot;, &quot;00-04&quot;, &quot;05-14&quot;, &quot;05-14&quot;, 
                                               &quot;15-24&quot;, &quot;15-24&quot;, &quot;25-49&quot;, &quot;25-49&quot;, &quot;50-64&quot;, &quot;50-64&quot;, &quot;65-79&quot;, 
                                               &quot;65-79&quot;, &quot;80+&quot;, &quot;80+&quot;), Gender = c(&quot;Female&quot;, &quot;Male&quot;, &quot;Female&quot;, 
                                                                                  &quot;Male&quot;, &quot;Female&quot;, &quot;Male&quot;, &quot;Female&quot;, &quot;Male&quot;, &quot;Female&quot;, &quot;Male&quot;, 
                                                                                  &quot;Female&quot;, &quot;Male&quot;, &quot;Female&quot;, &quot;Male&quot;), Cases = c(64578, 70518, 
                                                                                                                                 187568, 197015, 414405, 388138, 1342394, 1206168, 792180, 742744, 
                                                                                                                                 400232, 414613, 282268, 198026), lab = c(&quot;64,578&quot;, &quot;70,518&quot;, 
                                                                                                                                                                          &quot;187,568&quot;, &quot;197,015&quot;, &quot;414,405&quot;, &quot;388,138&quot;, &quot;1,342,394&quot;, &quot;1,206,168&quot;, 
                                                                                                                                                                          &quot;792,180&quot;, &quot;742,744&quot;, &quot;400,232&quot;, &quot;414,613&quot;, &quot;282,268&quot;, &quot;198,026&quot;
                                                                                                                                 ), Age.group.Sum = c(135096, 135096, 384583, 384583, 802543, 
                                                                                                                                                      802543, 2548562, 2548562, 1534924, 1534924, 814845, 814845, 480294, 
                                                                                                                                                      480294), lab2 = c(&quot;135,096&quot;, &quot;135,096&quot;, &quot;384,583&quot;, &quot;384,583&quot;, 
                                                                                                                                                                        &quot;802,543&quot;, &quot;802,543&quot;, &quot;2,548,562&quot;, &quot;2,548,562&quot;, &quot;1,534,924&quot;, 
                                                                                                                                                                        &quot;1,534,924&quot;, &quot;814,845&quot;, &quot;814,845&quot;, &quot;480,294&quot;, &quot;480,294&quot;), color = c(&quot;#4285f4&quot;, 
                                                                                                                                                                                                                                            &quot;#4285f4&quot;, &quot;#90a9e0&quot;, &quot;#90a9e0&quot;, &quot;#dd9e5f&quot;, &quot;#dd9e5f&quot;, &quot;#b45f06&quot;, 
                                                                                                                                                                                                                                            &quot;#b45f06&quot;, &quot;#b45f06&quot;, &quot;#b45f06&quot;, &quot;#dd9e5f&quot;, &quot;#dd9e5f&quot;, &quot;#aebbd6&quot;, 
                                                                                                                                                                                                                                            &quot;#90a9e0&quot;), Range = c(&quot;&lt;= 74453.8555555556&quot;, &quot;&lt;= 74453.8555555556&quot;, 
                                                                                                                                                                                                                                                                  &quot;148907.711111111 - 223361.566666667&quot;, &quot;148907.711111111 - 223361.566666667&quot;, 
                                                                                                                                                                                                                                                                  &quot;372269.277777778 - 446723.133333333&quot;, &quot;372269.277777778 - 446723.133333333&quot;, 
                                                                                                                                                                                                                                                                  &quot;&gt;= 670084.7&quot;, &quot;&gt;= 670084.7&quot;, &quot;&gt;= 670084.7&quot;, &quot;&gt;= 670084.7&quot;, &quot;372269.277777778 - 446723.133333333&quot;, 
                                                                                                                                                                                                                                                                  &quot;372269.277777778 - 446723.133333333&quot;, &quot;223361.566666667 - 297815.422222222&quot;, 
                                                                                                                                                                                                                                                                  &quot;148907.711111111 - 223361.566666667&quot;)), class = &quot;data.frame&quot;, row.names = c(NA, 
                                                                                                                                                                                                                                                                                                                                               -14L)))
  </code></pre>
  <p>and I want to color the bars by <code>color</code> and the legend names to show the <code>Range</code>. I do everything here but I get no bars. I think it has to do with the structure of my dataframe cause my code is correct I believe.</p>
  <pre><code>ggplot_obj &lt;- ggplot(data = Cum, aes(x = `Age group`, y = Cases, group = Gender,fill = Range)) +
          geom_bar(aes(
            # Define a text object here that can be use for reference by ggplot_ly
            # thought ggplot will throw a warning
            text = paste(&quot;&lt;b&gt;Gender:&lt;/b&gt;&quot;, Gender, &quot;&lt;br&gt;&lt;b&gt;Age:&lt;/b&gt;&quot;, `Age group` ,
                         &quot;&lt;br&gt;&lt;b&gt;Cases:&lt;/b&gt;&quot;, lab, &quot;&lt;br&gt;&lt;b&gt;Total cases in age group:&lt;/b&gt;&quot;,
                         lab2)), 
            position = &quot;dodge&quot;, stat = &quot;identity&quot;) +
          geom_text(aes(y = Cases + 10000, label = Gender), vjust = 1,
                    position = position_dodge(width=0.9),size=2) +
          scale_fill_manual(values = mycols) +
          coord_cartesian(ylim = c(0, max(Cum$Cases)*1.1), expand = FALSE) +
          theme_bw()+ theme(
            # remove the vertical grid lines
            panel.grid.major.x = element_blank(),
            panel.border = element_blank(), axis.line.x = element_line()
          )+
          scale_y_continuous(labels = paste0(ylab, &quot;M&quot;),
                             breaks = 10^6 * ylab)
        #&gt; Warning: Ignoring unknown aesthetics: text
        # running ggplotly with tooltip option reference to the text defined in ggplot object
        ggplotly(ggplot_obj, tooltip=&quot;text&quot;) %&gt;%
          config(modeBarButtonsToRemove = c('toImage', &quot;zoom2d&quot;, &quot;toggleSpikelines&quot;,
                                            &quot;hoverClosestCartesian&quot;, &quot;hoverCompareCartesian&quot;, &quot;drawline&quot;, &quot;autoScale2d&quot;,
                                            &quot;resetScale2d&quot;, &quot;zoomIn2d&quot;, &quot;zoomOut2d&quot;, &quot;pan2d&quot;, 'select2d', 'lasso2d')) %&gt;%
          config(displaylogo = FALSE)
  </code></pre>