JSFiddle - React, Tailwind, and code Playground
by g30rg3
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
<button id="toggle" > Sort Toggle</button>
JavaScript
$(function () {
var chart;
$(document).ready(function() {
$('#toggle').click(function(){
var order = chart.series.map(function(v,i){
return {key:v.dataMax,value:v} ;
});
order.sort(function(a,b){
return a.key-b.key
});
series = order.map(function(v,i){
return v.value;
});
cOptions.series = series;
chart = new Highcharts.Chart(cOptions);
});
var cOptions = {
chart: {
renderTo: 'container',
type: 'column'
},
title: {
text: ''
},
subtitle: {
text: ''
},
xAxis: {
categories: [
'foreclosures',
'nuisances',
'distance from city center'
]
},
yAxis: {
min: 0,
title: {
text: ''
}
},
legend: {
},
tooltip: {
formatter: function() {
return ''+
this.x +': '+ this.y +' mm';
}
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [{
name: 'Alger Heights',
data: [49.9, 71.5, 50]
}, {
name: 'Shawmut Hills',
data: [83.6, 78.8, 67]
}, {
name: 'Baxter',
data: [48.9, 38.8, 100]
}, {
name: 'Midtown',
data: [42.4, 33.2, 80]
...