Area line chart with missing data

author(s): Øystein Moseng

by oysteinmoseng

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/data.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<script src="https://code.highcharts.com/themes/high-contrast-light.js"></script>

<h1>Stacked area chart</h1>
<h2>Chart</h2>
<figure class="highcharts-figure">
    <div id="container"></div>
    <p class="highcharts-description">
        Time series smoothed area line chart with multiple stacked series.
    </p>
</figure>
<h2>CSV data</h2>
<p>
    Source: <a href="https://data.sfgov.org/Economy-and-Community/Unemployment-Insurance-Weekly-Claims-for-Bay-Area-/d98w-yij4">data.sfgov.org</a>
</p>
<pre id="csv">"Date","Alameda","Contra Costa","Marin","Napa","San Francisco","San Mateo","Santa Clara","Solano","Sonoma"
"2020-02-11 00:00:00",1487,1073,144,162,945,467,1443,678,558
"2020-02-18 00:00:00",1817,1383,202,185,965,597,1794,825,640
"2020-02-25 00:00:00",1350,940,146,157,739,438,1330,574,503
"2020-03-01 00:00:00",1265,949,154,140,801,384,1133,567,453
"2020-03-08 00:00:00",1328,867,138,130,824,444,1369,516,414
"2020-03-15 00:00:00",1371,936,182,115,917,509,1395,535,411
"2020-03-22 00:00:00",1046,836,134,100,703,375,1094,428,370
"2020-03-29 00:00:00",1330,925,159,130,802,462,1186,527,396
"2020-04-07 00:00:00",1434,1039,187,115,1115,523,1359,527,427
"2020-04-14 00:00:00",2171,1483,260,159,2491,975,1840,645,536
"2020-04-21 00:00:00",8664,6000,870,852,6039,3617,9478,2240,2337
"2020-04-28 00:00:00",46056,32426,5826,5525,26889,19466,49472,12702,17040
"2020-05-04 00:00:00",38645,26648,5782,3462,24040,17746,38511,9191,12141
"2020-05-11 00:00:00",27574,19102,4194,2152,16354,11747,27906,6881,8404
"2020-05-18 00:00:00",22842,14460,2793,1616,12502,9292,22920,5499,6675
"2020-05-25...

CSS

body {
  font-family: Verdana, sans-serif;
  padding-left: 10px;
}

p {
    margin-left: 1rem;
}

h2 {
  font-size: 1.3rem;
  margin-left: 10px;
  margin-bottom: 0;
  margin-top: 1.5rem;
}

pre {
  margin-left: 1rem;
  border: 1px solid #cde;
  max-width: 800px;
  padding: 10px;
  background-color: #f9f9f9;
  border-radius: 10px;
}

#container {
    height: 500px;
}

.highcharts-figure, .highcharts-data-table table {
    min-width: 320px;
    max-width: 800px;
    margin: 1em;
}

.highcharts-data-table table {
	font-family: Verdana, sans-serif;
	border-collapse: collapse;
	border: 1px solid #EBEBEB;
	margin: 10px auto;
	text-align: center;
	width: 100%;
	max-width: 500px;
}
.highcharts-data-table caption {
    padding: 1em 0;
    font-size: 1.2em;
    color: #555;
}
.highcharts-data-table th {
	font-weight: 600;
    padding: 0.5em;
}
.highcharts-data-table td, .highcharts-data-table th, .highcharts-data-table caption {
    padding: 0.5em;
}
.highcharts-data-table thead tr, .highcharts-data-table tr:nth-child(even) {
    background: #f8f8f8;
}
.highcharts-data-table tr:hover {
    background: #f1f7ff;
}


input[type="number"] {
	min-width: 50px;
}

JavaScript

var chart = Highcharts.chart('container', {
    chart: {
        type: 'areaspline'
    },
    title: {
        text: 'Weekly New Unemployment Insurance Claims in Bay Area Counties'
    },
    subtitle: {
	    text: 'Source: <a href="https://data.sfgov.org/Economy-and-Community/Unemployment-Insurance-Weekly-Claims-for-Bay-Area-/d98w-yij4">data.sfgov.org</a>'
    },
    tooltip: {
        shared: true,
        backgroundColor: 'rgba(255, 255, 255, 0.92)'
    },
    xAxis: {
    	type: 'datetime'
    },
    yAxis: {
    	title: {
        	text: 'Number of new claims'
        },
        endOnTick: false
    },
    plotOptions: {
    	series: {
        	stacking: 'normal'
        }
    },
    data: {
    	csv: document.getElementById('csv').innerHTML
    }
});