ChartWindow: Make gebunden type fixed more user friendly
This commit is contained in:
@ -210,21 +210,21 @@ namespace Elwig.Helpers.Billing {
|
||||
var x = graph.DataX;
|
||||
var y = graph.DataY;
|
||||
if (y.Distinct().Count() == 1) {
|
||||
return JsonValue.Create(graph.DataY[0]);
|
||||
return JsonValue.Create((decimal)graph.DataY[0]);
|
||||
}
|
||||
|
||||
var data = new JsonObject();
|
||||
|
||||
if (y[0] != y[1]) {
|
||||
data.Add(new KeyValuePair<string, JsonNode?>(x[0] + mode, Math.Round(y[0], graph.Precision)));
|
||||
data[$"{x[0]}{mode}"] = Math.Round(y[0], graph.Precision);
|
||||
}
|
||||
for (int i = 1; i < x.Length - 1; i++) {
|
||||
if (Math.Round(y[i] - y[i - 1], 10) != Math.Round(y[i + 1] - y[i], 10)) {
|
||||
data.Add(new KeyValuePair<string, JsonNode?>(x[i] + mode, Math.Round(y[i], graph.Precision)));
|
||||
data[$"{x[i]}{mode}"] = Math.Round(y[i], graph.Precision);
|
||||
}
|
||||
}
|
||||
if (y[^1] != y[^2]) {
|
||||
data.Add(new KeyValuePair<string, JsonNode?>(x[^1] + mode, Math.Round(y[^1], graph.Precision)));
|
||||
data[$"{x[^1]}{mode}"] = Math.Round(y[^1], graph.Precision);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
@ -247,16 +247,6 @@ namespace Elwig.Helpers.Billing {
|
||||
}
|
||||
|
||||
public JsonObject FromGraphEntries(IEnumerable<GraphEntry> graphEntries) {
|
||||
var payment = new JsonObject();
|
||||
var curves = new JsonArray();
|
||||
|
||||
foreach (var entry in graphEntries) {
|
||||
curves.Add(GraphEntryToJson(entry));
|
||||
foreach (var contract in entry.Contracts) {
|
||||
payment[$"{contract.Variety?.SortId}/{contract.Attribute?.AttrId}"] = $"curve:{entry.Id}";
|
||||
}
|
||||
}
|
||||
|
||||
var data = new JsonObject {
|
||||
["mode"] = "elwig",
|
||||
["version"] = 1,
|
||||
@ -270,6 +260,16 @@ namespace Elwig.Helpers.Billing {
|
||||
if (ConsiderAutoBusinessShares)
|
||||
data["consider_auto_business_shares"] = true;
|
||||
|
||||
var payment = new JsonObject();
|
||||
var curves = new JsonArray();
|
||||
|
||||
foreach (var entry in graphEntries) {
|
||||
curves.Add(GraphEntryToJson(entry));
|
||||
foreach (var contract in entry.Contracts) {
|
||||
payment[$"{contract.Variety?.SortId}/{contract.Attribute?.AttrId}"] = $"curve:{entry.Id}";
|
||||
}
|
||||
}
|
||||
|
||||
data["payment"] = payment;
|
||||
data["curves"] = curves;
|
||||
|
||||
|
Reference in New Issue
Block a user