JSFiddle - React, Tailwind, and code Playground
by roedema
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="result"></div>
<table id="table-sparkline">
<thead>
<tr>
<th>Campus</th>
<th>Current response count</th>
<th>Current response rate</th>
<th>Estimated margin of error</th>
<th>Reported population</th>
<th>Reported sample size</th>
<th>Planning form</th>
</tr>
</thead>
<tbody id="tbody-sparkline">
<tr>
<th>California</th>
<td>200</td>
<td data-sparkline="10"/>
<td>217</td>
<td>17</td>
<td>17</td>
<td><a href="#edit">Edit</a></td>
</tr>
<tr>
<th>Colorado</th>
<td>118</td>
<td data-sparkline="13"/>
<td>273</td>
<td>155</td>
<td>155</td>
<td><a href="#edit">Edit</a></td>
</tr>
<tr>
<th>Connecticut</th>
<td>201</td>
<td data-sparkline="6"/>
<td>148</td>
<td>53</td>
<td>53</td>
<td><a href="#edit">Edit</a></td>
</tr>
<tr>
<th>Florida</th>
<td>249</td>
<td data-sparkline="24"/>
<td>244</td>
<td>5</td>
<td>5</td>
<td><a href="#edit">Edit</a></td>
</tr>
<tr>
<th>Illinois</th>
<td>336</td>
<td data-sparkline="56"/>
<td>151</td>
<td>185</td>
<td>185</td>
<td><a href="#edit">Edit</a></td>
</tr>
<tr>
<th>New Jersey</th>
<td>194</td>
<td data-sparkline="31"/>
<td>147</td>
<td>47</td>
<td>47</td>
<td><a href="#edit">Edit</a></td>
</tr>
<tr>
<th>New York</th>
<td>316</td>
...
CSS
#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
$(function () {
/**
* 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 (options, callback) {
var defaultOptions = {
chart: {
renderTo: (options.chart && options.chart.renderTo) || this,
backgroundColor: null,
borderWidth: 0,
type: 'bar',
margin: [2, 0, 2, 0],
width: 120,
height: 20,
style: {
overflow: 'visible'
},
skipClone: true
},
title: {
text: ''
},
credits: {
enabled: false
},
xAxis: {
labels: {
enabled: false
},
title: {
text: null
},
startOnTick: false,
endOnTick: false,
tickPositions: []
},
yAxis: {
endOnTick: false,
startOnTick: false,
labels: {
enabled: false
},
title: {
text: null
},
tickPositions: [0]
},
legend: {
enabled: false
},
tooltip: {
backgroundColor: null,
borderWidth: 0,
shadow: false,
useHTML: true,
hideDelay: 0,
shared: true,
padding: 0,
positioner: function (w, h, point) {
return { x: point.plotX - w / 2, y: point.plotY - h};
}
},
plotOptions: {
...