Question: I am using Ionic with vanila java script
I am using CDN in head component

```
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.esm.js"></script>
<script nomodule src="https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core/css/ionic.bundle.css"/>

```

In the body of HTML

```
<ion-alert-controller></ion-alert-controller>
......
.....
<script src="app.js"></script>

```

in app.js

```
const alertCtrl = document.querySelector('ion-alert-controller');
..
..
..
alertCtrl.create ({
                message: 'ABC',
                header: 'DEF',
                button: ['Okay']
            });

```

getting an error saying

app.js:29 Uncaught TypeError: alertCtrl.create is not a function
at HTMLElement. (app.js:29)

Answer: 
One way to do this is to put the data into long format.
Not really sure how meaningful this graph is as it gives the sum highway and city miles per gallon. Might be more meaningful to calculate the average highway and city miles per gallon for the different fuel types.

```r
library(ggplot2)
library(tidyr)

mpg %>% 
  pivot_longer(c(cty,hwy)) %>% 
ggplot(aes(x = fl, y=value, fill = name))+
  geom_col(position = "dodge")

```

![](https://i.imgur.com/NedPOCg.png)

Created on 2021-04-10 by the [reprex package](https://reprex.tidyverse.org) (v2.0.0)
Barcharts makes the height of the bar proportional to the number of cases in each group. It can't have x and y aesthetic at the same time.

From your description I think you want to map categorical data to numeric, in this case use boxplots e.g.

```
mpg %>% 
 select(fl, cty, hwy) %>% 
 pivot_longer(-fl) %>% 
 ggplot(aes(x = fl, y = value, fill = name)) + geom_boxplot()

```