GDP per person in 12 large economies
GDP per person in the US is almost eight times India's. Sorting the x channel by -y orders the columns from highest to lowest.
{
"mark": {
"type": "bar",
"fill": "#0e7490"
},
"data": [
{
"country": "India",
"gdpPerCapita": 9818
},
{
"country": "China",
"gdpPerCapita": 23846
},
{
"country": "United States",
"gdpPerCapita": 75489
},
{
"country": "Indonesia",
"gdpPerCapita": 14470
},
{
"country": "Brazil",
"gdpPerCapita": 19652
},
{
"country": "Mexico",
"gdpPerCapita": 22040
},
{
"country": "Japan",
"gdpPerCapita": 46107
},
{
"country": "Germany",
"gdpPerCapita": 63676
},
{
"country": "United Kingdom",
"gdpPerCapita": 53139
},
{
"country": "France",
"gdpPerCapita": 54799
},
{
"country": "South Korea",
"gdpPerCapita": 55071
},
{
"country": "Canada",
"gdpPerCapita": 58321
}
],
"encoding": {
"x": {
"field": "country",
"type": "nominal",
"sort": "-y"
},
"y": {
"field": "gdpPerCapita",
"type": "quantitative",
"axis": {
"title": "GDP per person",
"format": "$,.0f"
}
}
},
"labels": false,
"chrome": {
"title": "GDP per person in the US is almost eight times India's",
"subtitle": "GDP per person, PPP-adjusted, constant international dollars, about 2022"
}
}import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = "\u0000demo-fold:0";
const spec: ChartSpec = {
data,
"mark": {
"type": "bar",
"fill": "#0e7490"
},
"encoding": {
"x": {
"field": "country",
"type": "nominal",
"sort": "-y"
},
"y": {
"field": "gdpPerCapita",
"type": "quantitative",
"axis": {
"title": "GDP per person",
"format": "$,.0f"
}
}
},
"labels": false,
"chrome": {
"title": "GDP per person in the US is almost eight times India's",
"subtitle": "GDP per person, PPP-adjusted, constant international dollars, about 2022"
}
};
export function Example() {
return <Chart spec={spec} />;
}
import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 12 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "bar",
"fill": "#0e7490"
},
"encoding": {
"x": {
"field": "country",
"type": "nominal",
"sort": "-y"
},
"y": {
"field": "gdpPerCapita",
"type": "quantitative",
"axis": {
"title": "GDP per person",
"format": "$,.0f"
}
}
},
"labels": false,
"chrome": {
"title": "GDP per person in the US is almost eight times India's",
"subtitle": "GDP per person, PPP-adjusted, constant international dollars, about 2022"
}
};
export function Example() {
return <Chart spec={spec} />;
}
<script setup lang="ts">
import { Chart } from "@opendata-ai/openchart-vue";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = "\u0000demo-fold:0";
const spec: ChartSpec = {
data,
"mark": {
"type": "bar",
"fill": "#0e7490"
},
"encoding": {
"x": {
"field": "country",
"type": "nominal",
"sort": "-y"
},
"y": {
"field": "gdpPerCapita",
"type": "quantitative",
"axis": {
"title": "GDP per person",
"format": "$,.0f"
}
}
},
"labels": false,
"chrome": {
"title": "GDP per person in the US is almost eight times India's",
"subtitle": "GDP per person, PPP-adjusted, constant international dollars, about 2022"
}
};
</script>
<template>
<Chart :spec="spec" />
</template>
<script setup lang="ts">
import { Chart } from "@opendata-ai/openchart-vue";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 12 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "bar",
"fill": "#0e7490"
},
"encoding": {
"x": {
"field": "country",
"type": "nominal",
"sort": "-y"
},
"y": {
"field": "gdpPerCapita",
"type": "quantitative",
"axis": {
"title": "GDP per person",
"format": "$,.0f"
}
}
},
"labels": false,
"chrome": {
"title": "GDP per person in the US is almost eight times India's",
"subtitle": "GDP per person, PPP-adjusted, constant international dollars, about 2022"
}
};
</script>
<template>
<Chart :spec="spec" />
</template>
<script lang="ts">
import { Chart } from "@opendata-ai/openchart-svelte";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = "\u0000demo-fold:0";
const spec: ChartSpec = {
data,
"mark": {
"type": "bar",
"fill": "#0e7490"
},
"encoding": {
"x": {
"field": "country",
"type": "nominal",
"sort": "-y"
},
"y": {
"field": "gdpPerCapita",
"type": "quantitative",
"axis": {
"title": "GDP per person",
"format": "$,.0f"
}
}
},
"labels": false,
"chrome": {
"title": "GDP per person in the US is almost eight times India's",
"subtitle": "GDP per person, PPP-adjusted, constant international dollars, about 2022"
}
};
</script>
<Chart {spec} />
<script lang="ts">
import { Chart } from "@opendata-ai/openchart-svelte";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 12 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "bar",
"fill": "#0e7490"
},
"encoding": {
"x": {
"field": "country",
"type": "nominal",
"sort": "-y"
},
"y": {
"field": "gdpPerCapita",
"type": "quantitative",
"axis": {
"title": "GDP per person",
"format": "$,.0f"
}
}
},
"labels": false,
"chrome": {
"title": "GDP per person in the US is almost eight times India's",
"subtitle": "GDP per person, PPP-adjusted, constant international dollars, about 2022"
}
};
</script>
<Chart {spec} />
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = "\u0000demo-fold:0";
const spec: ChartSpec = {
data,
"mark": {
"type": "bar",
"fill": "#0e7490"
},
"encoding": {
"x": {
"field": "country",
"type": "nominal",
"sort": "-y"
},
"y": {
"field": "gdpPerCapita",
"type": "quantitative",
"axis": {
"title": "GDP per person",
"format": "$,.0f"
}
}
},
"labels": false,
"chrome": {
"title": "GDP per person in the US is almost eight times India's",
"subtitle": "GDP per person, PPP-adjusted, constant international dollars, about 2022"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 12 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "bar",
"fill": "#0e7490"
},
"encoding": {
"x": {
"field": "country",
"type": "nominal",
"sort": "-y"
},
"y": {
"field": "gdpPerCapita",
"type": "quantitative",
"axis": {
"title": "GDP per person",
"format": "$,.0f"
}
}
},
"labels": false,
"chrome": {
"title": "GDP per person in the US is almost eight times India's",
"subtitle": "GDP per person, PPP-adjusted, constant international dollars, about 2022"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);