Share of generation from six sources by year, 2016 to 2023
Gas rose as coal's share of generation from six sources halved. A rect mark puts year on x, source on y and share on a sequential color scale.
{
"mark": "rect",
"data": "\u0000demo-fold:0",
"encoding": {
"x": {
"field": "year",
"type": "nominal"
},
"y": {
"field": "source",
"type": "nominal"
},
"color": {
"field": "share",
"type": "quantitative",
"scale": {
"scheme": "blues"
},
"format": ".1f"
}
},
"chrome": {
"title": "Gas rose as coal's share halved",
"subtitle": "Share of US electricity generation by source (%), 2016-2023. Darker cells = larger share."
}
}
{
"mark": "rect",
"data": [
{
"year": "2016",
"source": "Coal",
"share": 31.2
},
{
"year": "2016",
"source": "Gas",
"share": 34.8
},
{
"year": "2016",
"source": "Nuclear",
"share": 20.3
},
{
"year": "2016",
"source": "Hydro",
"share": 6.6
},
{
"year": "2016",
"source": "Wind",
"share": 5.7
},
{
"year": "2016",
"source": "Solar",
"share": 1.4
},
// … 42 more rows; Copy includes them
],
"encoding": {
"x": {
"field": "year",
"type": "nominal"
},
"y": {
"field": "source",
"type": "nominal"
},
"color": {
"field": "share",
"type": "quantitative",
"scale": {
"scheme": "blues"
},
"format": ".1f"
}
},
"chrome": {
"title": "Gas rose as coal's share halved",
"subtitle": "Share of US electricity generation by source (%), 2016-2023. Darker cells = larger share."
}
}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": "rect",
"encoding": {
"x": {
"field": "year",
"type": "nominal"
},
"y": {
"field": "source",
"type": "nominal"
},
"color": {
"field": "share",
"type": "quantitative",
"scale": {
"scheme": "blues"
},
"format": ".1f"
}
},
"chrome": {
"title": "Gas rose as coal's share halved",
"subtitle": "Share of US electricity generation by source (%), 2016-2023. Darker cells = larger share."
}
};
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 = [/* 48 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "rect",
"encoding": {
"x": {
"field": "year",
"type": "nominal"
},
"y": {
"field": "source",
"type": "nominal"
},
"color": {
"field": "share",
"type": "quantitative",
"scale": {
"scheme": "blues"
},
"format": ".1f"
}
},
"chrome": {
"title": "Gas rose as coal's share halved",
"subtitle": "Share of US electricity generation by source (%), 2016-2023. Darker cells = larger share."
}
};
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": "rect",
"encoding": {
"x": {
"field": "year",
"type": "nominal"
},
"y": {
"field": "source",
"type": "nominal"
},
"color": {
"field": "share",
"type": "quantitative",
"scale": {
"scheme": "blues"
},
"format": ".1f"
}
},
"chrome": {
"title": "Gas rose as coal's share halved",
"subtitle": "Share of US electricity generation by source (%), 2016-2023. Darker cells = larger share."
}
};
</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 = [/* 48 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "rect",
"encoding": {
"x": {
"field": "year",
"type": "nominal"
},
"y": {
"field": "source",
"type": "nominal"
},
"color": {
"field": "share",
"type": "quantitative",
"scale": {
"scheme": "blues"
},
"format": ".1f"
}
},
"chrome": {
"title": "Gas rose as coal's share halved",
"subtitle": "Share of US electricity generation by source (%), 2016-2023. Darker cells = larger share."
}
};
</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": "rect",
"encoding": {
"x": {
"field": "year",
"type": "nominal"
},
"y": {
"field": "source",
"type": "nominal"
},
"color": {
"field": "share",
"type": "quantitative",
"scale": {
"scheme": "blues"
},
"format": ".1f"
}
},
"chrome": {
"title": "Gas rose as coal's share halved",
"subtitle": "Share of US electricity generation by source (%), 2016-2023. Darker cells = larger share."
}
};
</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 = [/* 48 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "rect",
"encoding": {
"x": {
"field": "year",
"type": "nominal"
},
"y": {
"field": "source",
"type": "nominal"
},
"color": {
"field": "share",
"type": "quantitative",
"scale": {
"scheme": "blues"
},
"format": ".1f"
}
},
"chrome": {
"title": "Gas rose as coal's share halved",
"subtitle": "Share of US electricity generation by source (%), 2016-2023. Darker cells = larger share."
}
};
</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": "rect",
"encoding": {
"x": {
"field": "year",
"type": "nominal"
},
"y": {
"field": "source",
"type": "nominal"
},
"color": {
"field": "share",
"type": "quantitative",
"scale": {
"scheme": "blues"
},
"format": ".1f"
}
},
"chrome": {
"title": "Gas rose as coal's share halved",
"subtitle": "Share of US electricity generation by source (%), 2016-2023. Darker cells = larger share."
}
};
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 = [/* 48 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "rect",
"encoding": {
"x": {
"field": "year",
"type": "nominal"
},
"y": {
"field": "source",
"type": "nominal"
},
"color": {
"field": "share",
"type": "quantitative",
"scale": {
"scheme": "blues"
},
"format": ".1f"
}
},
"chrome": {
"title": "Gas rose as coal's share halved",
"subtitle": "Share of US electricity generation by source (%), 2016-2023. Darker cells = larger share."
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);