Skip to content

Instantly share code, notes, and snippets.

@JamesAndresCM
Created May 18, 2018 00:55
Show Gist options
  • Save JamesAndresCM/86a1b8591866f36b466b64f63a9e6430 to your computer and use it in GitHub Desktop.
Save JamesAndresCM/86a1b8591866f36b466b64f63a9e6430 to your computer and use it in GitHub Desktop.
parseData(json: any){
for (let indice in json.body.indicesItem){
let entry = json.body.indicesItem[indice].indice;
if (entry.trim() == "IGPA" || entry.trim() == "IPSA" || entry.trim() == "INTER-10"){
this.datos.push({
key: "indice",
value: json.body.indicesItem[indice],
});
}
}
for (let i in this.datos){
let fecha = Array.of(this.datos[i].value.fecha);
let ind_ant = Array.of(this.datos[i].value.ind_ant);
let ind_act = Array.of(this.datos[i].value.ind_act);
this.chart = new Chart('canvas', {
type: 'bar',
data: {
labels: fecha,
datasets: [
{
label: "Indice Actual",
data: ind_act,
borderColor: '#3cba9f',
fill: true
},
{
label: "Indice Anterior",
data: ind_ant,
borderColor: '#ffcc00',
fill: true
},
]
},
options: {
legend: {
display: true,
position: 'top',
labels: {
boxWidth: 80,
fontColor: 'black'
}
},
scales: {
xAxes: [{
display: true
}],
yAxes: [{
display: true
}]
}
}
})
}
//this.chart.reset();
console.log(this.datos);
this.comercios = this.datos;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment