Im new to this forum and this is my first Question! I hope you could help me out with it :)
i "stole" some sample code which im editing right now, but i cant figure out where i could state my if because i want to make the chart personal.
private calculateData(data: Array<Object>, config: ChartConfiguration): Object {
var values: Array<number> = [];
var labels: Object = this.getUnique(data, config);
var dataVal: Array<Array<any>> = this.getValues(data, labels['unique'], config);
switch (config.act) {
case 'sum':
dataVal.forEach((vals, i) => {
values[i] = 0;
vals.forEach((val) => {
values[i] += parseFloat(val);
});
});
break;
//its about this case where i want to make the label if label = x then parse values
case 'point':
dataVal.forEach((vals, i) => {
values[i] = 0;
vals.forEach((val) => {
if (dataVal.indexOf('x') != -1) {
values[i] = parseFloat(val);
}
});
}
);
break;
case 'average':
dataVal.forEach((vals, i) => {
values[i] = 0;
vals.forEach((val) => {
values[i] += parseFloat(val);
});
if (values[i] != 0) {
values[i] = values[i] / vals.length;
}
});
break;
case 'count':
dataVal.forEach((vals) => {
values.push(vals.length);
});
break;
default:
values = [100, 250, 90, 300];
break;
}
return { data: values, labels: labels['labels'] };
}
Aucun commentaire:
Enregistrer un commentaire