GDP per person and life expectancy in 12 large economies
The US has the highest GDP per person of the 12, but six of them live longer. A text annotation with a curved connector calls out one point.
{
"mark": {
"type": "point",
"fill": "#0e7490",
"size": 6,
"trendline": false
},
"data": [
{
"country": "India",
"gdpPerCapita": 9818,
"lifeExpectancy": 68.3
},
{
"country": "China",
"gdpPerCapita": 23846,
"lifeExpectancy": 76.1
},
{
"country": "United States",
"gdpPerCapita": 75489,
"lifeExpectancy": 79.2
},
{
"country": "Indonesia",
"gdpPerCapita": 14470,
"lifeExpectancy": 69
},
{
"country": "Brazil",
"gdpPerCapita": 19652,
"lifeExpectancy": 75.3
},
{
"country": "Mexico",
"gdpPerCapita": 22040,
"lifeExpectancy": 76.9
},
{
"country": "Japan",
"gdpPerCapita": 46107,
"lifeExpectancy": 83.6
},
{
"country": "Germany",
"gdpPerCapita": 63676,
"lifeExpectancy": 80.8
},
{
"country": "United Kingdom",
"gdpPerCapita": 53139,
"lifeExpectancy": 81.4
},
{
"country": "France",
"gdpPerCapita": 54799,
"lifeExpectancy": 82.4
},
{
"country": "South Korea",
"gdpPerCapita": 55071,
"lifeExpectancy": 81.9
},
{
"country": "Canada",
"gdpPerCapita": 58321,
"lifeExpectancy": 82.2
}
],
"encoding": {
"x": {
"field": "gdpPerCapita",
"type": "quantitative",
"axis": {
"title": "GDP per person (PPP, constant international $)",
"format": "$,.0f"
}
},
"y": {
"field": "lifeExpectancy",
"type": "quantitative",
"axis": {
"title": "Life expectancy at birth (years)"
}
},
"tooltip": {
"field": "country",
"type": "nominal",
"title": "Country"
}
},
"annotations": [
{
"type": "text",
"x": 75489,
"y": 79.2,
"text": "**United States**\n$75,489 per person, 79.2 years",
"anchor": "bottom",
"offset": {
"dx": -40,
"dy": 40
},
"connector": "curve"
}
],
"chrome": {
"title": "The US has the highest income of these 12 countries, but six of them live longer",
"subtitle": "GDP per person against life expectancy at birth in 12 large economies"
}
}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": "point",
"fill": "#0e7490",
"size": 6,
"trendline": false
},
"encoding": {
"x": {
"field": "gdpPerCapita",
"type": "quantitative",
"axis": {
"title": "GDP per person (PPP, constant international $)",
"format": "$,.0f"
}
},
"y": {
"field": "lifeExpectancy",
"type": "quantitative",
"axis": {
"title": "Life expectancy at birth (years)"
}
},
"tooltip": {
"field": "country",
"type": "nominal",
"title": "Country"
}
},
"annotations": [
{
"type": "text",
"x": 75489,
"y": 79.2,
"text": "**United States**\n$75,489 per person, 79.2 years",
"anchor": "bottom",
"offset": {
"dx": -40,
"dy": 40
},
"connector": "curve"
}
],
"chrome": {
"title": "The US has the highest income of these 12 countries, but six of them live longer",
"subtitle": "GDP per person against life expectancy at birth in 12 large economies"
}
};
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": "point",
"fill": "#0e7490",
"size": 6,
"trendline": false
},
"encoding": {
"x": {
"field": "gdpPerCapita",
"type": "quantitative",
"axis": {
"title": "GDP per person (PPP, constant international $)",
"format": "$,.0f"
}
},
"y": {
"field": "lifeExpectancy",
"type": "quantitative",
"axis": {
"title": "Life expectancy at birth (years)"
}
},
"tooltip": {
"field": "country",
"type": "nominal",
"title": "Country"
}
},
"annotations": [
{
"type": "text",
"x": 75489,
"y": 79.2,
"text": "**United States**\n$75,489 per person, 79.2 years",
"anchor": "bottom",
"offset": {
"dx": -40,
"dy": 40
},
"connector": "curve"
}
],
"chrome": {
"title": "The US has the highest income of these 12 countries, but six of them live longer",
"subtitle": "GDP per person against life expectancy at birth in 12 large economies"
}
};
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": "point",
"fill": "#0e7490",
"size": 6,
"trendline": false
},
"encoding": {
"x": {
"field": "gdpPerCapita",
"type": "quantitative",
"axis": {
"title": "GDP per person (PPP, constant international $)",
"format": "$,.0f"
}
},
"y": {
"field": "lifeExpectancy",
"type": "quantitative",
"axis": {
"title": "Life expectancy at birth (years)"
}
},
"tooltip": {
"field": "country",
"type": "nominal",
"title": "Country"
}
},
"annotations": [
{
"type": "text",
"x": 75489,
"y": 79.2,
"text": "**United States**\n$75,489 per person, 79.2 years",
"anchor": "bottom",
"offset": {
"dx": -40,
"dy": 40
},
"connector": "curve"
}
],
"chrome": {
"title": "The US has the highest income of these 12 countries, but six of them live longer",
"subtitle": "GDP per person against life expectancy at birth in 12 large economies"
}
};
</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": "point",
"fill": "#0e7490",
"size": 6,
"trendline": false
},
"encoding": {
"x": {
"field": "gdpPerCapita",
"type": "quantitative",
"axis": {
"title": "GDP per person (PPP, constant international $)",
"format": "$,.0f"
}
},
"y": {
"field": "lifeExpectancy",
"type": "quantitative",
"axis": {
"title": "Life expectancy at birth (years)"
}
},
"tooltip": {
"field": "country",
"type": "nominal",
"title": "Country"
}
},
"annotations": [
{
"type": "text",
"x": 75489,
"y": 79.2,
"text": "**United States**\n$75,489 per person, 79.2 years",
"anchor": "bottom",
"offset": {
"dx": -40,
"dy": 40
},
"connector": "curve"
}
],
"chrome": {
"title": "The US has the highest income of these 12 countries, but six of them live longer",
"subtitle": "GDP per person against life expectancy at birth in 12 large economies"
}
};
</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": "point",
"fill": "#0e7490",
"size": 6,
"trendline": false
},
"encoding": {
"x": {
"field": "gdpPerCapita",
"type": "quantitative",
"axis": {
"title": "GDP per person (PPP, constant international $)",
"format": "$,.0f"
}
},
"y": {
"field": "lifeExpectancy",
"type": "quantitative",
"axis": {
"title": "Life expectancy at birth (years)"
}
},
"tooltip": {
"field": "country",
"type": "nominal",
"title": "Country"
}
},
"annotations": [
{
"type": "text",
"x": 75489,
"y": 79.2,
"text": "**United States**\n$75,489 per person, 79.2 years",
"anchor": "bottom",
"offset": {
"dx": -40,
"dy": 40
},
"connector": "curve"
}
],
"chrome": {
"title": "The US has the highest income of these 12 countries, but six of them live longer",
"subtitle": "GDP per person against life expectancy at birth in 12 large economies"
}
};
</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": "point",
"fill": "#0e7490",
"size": 6,
"trendline": false
},
"encoding": {
"x": {
"field": "gdpPerCapita",
"type": "quantitative",
"axis": {
"title": "GDP per person (PPP, constant international $)",
"format": "$,.0f"
}
},
"y": {
"field": "lifeExpectancy",
"type": "quantitative",
"axis": {
"title": "Life expectancy at birth (years)"
}
},
"tooltip": {
"field": "country",
"type": "nominal",
"title": "Country"
}
},
"annotations": [
{
"type": "text",
"x": 75489,
"y": 79.2,
"text": "**United States**\n$75,489 per person, 79.2 years",
"anchor": "bottom",
"offset": {
"dx": -40,
"dy": 40
},
"connector": "curve"
}
],
"chrome": {
"title": "The US has the highest income of these 12 countries, but six of them live longer",
"subtitle": "GDP per person against life expectancy at birth in 12 large economies"
}
};
</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": "point",
"fill": "#0e7490",
"size": 6,
"trendline": false
},
"encoding": {
"x": {
"field": "gdpPerCapita",
"type": "quantitative",
"axis": {
"title": "GDP per person (PPP, constant international $)",
"format": "$,.0f"
}
},
"y": {
"field": "lifeExpectancy",
"type": "quantitative",
"axis": {
"title": "Life expectancy at birth (years)"
}
},
"tooltip": {
"field": "country",
"type": "nominal",
"title": "Country"
}
},
"annotations": [
{
"type": "text",
"x": 75489,
"y": 79.2,
"text": "**United States**\n$75,489 per person, 79.2 years",
"anchor": "bottom",
"offset": {
"dx": -40,
"dy": 40
},
"connector": "curve"
}
],
"chrome": {
"title": "The US has the highest income of these 12 countries, but six of them live longer",
"subtitle": "GDP per person against life expectancy at birth in 12 large economies"
}
};
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": "point",
"fill": "#0e7490",
"size": 6,
"trendline": false
},
"encoding": {
"x": {
"field": "gdpPerCapita",
"type": "quantitative",
"axis": {
"title": "GDP per person (PPP, constant international $)",
"format": "$,.0f"
}
},
"y": {
"field": "lifeExpectancy",
"type": "quantitative",
"axis": {
"title": "Life expectancy at birth (years)"
}
},
"tooltip": {
"field": "country",
"type": "nominal",
"title": "Country"
}
},
"annotations": [
{
"type": "text",
"x": 75489,
"y": 79.2,
"text": "**United States**\n$75,489 per person, 79.2 years",
"anchor": "bottom",
"offset": {
"dx": -40,
"dy": 40
},
"connector": "curve"
}
],
"chrome": {
"title": "The US has the highest income of these 12 countries, but six of them live longer",
"subtitle": "GDP per person against life expectancy at birth in 12 large economies"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);