ChartWindow: Added second graph for gebunden
This commit is contained in:
@ -26,6 +26,22 @@ namespace Elwig.Helpers.Billing {
|
||||
DataY = dataY;
|
||||
}
|
||||
|
||||
public double GetOechsleAt(int index) {
|
||||
return DataX[index];
|
||||
}
|
||||
|
||||
public void SetOechsleAt(int index, double oechsle) {
|
||||
DataX[index] = oechsle;
|
||||
}
|
||||
|
||||
public void SetPriceAt(int index, double price) {
|
||||
DataY[index] = price;
|
||||
}
|
||||
|
||||
public double GetPriceAt(int index) {
|
||||
return DataY[index];
|
||||
}
|
||||
|
||||
private void ParseGraphData(Dictionary<double, decimal> graphPoints, int minX, int maxX) {
|
||||
if (graphPoints.Keys.Count < 1) {
|
||||
return;
|
||||
@ -71,19 +87,48 @@ namespace Elwig.Helpers.Billing {
|
||||
}
|
||||
}
|
||||
|
||||
public void FlattenGraph(int begin, int end, double value) {
|
||||
private void FlattenGraph(int begin, int end, double value) {
|
||||
for (int i = begin; i <= end; i++) {
|
||||
DataY[i] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void LinearIncreaseGraph(int begin, int end, double inc) {
|
||||
public void FlattenGraphLeft(int pointIndex) {
|
||||
FlattenGraph(0, pointIndex, DataY[pointIndex]);
|
||||
}
|
||||
|
||||
public void FlattenGraphRight(int pointIndex) {
|
||||
FlattenGraph(pointIndex, DataY.Length - 1, DataY[pointIndex]);
|
||||
}
|
||||
|
||||
private void LinearIncreaseGraph(int begin, int end, double inc) {
|
||||
for (int i = begin; i < end; i++) {
|
||||
DataY[i + 1] = DataY[i] + inc;
|
||||
DataY[i + 1] = Math.Round(DataY[i] + inc, 4); //TODO richtig runden
|
||||
}
|
||||
}
|
||||
|
||||
public JsonObject ToJson(string mode) {
|
||||
public void LinearIncreaseGraphToEnd(int begin, double inc) {
|
||||
LinearIncreaseGraph(begin, DataY.Length - 1, inc);
|
||||
}
|
||||
|
||||
public void InterpolateGraph(int firstPoint, int secondPoint) {
|
||||
int steps = Math.Abs(firstPoint - secondPoint);
|
||||
if (firstPoint == -1 || secondPoint == -1 || steps < 2) {
|
||||
return;
|
||||
}
|
||||
var (lowIndex, highIndex) = firstPoint < secondPoint ? (firstPoint, secondPoint) : (secondPoint, firstPoint);
|
||||
double step = (DataY[highIndex] - DataY[lowIndex]) / steps;
|
||||
|
||||
for (int i = lowIndex; i < highIndex - 1; i++) {
|
||||
DataY[i + 1] = Math.Round(DataY[i] + step, 4); // TODO richtig runden
|
||||
}
|
||||
}
|
||||
|
||||
public JsonNode ToJson(string mode) {
|
||||
if (DataY.Distinct().Count() == 1) {
|
||||
return JsonValue.Create(DataY[0]);
|
||||
}
|
||||
|
||||
var data = new JsonObject();
|
||||
|
||||
if (DataY[0] != DataY[1]) {
|
||||
|
Reference in New Issue
Block a user