Basic area

author(s): Torstein Hønsi

by Black Label

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>

<div id="container"></div>

CSS

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

#container {
    height: 450px;
}

.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;
}

JavaScript

Highcharts.chart('container', {
  chart: {
    type: 'area',
    events: {
      load() {
        const chart = this,
          series = chart.series[0],
          points = series.points,
          zones = [];

        series.points.forEach((p, i) => {
          if (points[i + 1] && p.y < points[i + 1].y) {
            zones.push({
              value: points[i + 1].x,
              color: 'green'
            })
          } else {
            zones.push({
              value: p.x,
              color: 'red'
            })
          }
        });
        series.update({
          zones: zones
        })
      }
    }
  },

  xAxis: {
    type: 'datetime'
  },

  series: [{
    data: [
      [1483074000000, 529565.95],
      [1485838800000, 581409.01],
      [1488258000000, 635260.08],
      [1490932800000, 664102.35],
      [1493352000000, 638819.73],
      [1493524800000, 638819.73],
      [1494475200000, 638911],
      [1494561600000, 689111.15],
      [1494820800000, 717497.05],
      [1494907200000, 720143.97],
      [1494993600000, 724890.17]
    ],
    zoneAxis: 'x',
  }]
});