The 10 most populous countries, 2025
India and China each have about four times the US population. One setting, sort on the y channel, orders the bars by value.
{
"mark": "bar",
"data": [
{
"country": "India",
"population": 1463000000
},
{
"country": "China",
"population": 1410000000
},
{
"country": "United States",
"population": 347000000
},
{
"country": "Indonesia",
"population": 285000000
},
{
"country": "Pakistan",
"population": 255000000
},
{
"country": "Nigeria",
"population": 240000000
},
{
"country": "Brazil",
"population": 217000000
},
{
"country": "Bangladesh",
"population": 175000000
},
{
"country": "Russia",
"population": 144000000
},
{
"country": "Ethiopia",
"population": 135000000
}
],
"encoding": {
"x": {
"field": "population",
"type": "quantitative",
"axis": {
"title": "Population",
"format": ".2~s"
}
},
"y": {
"field": "country",
"type": "nominal",
"sort": "-x"
}
},
"chrome": {
"title": "India and China each have about four times the US population",
"subtitle": "Population by country, 2025 estimates"
}
}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": "bar",
"encoding": {
"x": {
"field": "population",
"type": "quantitative",
"axis": {
"title": "Population",
"format": ".2~s"
}
},
"y": {
"field": "country",
"type": "nominal",
"sort": "-x"
}
},
"chrome": {
"title": "India and China each have about four times the US population",
"subtitle": "Population by country, 2025 estimates"
}
};
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 = [/* 10 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "bar",
"encoding": {
"x": {
"field": "population",
"type": "quantitative",
"axis": {
"title": "Population",
"format": ".2~s"
}
},
"y": {
"field": "country",
"type": "nominal",
"sort": "-x"
}
},
"chrome": {
"title": "India and China each have about four times the US population",
"subtitle": "Population by country, 2025 estimates"
}
};
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": "bar",
"encoding": {
"x": {
"field": "population",
"type": "quantitative",
"axis": {
"title": "Population",
"format": ".2~s"
}
},
"y": {
"field": "country",
"type": "nominal",
"sort": "-x"
}
},
"chrome": {
"title": "India and China each have about four times the US population",
"subtitle": "Population by country, 2025 estimates"
}
};
</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 = [/* 10 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "bar",
"encoding": {
"x": {
"field": "population",
"type": "quantitative",
"axis": {
"title": "Population",
"format": ".2~s"
}
},
"y": {
"field": "country",
"type": "nominal",
"sort": "-x"
}
},
"chrome": {
"title": "India and China each have about four times the US population",
"subtitle": "Population by country, 2025 estimates"
}
};
</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": "bar",
"encoding": {
"x": {
"field": "population",
"type": "quantitative",
"axis": {
"title": "Population",
"format": ".2~s"
}
},
"y": {
"field": "country",
"type": "nominal",
"sort": "-x"
}
},
"chrome": {
"title": "India and China each have about four times the US population",
"subtitle": "Population by country, 2025 estimates"
}
};
</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 = [/* 10 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "bar",
"encoding": {
"x": {
"field": "population",
"type": "quantitative",
"axis": {
"title": "Population",
"format": ".2~s"
}
},
"y": {
"field": "country",
"type": "nominal",
"sort": "-x"
}
},
"chrome": {
"title": "India and China each have about four times the US population",
"subtitle": "Population by country, 2025 estimates"
}
};
</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": "bar",
"encoding": {
"x": {
"field": "population",
"type": "quantitative",
"axis": {
"title": "Population",
"format": ".2~s"
}
},
"y": {
"field": "country",
"type": "nominal",
"sort": "-x"
}
},
"chrome": {
"title": "India and China each have about four times the US population",
"subtitle": "Population by country, 2025 estimates"
}
};
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 = [/* 10 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "bar",
"encoding": {
"x": {
"field": "population",
"type": "quantitative",
"axis": {
"title": "Population",
"format": ".2~s"
}
},
"y": {
"field": "country",
"type": "nominal",
"sort": "-x"
}
},
"chrome": {
"title": "India and China each have about four times the US population",
"subtitle": "Population by country, 2025 estimates"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);