# BarChart using EntityList?

**URL:** <https://community.wolfram.com/t/barchart-using-entitylist/19114>\
**Category:** Questions\
**Tags:** curated-data, graphics-and-visualization\
**Created:** [November 11, 2021, 6:15pm UTC](https://community.wolfram.com/t/barchart-using-entitylist/19114 "2021-11-11T18:15:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlock029](https://avatars.discourse-cdn.com/v4/letter/j/b9bd4f/32.png) [@jlock029](https://community.wolfram.com/u/jlock029)\
**Post date:** [November 11, 2021, 6:15pm UTC](https://community.wolfram.com/t/barchart-using-entitylist/19114/1 "2021-11-11T18:15:54Z")

</div>

Trying to make a barchart, but not sure what I am doing wrong. I attached my code and the example,

Please advise.

[Open in Wolfram Cloud ↗](https://www.wolframcloud.com/obj/a62a4d88-7c2e-4e7d-a63d-04fa69204f9b)

---

<div class="post-metadata">

**Author:** ![rohitnamjoshi](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rohitnamjoshi](https://community.wolfram.com/u/rohitnamjoshi)\
**Post date:** [November 11, 2021, 8:41pm UTC](https://community.wolfram.com/t/barchart-using-entitylist/19114/2 "2021-11-11T20:41:24Z")

</div>

Hi Jon,

It seems your main problem is with getting the data. Here is one way

```
greenhouseGases = EntityClass["Chemical", "GreenhouseGases"] // EntityList
euCountries = EntityClass["Country", "EU"] // EntityList

```

Helper function to get emissions for a country

```
emissionsFor[country_, gases_] := 
 AssociationMap[
   country[EntityProperty["Country", 
      "GreenhouseGasEmissions", {"GreenhouseGas" -> CanonicalName@#}]] &, gases] // 
 DeleteMissing

```

e.g. for Austria

```
emissionsFor[Entity["Country", "Austria"], greenhouseGases]

(* 
 <|Entity["Chemical", "Methane"] -> 
  Quantity[7.05709*10^6, IndependentUnit["metric tons of carbon dioxide equivalent"]/("Years")], 
  Entity["Chemical", "CarbonDioxide"] -> 
  Quantity[7.96504*10^7, IndependentUnit["metric tons of carbon dioxide equivalent"]/("Years")], 
  Entity["Chemical", "NitrousOxide"] -> 
  Quantity[5.25581*10^6, IndependentUnit["metric tons of carbon dioxide equivalent"]/("Years")]|>
*)

```

Emissions for all countries

```
AssociationMap[emissionsFor[#, greenhouseGases] &, euCountries]

```

You should be able to generate the `BarChart` from this data.

---

<div class="post-metadata">

**Author:** ![rohitnamjoshi](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rohitnamjoshi](https://community.wolfram.com/u/rohitnamjoshi)\
**Post date:** [November 14, 2021, 2:16am UTC](https://community.wolfram.com/t/barchart-using-entitylist/19114/3 "2021-11-14T02:16:07Z")

</div>

You asked a related question yesterday but it was deleted before I could answer.

```
greenhouseGases = EntityClass["Chemical", "GreenhouseGases"] // EntityList
countries = {Entity["Country", "France"],
  Entity["Country", "Germany"],
  Entity["Country", "Italy"],
  Entity["Country", "Poland"],
  Entity["Country", "Spain"],
  Entity["Country", "Sweden"]}

emissionsFor[country_, gases_] := AssociationMap[
   country[EntityProperty["Country", "GreenhouseGasEmissions",
      {"GreenhouseGas" -> CanonicalName@#}]] &, gases] // 
  DeleteMissing

data = AssociationMap[emissionsFor[#, greenhouseGases] &, countries]

data // BarChart[#,
   ChartLabels -> {CanonicalName@Keys@#, None},
   ChartLegends -> CanonicalName@DeleteDuplicates@Keys@Values@#,
   PlotTheme -> "Detailed",
   FrameLabel -> {"Country", "Metric tons of carbon dioxide equivalent / Year"},
   ImageSize -> 500] &

```

 ![10821plot.png](https://global.discourse-cdn.com/wolfram/original/3X/0/f/0f1a463150ab87ba3a6574c7265bc9e3522c474d.png)
