Highcharts Demo
author(s): Torstein Hønsi
by mohdali
HTML
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="result"></div>
<table id="table-sparkline">
<thead>
<tr>
<th>Rate</th>
<th>Last 24 Hours</th>
<th>Current</th>
<th>Target</th>
</tr>
</thead>
<tbody id="tbody-sparkline">
<tr>
<th>Oil Production</th>
<td data-sparkline="150, 100, 200, 185 "/>
<td class='good'>185,000 </td>
<td>200,000 STB/Day</td>
</tr>
<tr>
<th>Water Production</th>
<td data-sparkline="71, 78, 39, 30 "/>
<td class='bad'>30,000 </td>
<td>25,000 STB/day</td>
</tr>
<tr>
<th>Gas Production</th>
<td data-sparkline="50, 55, 60, 62, 65 "/>
<td class='good'>55.0</td>
<td>60.0 MMscf/day</td>
</tr>
</tbody>
</table>
CSS
body {
background-color: white;
font-family: Arial, sans-serif;
}
.good {
color: yellowgreen;
font-weight: bold;
}
.bad {
color: red;
font-weight: bold;
}
#result {
text-align: right;
color: gray;
min-height: 2em;
}
#table-sparkline {
margin: 0 auto;
border-collapse: collapse;
}
th {
font-weight: bold;
text-align: left;
}
td, th {
padding: 5px;
border-bottom: 1px solid silver;
height: 20px;
}
thead th {
border-top: 2px solid gray;
border-bottom: 2px solid gray;
}
.highcharts-tooltip>span {
background: white;
border: 1px solid silver;
border-radius: 3px;
box-shadow: 1px 1px 2px #888;
padding: 8px;
}
JavaScript
/**
* Create a constructor for sparklines that takes some sensible defaults and merges in the individual
* chart options. This function is also available from the jQuery plugin as $(element).highcharts('SparkLine').
*/
Highcharts.SparkLine = function (a, b, c) {
var hasRenderToArg = typeof a === 'string' || a.nodeName,
options = arguments[hasRenderToArg ? 1 : 0],
defaultOptions = {
chart: {
renderTo: (options.chart && options.chart.renderTo) || this,
backgroundColor: null,
borderWidth: 0,
type: 'line',
margin: [2, 0, 2, 0],
width: 120,
height: 20,
style: {
overflow: 'visible'
},
// small optimalization, saves 1-2 ms each sparkline
skipClone: true
},
title: {
text: ''
},
credits: {
enabled: false
},
xAxis: {
labels: {
enabled: false
},
title: {
text: null
},
startOnTick: false,
endOnTick: false,
tickPositions: [],
lineWidth: 0,
gridLineWidth: 0
},
yAxis: {
endOnTick: false,
startOnTick: false,
labels: {
enabled: false
},
title: {
text: null
},
tickPositions: [0],
lineWidth: 0
},
legend: {
enabled: false
},
tooltip: {
backgroundColor: null,
borderWidth: 0,
shadow: false,
useHTML: true,
hideDelay: 0,
shared:...