Description:
Add more series and handle minimum as well.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r509:936237b8677a -

@@ -32,7 +32,10
32 public static Dictionary<String, bool> data_sets_show = new Dictionary<string,bool> {
32 public static Dictionary<String, bool> data_sets_show = new Dictionary<string,bool> {
33 {"Total Funds", false},
33 {"Total Funds", false},
34 {"Subsidies", false},
34 {"Subsidies", false},
35 {"Upkeep", false}};
35 {"Upkeep", false},
36 {"Contracts", false},
37 {"Cashflow", false},
38 {"Misc", false}};
36
39
37 public static void Render(ImFontPtr font, Simulation sim, ImGuiWindowBridgeEngine engine)
40 public static void Render(ImFontPtr font, Simulation sim, ImGuiWindowBridgeEngine engine)
38 {
41 {
@@ -60,6 +63,9
60 data_sets["Total Funds"] = sim.allBudgets().Select(b => (double)b.money);
63 data_sets["Total Funds"] = sim.allBudgets().Select(b => (double)b.money);
61 data_sets["Subsidies"] = sim.allBudgets().Select(b => (double)b.subsidy);
64 data_sets["Subsidies"] = sim.allBudgets().Select(b => (double)b.subsidy);
62 data_sets["Upkeep"] = sim.allBudgets().Select(b => (double)b.upkeep);
65 data_sets["Upkeep"] = sim.allBudgets().Select(b => (double)b.upkeep);
66 data_sets["Contracts"] = sim.allBudgets().Select(b => (double)b.contracts);
67 data_sets["Misc"] = sim.allBudgets().Select(b => (double)b.misc);
68 data_sets["Cashflow"] = sim.allBudgets().Select(b => (double)b.cashflow);
63
69
64 var periods = 12.0d * GraphWindow.year;
70 var periods = 12.0d * GraphWindow.year;
65 var keys = data_sets_show.Keys.ToList();
71 var keys = data_sets_show.Keys.ToList();
@@ -67,6 +73,7
67 var totals = data_sets["Total Funds"];
73 var totals = data_sets["Total Funds"];
68
74
69 var max = 0.0d;
75 var max = 0.0d;
76 var min = 0.0d;
70
77
71 foreach( var key in keys) {
78 foreach( var key in keys) {
72 if (data_sets_show[key] && totals.Count() > 0) {
79 if (data_sets_show[key] && totals.Count() > 0) {
@@ -75,7 +82,15
75 }
82 }
76 }
83 }
77
84
78 ImPlot.SetNextPlotLimits(totals.Count()-periods, totals.Count(), 0.0d, max , ImGuiCond.Always);
85 foreach( var key in keys) {
86 if (data_sets_show[key] && totals.Count() > 0) {
87 var series_min = data_sets[key].Min();
88 series_min = series_min >= 0? series_min * 0.90f : series_min *1.10f;
89 min = Math.Min(series_min, min);
90 }
91 }
92
93 ImPlot.SetNextPlotLimits(totals.Count()-periods, totals.Count(), min, max , ImGuiCond.Always);
79 if( ImPlot.BeginPlot("My Plot")) {
94 if( ImPlot.BeginPlot("My Plot")) {
80 // Span<double> totals = new Span<double>(new double[]{0.0, 1.0, 2.0, 9.0});
95 // Span<double> totals = new Span<double>(new double[]{0.0, 1.0, 2.0, 9.0});
81 foreach (var key in keys) {
96 foreach (var key in keys) {
You need to be logged in to leave comments. Login now