Share of generation from six sources by year, stacked to 100%
Wind and solar's share more than doubled from 2016 to 2023. stack: normalize turns the shares into 100% columns, and highlight dims the other four.
{
"mark": "bar",
"data": "\u0000demo-fold:0",
"encoding": {
"x": {
"field": "year",
"type": "ordinal"
},
"y": {
"field": "share",
"type": "quantitative",
"stack": "normalize",
"axis": {
"title": "Share of generation",
"format": ".0%",
"grid": true
}
},
"color": {
"field": "source",
"type": "nominal",
"scale": {
"domain": [
"Coal",
"Gas",
"Nuclear",
"Hydro",
"Wind",
"Solar"
]
},
"highlight": [
"Wind",
"Solar"
]
}
},
"labels": false,
"chrome": {
"title": "Wind and solar's share of generation from six sources more than doubled, 2016 to 2023",
"subtitle": "Share of US generation from six sources: coal, gas, nuclear, hydro, wind and solar, each year stacked to 100%"
}
}
{
"mark": "bar",
"data": [
{
"year": "2016",
"source": "Wind",
"share": 5.7
},
{
"year": "2016",
"source": "Solar",
"share": 1.4
},
{
"year": "2017",
"source": "Wind",
"share": 6.5
},
{
"year": "2017",
"source": "Solar",
"share": 2
},
{
"year": "2018",
"source": "Wind",
"share": 6.7
},
{
"year": "2018",
"source": "Solar",
"share": 2.3
},
// … 42 more rows; Copy includes them
],
"encoding": {
"x": {
"field": "year",
"type": "ordinal"
},
"y": {
"field": "share",
"type": "quantitative",
"stack": "normalize",
"axis": {
"title": "Share of generation",
"format": ".0%",
"grid": true
}
},
"color": {
"field": "source",
"type": "nominal",
"scale": {
"domain": [
"Coal",
"Gas",
"Nuclear",
"Hydro",
"Wind",
"Solar"
]
},
"highlight": [
"Wind",
"Solar"
]
}
},
"labels": false,
"chrome": {
"title": "Wind and solar's share of generation from six sources more than doubled, 2016 to 2023",
"subtitle": "Share of US generation from six sources: coal, gas, nuclear, hydro, wind and solar, each year stacked to 100%"
}
}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": "year",
"type": "ordinal"
},
"y": {
"field": "share",
"type": "quantitative",
"stack": "normalize",
"axis": {
"title": "Share of generation",
"format": ".0%",
"grid": true
}
},
"color": {
"field": "source",
"type": "nominal",
"scale": {
"domain": [
"Coal",
"Gas",
"Nuclear",
"Hydro",
"Wind",
"Solar"
]
},
"highlight": [
"Wind",
"Solar"
]
}
},
"labels": false,
"chrome": {
"title": "Wind and solar's share of generation from six sources more than doubled, 2016 to 2023",
"subtitle": "Share of US generation from six sources: coal, gas, nuclear, hydro, wind and solar, each year stacked to 100%"
}
};
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": "bar",
"encoding": {
"x": {
"field": "year",
"type": "ordinal"
},
"y": {
"field": "share",
"type": "quantitative",
"stack": "normalize",
"axis": {
"title": "Share of generation",
"format": ".0%",
"grid": true
}
},
"color": {
"field": "source",
"type": "nominal",
"scale": {
"domain": [
"Coal",
"Gas",
"Nuclear",
"Hydro",
"Wind",
"Solar"
]
},
"highlight": [
"Wind",
"Solar"
]
}
},
"labels": false,
"chrome": {
"title": "Wind and solar's share of generation from six sources more than doubled, 2016 to 2023",
"subtitle": "Share of US generation from six sources: coal, gas, nuclear, hydro, wind and solar, each year stacked to 100%"
}
};
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": "year",
"type": "ordinal"
},
"y": {
"field": "share",
"type": "quantitative",
"stack": "normalize",
"axis": {
"title": "Share of generation",
"format": ".0%",
"grid": true
}
},
"color": {
"field": "source",
"type": "nominal",
"scale": {
"domain": [
"Coal",
"Gas",
"Nuclear",
"Hydro",
"Wind",
"Solar"
]
},
"highlight": [
"Wind",
"Solar"
]
}
},
"labels": false,
"chrome": {
"title": "Wind and solar's share of generation from six sources more than doubled, 2016 to 2023",
"subtitle": "Share of US generation from six sources: coal, gas, nuclear, hydro, wind and solar, each year stacked to 100%"
}
};
</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": "bar",
"encoding": {
"x": {
"field": "year",
"type": "ordinal"
},
"y": {
"field": "share",
"type": "quantitative",
"stack": "normalize",
"axis": {
"title": "Share of generation",
"format": ".0%",
"grid": true
}
},
"color": {
"field": "source",
"type": "nominal",
"scale": {
"domain": [
"Coal",
"Gas",
"Nuclear",
"Hydro",
"Wind",
"Solar"
]
},
"highlight": [
"Wind",
"Solar"
]
}
},
"labels": false,
"chrome": {
"title": "Wind and solar's share of generation from six sources more than doubled, 2016 to 2023",
"subtitle": "Share of US generation from six sources: coal, gas, nuclear, hydro, wind and solar, each year stacked to 100%"
}
};
</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": "year",
"type": "ordinal"
},
"y": {
"field": "share",
"type": "quantitative",
"stack": "normalize",
"axis": {
"title": "Share of generation",
"format": ".0%",
"grid": true
}
},
"color": {
"field": "source",
"type": "nominal",
"scale": {
"domain": [
"Coal",
"Gas",
"Nuclear",
"Hydro",
"Wind",
"Solar"
]
},
"highlight": [
"Wind",
"Solar"
]
}
},
"labels": false,
"chrome": {
"title": "Wind and solar's share of generation from six sources more than doubled, 2016 to 2023",
"subtitle": "Share of US generation from six sources: coal, gas, nuclear, hydro, wind and solar, each year stacked to 100%"
}
};
</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": "bar",
"encoding": {
"x": {
"field": "year",
"type": "ordinal"
},
"y": {
"field": "share",
"type": "quantitative",
"stack": "normalize",
"axis": {
"title": "Share of generation",
"format": ".0%",
"grid": true
}
},
"color": {
"field": "source",
"type": "nominal",
"scale": {
"domain": [
"Coal",
"Gas",
"Nuclear",
"Hydro",
"Wind",
"Solar"
]
},
"highlight": [
"Wind",
"Solar"
]
}
},
"labels": false,
"chrome": {
"title": "Wind and solar's share of generation from six sources more than doubled, 2016 to 2023",
"subtitle": "Share of US generation from six sources: coal, gas, nuclear, hydro, wind and solar, each year stacked to 100%"
}
};
</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": "year",
"type": "ordinal"
},
"y": {
"field": "share",
"type": "quantitative",
"stack": "normalize",
"axis": {
"title": "Share of generation",
"format": ".0%",
"grid": true
}
},
"color": {
"field": "source",
"type": "nominal",
"scale": {
"domain": [
"Coal",
"Gas",
"Nuclear",
"Hydro",
"Wind",
"Solar"
]
},
"highlight": [
"Wind",
"Solar"
]
}
},
"labels": false,
"chrome": {
"title": "Wind and solar's share of generation from six sources more than doubled, 2016 to 2023",
"subtitle": "Share of US generation from six sources: coal, gas, nuclear, hydro, wind and solar, each year stacked to 100%"
}
};
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": "bar",
"encoding": {
"x": {
"field": "year",
"type": "ordinal"
},
"y": {
"field": "share",
"type": "quantitative",
"stack": "normalize",
"axis": {
"title": "Share of generation",
"format": ".0%",
"grid": true
}
},
"color": {
"field": "source",
"type": "nominal",
"scale": {
"domain": [
"Coal",
"Gas",
"Nuclear",
"Hydro",
"Wind",
"Solar"
]
},
"highlight": [
"Wind",
"Solar"
]
}
},
"labels": false,
"chrome": {
"title": "Wind and solar's share of generation from six sources more than doubled, 2016 to 2023",
"subtitle": "Share of US generation from six sources: coal, gas, nuclear, hydro, wind and solar, each year stacked to 100%"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);