Area chart
A line with a wash of its color under it, alone or stacked into a total.
On this page
An area is a line with a wash of its color under it that fades out downward. It gives one or two series more weight on the page; with more, the washes cover each other and lines read better.
Area chart
<div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Requests</h3> <p class="card-description">Millions per month, by region</p> </div> <figure class="chart" id="requests"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('requests'), { type: 'area', label: 'Requests per month by region, in millions', labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], series: [ { name: 'Tokyo', values: [32, 36, 34, 41, 46, 44, 52, 56, 54, 61, 68, 72] }, { name: 'Frankfurt', values: [12, 14, 18, 17, 22, 26, 25, 30, 34, 33, 39, 42] } ]})})</script><script type="module"> import { attach } from '@master/ui/behaviors' attach()</script>import { Chart } from './ui/chart'<div className="card max-w(560) mx-auto"> <div className="card-header"> <h3 className="card-title">Requests</h3> <p className="card-description">Millions per month, by region</p> </div> <Chart id="requests" type="area" label="Requests per month by region, in millions" labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']} series={[ { name: 'Tokyo', values: [32, 36, 34, 41, 46, 44, 52, 56, 54, 61, 68, 72] }, { name: 'Frankfurt', values: [12, 14, 18, 17, 22, 26, 25, 30, 34, 33, 39, 42] } ]} /></div><script> import Chart from './ui/Chart.svelte'</script><div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Requests</h3> <p class="card-description">Millions per month, by region</p> </div> <Chart id="requests" type="area" label="Requests per month by region, in millions" labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']} series={[ { name: 'Tokyo', values: [32, 36, 34, 41, 46, 44, 52, 56, 54, 61, 68, 72] }, { name: 'Frankfurt', values: [12, 14, 18, 17, 22, 26, 25, 30, 34, 33, 39, 42] } ]} /></div><script setup>import Chart from './ui/Chart.vue'</script><template> <div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Requests</h3> <p class="card-description">Millions per month, by region</p> </div> <Chart id="requests" type="area" label="Requests per month by region, in millions" :labels="['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']" :series="[ { name: 'Tokyo', values: [32, 36, 34, 41, 46, 44, 52, 56, 54, 61, 68, 72] }, { name: 'Frankfurt', values: [12, 14, 18, 17, 22, 26, 25, 30, 34, 33, 39, 42] } ]" /> </div></template>#Stacked
Set stacked when the series are parts of a total. Each layer stands on the one before it, so the top edge is the total, and each layer is a tint of its own instead of a fade.
Stacked areas
<div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Visits</h3> <p class="card-description">Thousands per month, by source</p> </div> <figure class="chart" id="visits"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('visits'), { type: 'area', stacked: true, label: 'Visits per month by source, in thousands', labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], series: [ { name: 'Direct', values: [120, 130, 125, 150, 160, 155, 170, 180, 175, 190, 210, 220] }, { name: 'Search', values: [80, 95, 110, 105, 130, 150, 145, 160, 185, 180, 200, 230] }, { name: 'Social', values: [40, 45, 60, 55, 70, 65, 90, 85, 100, 120, 110, 140] } ]})})</script><script type="module"> import { attach } from '@master/ui/behaviors' attach()</script>import { Chart } from './ui/chart'<div className="card max-w(560) mx-auto"> <div className="card-header"> <h3 className="card-title">Visits</h3> <p className="card-description">Thousands per month, by source</p> </div> <Chart id="visits" type="area" stacked label="Visits per month by source, in thousands" labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']} series={[ { name: 'Direct', values: [120, 130, 125, 150, 160, 155, 170, 180, 175, 190, 210, 220] }, { name: 'Search', values: [80, 95, 110, 105, 130, 150, 145, 160, 185, 180, 200, 230] }, { name: 'Social', values: [40, 45, 60, 55, 70, 65, 90, 85, 100, 120, 110, 140] } ]} /></div><script> import Chart from './ui/Chart.svelte'</script><div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Visits</h3> <p class="card-description">Thousands per month, by source</p> </div> <Chart id="visits" type="area" stacked label="Visits per month by source, in thousands" labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']} series={[ { name: 'Direct', values: [120, 130, 125, 150, 160, 155, 170, 180, 175, 190, 210, 220] }, { name: 'Search', values: [80, 95, 110, 105, 130, 150, 145, 160, 185, 180, 200, 230] }, { name: 'Social', values: [40, 45, 60, 55, 70, 65, 90, 85, 100, 120, 110, 140] } ]} /></div><script setup>import Chart from './ui/Chart.vue'</script><template> <div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Visits</h3> <p class="card-description">Thousands per month, by source</p> </div> <Chart id="visits" type="area" stacked label="Visits per month by source, in thousands" :labels="['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']" :series="[ { name: 'Direct', values: [120, 130, 125, 150, 160, 155, 170, 180, 175, 190, 210, 220] }, { name: 'Search', values: [80, 95, 110, 105, 130, 150, 145, 160, 185, 180, 200, 230] }, { name: 'Social', values: [40, 45, 60, 55, 70, 65, 90, 85, 100, 120, 110, 140] } ]" /> </div></template>#A stream
stacked: 'stream' centers the stacked areas on a middle line instead of standing them on the baseline. No layer is then pushed about by the ones under it, so each one's thickness is read where it is, and the whole reads as a shape that swells and thins. A stream has no scale: the readout says each layer's value.
A stream
<div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Listening</h3> <p class="card-description">Hours a month by genre</p> </div> <figure class="chart" id="genres"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('genres'), { type: 'area', stacked: 'stream', label: 'Listening hours a month by genre', labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], series: [ { name: 'Rock', values: [20, 24, 30, 28, 22, 18, 16, 20, 26, 30, 34, 30] }, { name: 'Jazz', values: [10, 12, 11, 16, 22, 26, 24, 20, 16, 12, 10, 12] }, { name: 'Pop', values: [14, 12, 16, 20, 24, 30, 36, 32, 26, 20, 16, 18] }, { name: 'Folk', values: [6, 8, 7, 6, 8, 10, 12, 14, 12, 9, 7, 6] } ]})})</script><script type="module"> import { attach } from '@master/ui/behaviors' attach()</script>import { Chart } from './ui/chart'<div className="card max-w(560) mx-auto"> <div className="card-header"> <h3 className="card-title">Listening</h3> <p className="card-description">Hours a month by genre</p> </div> <Chart id="genres" type="area" stacked="stream" label="Listening hours a month by genre" labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']} series={[ { name: 'Rock', values: [20, 24, 30, 28, 22, 18, 16, 20, 26, 30, 34, 30] }, { name: 'Jazz', values: [10, 12, 11, 16, 22, 26, 24, 20, 16, 12, 10, 12] }, { name: 'Pop', values: [14, 12, 16, 20, 24, 30, 36, 32, 26, 20, 16, 18] }, { name: 'Folk', values: [6, 8, 7, 6, 8, 10, 12, 14, 12, 9, 7, 6] } ]} /></div><script> import Chart from './ui/Chart.svelte'</script><div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Listening</h3> <p class="card-description">Hours a month by genre</p> </div> <Chart id="genres" type="area" stacked="stream" label="Listening hours a month by genre" labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']} series={[ { name: 'Rock', values: [20, 24, 30, 28, 22, 18, 16, 20, 26, 30, 34, 30] }, { name: 'Jazz', values: [10, 12, 11, 16, 22, 26, 24, 20, 16, 12, 10, 12] }, { name: 'Pop', values: [14, 12, 16, 20, 24, 30, 36, 32, 26, 20, 16, 18] }, { name: 'Folk', values: [6, 8, 7, 6, 8, 10, 12, 14, 12, 9, 7, 6] } ]} /></div><script setup>import Chart from './ui/Chart.vue'</script><template> <div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Listening</h3> <p class="card-description">Hours a month by genre</p> </div> <Chart id="genres" type="area" stacked="stream" label="Listening hours a month by genre" :labels="['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']" :series="[ { name: 'Rock', values: [20, 24, 30, 28, 22, 18, 16, 20, 26, 30, 34, 30] }, { name: 'Jazz', values: [10, 12, 11, 16, 22, 26, 24, 20, 16, 12, 10, 12] }, { name: 'Pop', values: [14, 12, 16, 20, 24, 30, 36, 32, 26, 20, 16, 18] }, { name: 'Folk', values: [6, 8, 7, 6, 8, 10, 12, 14, 12, 9, 7, 6] } ]" /> </div></template>stacked: 'percent' makes every step a whole instead: the layers fill the plot from none to all of it, and what is read is each one's share, not the total.
#One series
A chart of one series is drawn in ink, and takes a color only when the series names a category.
One series
<div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Revenue</h3> <p class="card-description">Dollars per month, this year</p> </div> <figure class="chart" id="revenue"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('revenue'), { type: 'area', label: 'Revenue per month, in dollars', labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], series: [{ name: 'Revenue', values: [2100, 2400, 2250, 2900, 3300, 3150, 3700, 4100, 3950, 4600, 5200, 5600] }], format: function (value) { return '$' + value.toLocaleString('en-US') }})})</script><script type="module"> import { attach } from '@master/ui/behaviors' attach()</script>import { Chart } from './ui/chart'<div className="card max-w(560) mx-auto"> <div className="card-header"> <h3 className="card-title">Revenue</h3> <p className="card-description">Dollars per month, this year</p> </div> <Chart id="revenue" type="area" label="Revenue per month, in dollars" labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']} series={[{ name: 'Revenue', values: [2100, 2400, 2250, 2900, 3300, 3150, 3700, 4100, 3950, 4600, 5200, 5600] }]} format={function (value) { return '$' + value.toLocaleString('en-US') }} /></div><script> import Chart from './ui/Chart.svelte'</script><div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Revenue</h3> <p class="card-description">Dollars per month, this year</p> </div> <Chart id="revenue" type="area" label="Revenue per month, in dollars" labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']} series={[{ name: 'Revenue', values: [2100, 2400, 2250, 2900, 3300, 3150, 3700, 4100, 3950, 4600, 5200, 5600] }]} format={function (value) { return '$' + value.toLocaleString('en-US') }} /></div><script setup>import Chart from './ui/Chart.vue'</script><template> <div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Revenue</h3> <p class="card-description">Dollars per month, this year</p> </div> <Chart id="revenue" type="area" label="Revenue per month, in dollars" :labels="['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']" :series="[{ name: 'Revenue', values: [2100, 2400, 2250, 2900, 3300, 3150, 3700, 4100, 3950, 4600, 5200, 5600] }]" :format="function (value) { return '$' + value.toLocaleString('en-US') }" /> </div></template>#Options
| Option | Default | |
|---|---|---|
label | none | What the chart shows and in what unit: the plot's accessible name |
labels | [] | The names along the scale, around a radar or over a heatmap's columns |
series | [] | Each with a name and what its form reads: values, a value, points, ranges or children; optionally a category, a type, low and high, and a ring's max |
stacked | false | Bars, or areas, stand on each other; 'percent' makes every stack a whole, and 'stream' centers stacked areas on a middle line |
curve | 'smooth' | smooth, linear or step |
min, max, ticks | fit, 4 | The ends of the scale and about how many steps mark it; xMin, xMax and xTicks for a scatter's scale across |
format, tickFormat | the locale's | How a value and a tick are written; xFormat for a scatter's scale across |
legend, toggle | with two series, true | Whether a legend is written, and whether its entries are checkboxes |
The readout, the keys, the legend, the colors and the scale are the same in every form: Chart holds them, with every option, class and custom property.