Skip to content

Instantly share code, notes, and snippets.

@BrunoDSouza
Created July 2, 2017 06:44
Show Gist options
  • Save BrunoDSouza/880d8671cbed720da79b5f30191e0ed6 to your computer and use it in GitHub Desktop.
Save BrunoDSouza/880d8671cbed720da79b5f30191e0ed6 to your computer and use it in GitHub Desktop.
var chartFaturamento = {
create : function(element){
$.ajax({
type : "GET",
contentType : "application/json",
url : "/ajax/chartFaturamento",
success : function(data, statusText, xhr) {
//Instancia de um novo map<month, value>
data = new Map(JSON.parse(data)
.map(function(v, k, array){
return Object.values(array[k])
}))
var month = Array.from(data.keys())
var dados = Array.from(data.values())
Highcharts.chart(element, {
title: {
text: ''
},
exporting:{
enabled : false
},
xAxis: {
categories: month
},
tooltip: {
pointFormat: 'Retorno de <b>R${point.y:,.0f}</b><br/>'
},
series: [{
type: 'column',
colorByPoint: true,
data: dados,
showInLegend: true
}],
});
},
error : function(e) {
alert("ERROR: " + e.responseText)
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment