China's life expectancy nearly doubled from 1960 to 1980
China's life expectancy rose from 33 to 64 years by 1980 on under $200 a head. encoding.time plays the bubbles year by year, and playback.labels names three.
{
"mark": "point",
"data": "\u0000demo-fold:0",
"encoding": {
"x": {
"field": "gdp",
"type": "quantitative",
"scale": {
"type": "log"
},
"axis": {
"title": "GDP per capita (current US$)",
"format": "$,.0f"
}
},
"y": {
"field": "life",
"type": "quantitative",
"axis": {
"title": "Life expectancy (years)"
}
},
"size": {
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
},
"color": {
"field": "region",
"type": "nominal"
},
"key": {
"field": "country",
"type": "nominal"
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 20000,
"labels": [
"China",
"India",
"United States"
]
},
"chrome": {
"title": "China and India got healthier long before they got rich",
"subtitle": "GDP per capita and life expectancy, every other year from 1960 to 2022. Circle size = population."
}
}
{
"mark": "point",
"data": [
{
"country": "Afghanistan",
"region": "Asia & Pacific",
"year": 2000,
"gdp": 175,
"life": 55,
"pop": 20.1
},
{
"country": "Afghanistan",
"region": "Asia & Pacific",
"year": 2002,
"gdp": 179,
"life": 56.2,
"pop": 21.4
},
{
"country": "Afghanistan",
"region": "Asia & Pacific",
"year": 2004,
"gdp": 222,
"life": 57.8,
"pop": 23.6
},
{
"country": "Afghanistan",
"region": "Asia & Pacific",
"year": 2006,
"gdp": 274,
"life": 58.6,
"pop": 25.4
},
{
"country": "Afghanistan",
"region": "Asia & Pacific",
"year": 2008,
"gdp": 382,
"life": 59.7,
"pop": 26.5
},
{
"country": "Afghanistan",
"region": "Asia & Pacific",
"year": 2010,
"gdp": 561,
"life": 60.7,
"pop": 28.3
},
// … 1,844 more rows; Copy includes them
],
"encoding": {
"x": {
"field": "gdp",
"type": "quantitative",
"scale": {
"type": "log"
},
"axis": {
"title": "GDP per capita (current US$)",
"format": "$,.0f"
}
},
"y": {
"field": "life",
"type": "quantitative",
"axis": {
"title": "Life expectancy (years)"
}
},
"size": {
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
},
"color": {
"field": "region",
"type": "nominal"
},
"key": {
"field": "country",
"type": "nominal"
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 20000,
"labels": [
"China",
"India",
"United States"
]
},
"chrome": {
"title": "China and India got healthier long before they got rich",
"subtitle": "GDP per capita and life expectancy, every other year from 1960 to 2022. Circle size = population."
}
}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": "point",
"encoding": {
"x": {
"field": "gdp",
"type": "quantitative",
"scale": {
"type": "log"
},
"axis": {
"title": "GDP per capita (current US$)",
"format": "$,.0f"
}
},
"y": {
"field": "life",
"type": "quantitative",
"axis": {
"title": "Life expectancy (years)"
}
},
"size": {
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
},
"color": {
"field": "region",
"type": "nominal"
},
"key": {
"field": "country",
"type": "nominal"
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 20000,
"labels": [
"China",
"India",
"United States"
]
},
"chrome": {
"title": "China and India got healthier long before they got rich",
"subtitle": "GDP per capita and life expectancy, every other year from 1960 to 2022. Circle size = population."
}
};
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,850 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "point",
"encoding": {
"x": {
"field": "gdp",
"type": "quantitative",
"scale": {
"type": "log"
},
"axis": {
"title": "GDP per capita (current US$)",
"format": "$,.0f"
}
},
"y": {
"field": "life",
"type": "quantitative",
"axis": {
"title": "Life expectancy (years)"
}
},
"size": {
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
},
"color": {
"field": "region",
"type": "nominal"
},
"key": {
"field": "country",
"type": "nominal"
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 20000,
"labels": [
"China",
"India",
"United States"
]
},
"chrome": {
"title": "China and India got healthier long before they got rich",
"subtitle": "GDP per capita and life expectancy, every other year from 1960 to 2022. Circle size = population."
}
};
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": "point",
"encoding": {
"x": {
"field": "gdp",
"type": "quantitative",
"scale": {
"type": "log"
},
"axis": {
"title": "GDP per capita (current US$)",
"format": "$,.0f"
}
},
"y": {
"field": "life",
"type": "quantitative",
"axis": {
"title": "Life expectancy (years)"
}
},
"size": {
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
},
"color": {
"field": "region",
"type": "nominal"
},
"key": {
"field": "country",
"type": "nominal"
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 20000,
"labels": [
"China",
"India",
"United States"
]
},
"chrome": {
"title": "China and India got healthier long before they got rich",
"subtitle": "GDP per capita and life expectancy, every other year from 1960 to 2022. Circle size = population."
}
};
</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,850 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "point",
"encoding": {
"x": {
"field": "gdp",
"type": "quantitative",
"scale": {
"type": "log"
},
"axis": {
"title": "GDP per capita (current US$)",
"format": "$,.0f"
}
},
"y": {
"field": "life",
"type": "quantitative",
"axis": {
"title": "Life expectancy (years)"
}
},
"size": {
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
},
"color": {
"field": "region",
"type": "nominal"
},
"key": {
"field": "country",
"type": "nominal"
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 20000,
"labels": [
"China",
"India",
"United States"
]
},
"chrome": {
"title": "China and India got healthier long before they got rich",
"subtitle": "GDP per capita and life expectancy, every other year from 1960 to 2022. Circle size = population."
}
};
</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": "point",
"encoding": {
"x": {
"field": "gdp",
"type": "quantitative",
"scale": {
"type": "log"
},
"axis": {
"title": "GDP per capita (current US$)",
"format": "$,.0f"
}
},
"y": {
"field": "life",
"type": "quantitative",
"axis": {
"title": "Life expectancy (years)"
}
},
"size": {
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
},
"color": {
"field": "region",
"type": "nominal"
},
"key": {
"field": "country",
"type": "nominal"
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 20000,
"labels": [
"China",
"India",
"United States"
]
},
"chrome": {
"title": "China and India got healthier long before they got rich",
"subtitle": "GDP per capita and life expectancy, every other year from 1960 to 2022. Circle size = population."
}
};
</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,850 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "point",
"encoding": {
"x": {
"field": "gdp",
"type": "quantitative",
"scale": {
"type": "log"
},
"axis": {
"title": "GDP per capita (current US$)",
"format": "$,.0f"
}
},
"y": {
"field": "life",
"type": "quantitative",
"axis": {
"title": "Life expectancy (years)"
}
},
"size": {
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
},
"color": {
"field": "region",
"type": "nominal"
},
"key": {
"field": "country",
"type": "nominal"
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 20000,
"labels": [
"China",
"India",
"United States"
]
},
"chrome": {
"title": "China and India got healthier long before they got rich",
"subtitle": "GDP per capita and life expectancy, every other year from 1960 to 2022. Circle size = population."
}
};
</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": "point",
"encoding": {
"x": {
"field": "gdp",
"type": "quantitative",
"scale": {
"type": "log"
},
"axis": {
"title": "GDP per capita (current US$)",
"format": "$,.0f"
}
},
"y": {
"field": "life",
"type": "quantitative",
"axis": {
"title": "Life expectancy (years)"
}
},
"size": {
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
},
"color": {
"field": "region",
"type": "nominal"
},
"key": {
"field": "country",
"type": "nominal"
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 20000,
"labels": [
"China",
"India",
"United States"
]
},
"chrome": {
"title": "China and India got healthier long before they got rich",
"subtitle": "GDP per capita and life expectancy, every other year from 1960 to 2022. Circle size = population."
}
};
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,850 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "point",
"encoding": {
"x": {
"field": "gdp",
"type": "quantitative",
"scale": {
"type": "log"
},
"axis": {
"title": "GDP per capita (current US$)",
"format": "$,.0f"
}
},
"y": {
"field": "life",
"type": "quantitative",
"axis": {
"title": "Life expectancy (years)"
}
},
"size": {
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
},
"color": {
"field": "region",
"type": "nominal"
},
"key": {
"field": "country",
"type": "nominal"
},
"time": {
"field": "year",
"type": "temporal"
}
},
"playback": {
"duration": 20000,
"labels": [
"China",
"India",
"United States"
]
},
"chrome": {
"title": "China and India got healthier long before they got rich",
"subtitle": "GDP per capita and life expectancy, every other year from 1960 to 2022. Circle size = population."
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);