Japan's population pyramid, 1950 to 2100
People 65 and older went from 5% of Japan in 1950 to 30% in 2025. mark.mirror sets men and women back to back, and encoding.time plays the years.
{
"mark": {
"type": "bar",
"mirror": true
},
"data": "\u0000demo-fold:0",
"encoding": {
"y": {
"field": "age",
"type": "ordinal",
"sort": [
"100+",
"95-99",
"90-94",
"85-89",
"80-84",
"75-79",
"70-74",
"65-69",
"60-64",
"55-59",
"50-54",
"45-49",
"40-44",
"35-39",
"30-34",
"25-29",
"20-24",
"15-19",
"10-14",
"5-9",
"0-4"
]
},
"x": {
"field": "pop",
"type": "quantitative",
"format": ".2~s"
},
"color": {
"field": "sex",
"type": "nominal",
"sort": [
"Male",
"Female"
]
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 15000
},
"chrome": {
"title": "Japan's population ages as the base narrows and the bulge moves up",
"subtitle": "Population of Japan by age and sex, every fifth year from 1950 to 2100; 2025 onward projected"
}
}
{
"mark": {
"type": "bar",
"mirror": true
},
"data": [
{
"year": 1950,
"age": "0-4",
"sex": "Male",
"pop": 6002000
},
{
"year": 1950,
"age": "0-4",
"sex": "Female",
"pop": 5944000
},
{
"year": 1955,
"age": "0-4",
"sex": "Male",
"pop": 4852000
},
{
"year": 1955,
"age": "0-4",
"sex": "Female",
"pop": 4687000
},
{
"year": 1960,
"age": "0-4",
"sex": "Male",
"pop": 4085000
},
{
"year": 1960,
"age": "0-4",
"sex": "Female",
"pop": 3949000
},
// … 1,296 more rows; Copy includes them
],
"encoding": {
"y": {
"field": "age",
"type": "ordinal",
"sort": [
"100+",
"95-99",
"90-94",
"85-89",
"80-84",
"75-79",
"70-74",
"65-69",
"60-64",
"55-59",
"50-54",
"45-49",
"40-44",
"35-39",
"30-34",
"25-29",
"20-24",
"15-19",
"10-14",
"5-9",
"0-4"
]
},
"x": {
"field": "pop",
"type": "quantitative",
"format": ".2~s"
},
"color": {
"field": "sex",
"type": "nominal",
"sort": [
"Male",
"Female"
]
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 15000
},
"chrome": {
"title": "Japan's population ages as the base narrows and the bulge moves up",
"subtitle": "Population of Japan by age and sex, every fifth year from 1950 to 2100; 2025 onward projected"
}
}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",
"mirror": true
},
"encoding": {
"y": {
"field": "age",
"type": "ordinal",
"sort": [
"100+",
"95-99",
"90-94",
"85-89",
"80-84",
"75-79",
"70-74",
"65-69",
"60-64",
"55-59",
"50-54",
"45-49",
"40-44",
"35-39",
"30-34",
"25-29",
"20-24",
"15-19",
"10-14",
"5-9",
"0-4"
]
},
"x": {
"field": "pop",
"type": "quantitative",
"format": ".2~s"
},
"color": {
"field": "sex",
"type": "nominal",
"sort": [
"Male",
"Female"
]
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 15000
},
"chrome": {
"title": "Japan's population ages as the base narrows and the bulge moves up",
"subtitle": "Population of Japan by age and sex, every fifth year from 1950 to 2100; 2025 onward projected"
}
};
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 = [/* 1,302 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "bar",
"mirror": true
},
"encoding": {
"y": {
"field": "age",
"type": "ordinal",
"sort": [
"100+",
"95-99",
"90-94",
"85-89",
"80-84",
"75-79",
"70-74",
"65-69",
"60-64",
"55-59",
"50-54",
"45-49",
"40-44",
"35-39",
"30-34",
"25-29",
"20-24",
"15-19",
"10-14",
"5-9",
"0-4"
]
},
"x": {
"field": "pop",
"type": "quantitative",
"format": ".2~s"
},
"color": {
"field": "sex",
"type": "nominal",
"sort": [
"Male",
"Female"
]
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 15000
},
"chrome": {
"title": "Japan's population ages as the base narrows and the bulge moves up",
"subtitle": "Population of Japan by age and sex, every fifth year from 1950 to 2100; 2025 onward projected"
}
};
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",
"mirror": true
},
"encoding": {
"y": {
"field": "age",
"type": "ordinal",
"sort": [
"100+",
"95-99",
"90-94",
"85-89",
"80-84",
"75-79",
"70-74",
"65-69",
"60-64",
"55-59",
"50-54",
"45-49",
"40-44",
"35-39",
"30-34",
"25-29",
"20-24",
"15-19",
"10-14",
"5-9",
"0-4"
]
},
"x": {
"field": "pop",
"type": "quantitative",
"format": ".2~s"
},
"color": {
"field": "sex",
"type": "nominal",
"sort": [
"Male",
"Female"
]
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 15000
},
"chrome": {
"title": "Japan's population ages as the base narrows and the bulge moves up",
"subtitle": "Population of Japan by age and sex, every fifth year from 1950 to 2100; 2025 onward projected"
}
};
</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 = [/* 1,302 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "bar",
"mirror": true
},
"encoding": {
"y": {
"field": "age",
"type": "ordinal",
"sort": [
"100+",
"95-99",
"90-94",
"85-89",
"80-84",
"75-79",
"70-74",
"65-69",
"60-64",
"55-59",
"50-54",
"45-49",
"40-44",
"35-39",
"30-34",
"25-29",
"20-24",
"15-19",
"10-14",
"5-9",
"0-4"
]
},
"x": {
"field": "pop",
"type": "quantitative",
"format": ".2~s"
},
"color": {
"field": "sex",
"type": "nominal",
"sort": [
"Male",
"Female"
]
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 15000
},
"chrome": {
"title": "Japan's population ages as the base narrows and the bulge moves up",
"subtitle": "Population of Japan by age and sex, every fifth year from 1950 to 2100; 2025 onward projected"
}
};
</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",
"mirror": true
},
"encoding": {
"y": {
"field": "age",
"type": "ordinal",
"sort": [
"100+",
"95-99",
"90-94",
"85-89",
"80-84",
"75-79",
"70-74",
"65-69",
"60-64",
"55-59",
"50-54",
"45-49",
"40-44",
"35-39",
"30-34",
"25-29",
"20-24",
"15-19",
"10-14",
"5-9",
"0-4"
]
},
"x": {
"field": "pop",
"type": "quantitative",
"format": ".2~s"
},
"color": {
"field": "sex",
"type": "nominal",
"sort": [
"Male",
"Female"
]
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 15000
},
"chrome": {
"title": "Japan's population ages as the base narrows and the bulge moves up",
"subtitle": "Population of Japan by age and sex, every fifth year from 1950 to 2100; 2025 onward projected"
}
};
</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 = [/* 1,302 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "bar",
"mirror": true
},
"encoding": {
"y": {
"field": "age",
"type": "ordinal",
"sort": [
"100+",
"95-99",
"90-94",
"85-89",
"80-84",
"75-79",
"70-74",
"65-69",
"60-64",
"55-59",
"50-54",
"45-49",
"40-44",
"35-39",
"30-34",
"25-29",
"20-24",
"15-19",
"10-14",
"5-9",
"0-4"
]
},
"x": {
"field": "pop",
"type": "quantitative",
"format": ".2~s"
},
"color": {
"field": "sex",
"type": "nominal",
"sort": [
"Male",
"Female"
]
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 15000
},
"chrome": {
"title": "Japan's population ages as the base narrows and the bulge moves up",
"subtitle": "Population of Japan by age and sex, every fifth year from 1950 to 2100; 2025 onward projected"
}
};
</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",
"mirror": true
},
"encoding": {
"y": {
"field": "age",
"type": "ordinal",
"sort": [
"100+",
"95-99",
"90-94",
"85-89",
"80-84",
"75-79",
"70-74",
"65-69",
"60-64",
"55-59",
"50-54",
"45-49",
"40-44",
"35-39",
"30-34",
"25-29",
"20-24",
"15-19",
"10-14",
"5-9",
"0-4"
]
},
"x": {
"field": "pop",
"type": "quantitative",
"format": ".2~s"
},
"color": {
"field": "sex",
"type": "nominal",
"sort": [
"Male",
"Female"
]
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 15000
},
"chrome": {
"title": "Japan's population ages as the base narrows and the bulge moves up",
"subtitle": "Population of Japan by age and sex, every fifth year from 1950 to 2100; 2025 onward projected"
}
};
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 = [/* 1,302 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "bar",
"mirror": true
},
"encoding": {
"y": {
"field": "age",
"type": "ordinal",
"sort": [
"100+",
"95-99",
"90-94",
"85-89",
"80-84",
"75-79",
"70-74",
"65-69",
"60-64",
"55-59",
"50-54",
"45-49",
"40-44",
"35-39",
"30-34",
"25-29",
"20-24",
"15-19",
"10-14",
"5-9",
"0-4"
]
},
"x": {
"field": "pop",
"type": "quantitative",
"format": ".2~s"
},
"color": {
"field": "sex",
"type": "nominal",
"sort": [
"Male",
"Female"
]
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 15000
},
"chrome": {
"title": "Japan's population ages as the base narrows and the bulge moves up",
"subtitle": "Population of Japan by age and sex, every fifth year from 1950 to 2100; 2025 onward projected"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);