Skip to content

Instantly share code, notes, and snippets.

@mikechau
Last active December 17, 2015 13:59
Show Gist options
  • Save mikechau/5620889 to your computer and use it in GitHub Desktop.
Save mikechau/5620889 to your computer and use it in GitHub Desktop.
JSON Parsing
$(function () {
$('#container').highcharts({
chart: {
type: 'bar'
},
title: {
text: 'Leading Indicators'
},
subtitle: {
text: 'Source: Rbandits::Trdopt'
},
xAxis: {
categories: ["AUTO", "SPRD", "ISOI", "REG", "SPIM", "CMBO"],
title: {
text: null
}
},
yAxis: {
min: 0,
title: {
text: 'Total',
align: 'high'
},
labels: {
overflow: 'justify'
}
},
plotOptions: {
bar: {
dataLabels: {
enabled: true,
style: {
color: 'black'
}
}
},
series: {
//stacking: 'normal',
borderWidth: 1,
pointPadding: 0,
groupPadding: 0
}
},
legend: {
enabled: false,
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -100,
y: 100,
floating: true,
borderWidth: 1,
backgroundColor: '#FFFFFF',
shadow: true
},
credits: {
enabled: false
},
series: [{ name: "Instruments", data: [576754, 118035, 104525, 93434, 52229, 13259]}]
});
});
<script src="http://code.highcharts.com/stock/highstock.js" type="text/javascript"></script>
<div id="container" style="height:540px"></div>
<script>
$(function () {
$('#container').highcharts({
chart: {
type: 'bar'
},
title: {
text: 'Leading Indicators'
},
subtitle: {
text: 'Source: Rbandits::Trdopt'
},
xAxis: {
categories: ["AUTO", "SPRD", "ISOI", "REG", "SPIM", "CMBO"],
title: {
text: null
}
},
yAxis: {
min: 0,
title: {
text: 'Total',
align: 'high'
},
labels: {
overflow: 'justify'
}
},
plotOptions: {
bar: {
dataLabels: {
enabled: true,
style: {
color: 'black'
}
}
},
series: {
//stacking: 'normal',
borderWidth: 1,
pointPadding: 0,
groupPadding: 0
}
},
legend: {
enabled: false,
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -100,
y: 100,
floating: true,
borderWidth: 1,
backgroundColor: '#FFFFFF',
shadow: true
},
credits: {
enabled: false
},
series: [{ name: "Instruments", data: [576754, 118035, 104525, 93434, 52229, 13259]}]
});
});
</script>
$(function(){
$.getJSON('http://10.0.7.208:3333/demo3.json?utf8=%E2%9C%93&start_date=2013-05-20+09%3A30%3A00&end_date=2013-05-20+23%3A59%3A59&group_type=ind', function(data) {
cats = [];
dats = [];
data.map(function(a) { cats.push(a[0]) });
data.map(function(a) { dats.push(a[1]) });
$('#container').highcharts({
chart: {
type: 'bar'
},
title: {
text: 'Leading Indicators'
},
subtitle: {
text: 'Source: Rbandits::Trdopt'
},
xAxis: {
categories: cats,
title: {
text: null
}
},
yAxis: {
min: 0,
title: {
text: 'Total',
align: 'high'
},
labels: {
overflow: 'justify'
}
},
plotOptions: {
bar: {
dataLabels: {
enabled: true,
style: {
color: 'black'
}
}
},
series: {
//stacking: 'normal',
borderWidth: 1,
pointPadding: 0,
groupPadding: 0
}
},
legend: {
enabled: false,
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -100,
y: 100,
floating: true,
borderWidth: 1,
backgroundColor: '#FFFFFF',
shadow: true
},
credits: {
enabled: false
},
series: [{ name: "Instruments", data: dats }]
});
});
});
[["AUTO",576754],["SPRD",118035],["ISOI",104525],["REG",93434],["SPIM",52229],["CMBO",13259],["STDL",11871],["BWRT",7724],["LATE",201],["CANC",191],["CNCL",68],["AJST",66],["CNCO",56],["XMPT",53],["OPNL",27],["CNOL",16],["OSEQ",16],["OPEN",1]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment