Basic line

by oysteinmoseng

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/series-label.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>

<figure class="highcharts-figure">
    <div id="container"></div>
    <p class="highcharts-description">
        Basic line chart showing time data. This chart includes the
        <code>series-label</code> module, which adds a label to each line for
        enhanced readability.
    </p>
</figure>

CSS

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

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

.highcharts-description {
    margin: 0.3rem 10px;
}

JavaScript

Highcharts.chart('container', {
  chart: {
    type: 'spline' // Smoothed line
  },

  title: {
    text: 'Application users last 24 hours',
    align: 'left'
  },

  subtitle: {
    text: 'All traffic sources combined'
  },

  yAxis: {
    title: {
      text: 'Unique users'
    }
  },

  xAxis: {
    type: 'datetime',
    crosshair: true,
    dateTimeLabelFormats: {
    	day: '%H:%M' // Don't show the date
    }
  },

  legend: {
    enabled: false
  },

  tooltip: {
    shared: true,
    dateTimeLabelFormats: {
    	hour: '%H:%M'
    }
  },

  // Common options for all series
  plotOptions: {
    series: {
      // There are many ways to handle time data in Highcharts.
      // This way we omit the timestamp from each data point, and
      // rely on each data point being one hour apart.
      pointInterval: 36e5 // one hour
    }
  },

  series: [{
    name: 'Users',
    color: '#1F75FF',
    data: [
      990, 652, 965, 1048, 939, 1012, 2089, 3995, 4123, 4302, 5289, 6115,
      7723, 8162, 10089, 7812, 4127, 3812, 4156, 3805, 2958, 1984, 1432, 1299
    ]
  }, {
    name: 'Average',
    color: '#8791BA',
    dashStyle: 'dot',
    marker: {
      enabled: false
    },
    data: [
      865, 832, 775, 728, 779, 812, 989, 1095, 1623, 2102, 2289, 2315, 2412,
      2662, 3089, 2812, 2427, 2112, 2356, 2305, 1858, 1084, 932, 899
    ]
  }]
})