Ich fürchte, Dimple hat keine eingebaute Möglichkeit, damit umzugehen. Ich nehme an, Dimple aggregiert die Daten für Sie - daher die Schwierigkeit. Aber hier haben Sie keine andere Wahl, als auf die Ebene eines Datenpunkts vorzuaggregieren und das berechnete Feld selbst hinzuzufügen. Zum Beispiel, wenn Ihre Daten haben Brand, SKU und Kanal aber Ihr Diagramm war am Brand, Sie Channel-Ebene müssen wie diese die Daten zu-Prozess vor:
// var chartData is going to be the aggregated level you use for your chart.
// var added is a dictionary of aggregated data returning a row index
// for each Brand/Channel combination.
var chartData = [],
added = {};
// Aggregate to the Brand/Channel level
data.forEach(function (d) {
var key = d["Brand"] + "|" + d["Channel"],
i = added[key];
// Check the output index
if (i !== undefined) {
// Brand/Channel have been added already so add the measures
chartData[i]["Sales Value"] += parseFloat(d["Sales Value"]);
chartData[i]["Sales Volume"] += parseFloat(d["Sales Volume"]);
} else {
// Get the index for the row we are about to add
added[key] = chartData.length;
// Insert a new output row for the Brand/Channel
chartData.push({
"Brand": d["Brand"],
"Channel": d["Channel"],
"Sales Value": parseFloat(d["Sales Value"]) || 0,
"Sales Volume": parseFloat(d["Sales Volume"]) || 0
});
}
});
// Calculate ASP
chartData.forEach(function (d) {
d["ASP"] = d["Sales Value"]/d["Sales Volume"];
});
// Draw the chart using chartData instead of data
...
Vielen Dank, wird die Lösung arbeiten :) – Karthik