# HG changeset patch # User Alys Brooks # Date 2022-01-08 18:58:34 # Node ID 7dba0456323a955d81e97566f1ede66c07ee07ad # Parent ce998c162896308428e9e8e2b9938a797f767cab Support multiple data series. diff --git a/isometric-park-fna/UI/Graph.cs b/isometric-park-fna/UI/Graph.cs --- a/isometric-park-fna/UI/Graph.cs +++ b/isometric-park-fna/UI/Graph.cs @@ -21,10 +21,15 @@ public static bool hadFocus = false; public static int year = 1; + public static bool show_totals = false; + public static bool show_subsidies = false; + public static bool show_upkeep = false; public static void Render(ImFontPtr font, Simulation sim, ImGuiWindowBridgeEngine engine) { bool newShow = true; + + ImGui.PushFont(font); ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None; @@ -46,9 +51,12 @@ // ImGui.Text("Lorem Ipsum"); var totals = sim.allBudgets().Select(b => (double)b.money); - + var subsidies = sim.allBudgets().Select(b => (double)b.subsidy); + var upkeep = sim.allBudgets().Select(b => (double)b.upkeep); var totals_array = totals.ToArray(); + var subsidies_array = subsidies.ToArray(); + var upkeep_array = upkeep.ToArray(); var periods = 12.0d * GraphWindow.year; @@ -57,13 +65,19 @@ if( ImPlot.BeginPlot("My Plot")) { // Span totals = new Span(new double[]{0.0, 1.0, 2.0, 9.0}); - if (totals_array.Length > 0) + if (totals_array.Length > 0 && show_totals) { - // ImGui.PlotLines("MainGraph", ref totals[0], totals.Length, 0, null, float.MaxValue, float.MaxValue, new Num.Vector2(350, 200)); - // ImPlot.PlotLine("My Line", ref MemoryMarshal.GetReference(totals), ref MemoryMarshal.GetReference(totals), totals.Length); - // Logging.Info(String.Format("Max: {0}", max.ToString())); ImPlot.PlotLine("Total Funds", ref totals_array[0], totals_array.Length); } + if (subsidies_array.Length > 0 && show_subsidies) + { + ImPlot.PlotLine("Subsidies", ref subsidies_array[0], subsidies_array.Length); + } + if (upkeep_array.Length > 0 && show_upkeep) + { + ImPlot.PlotLine("Upkeep", ref upkeep_array[0], upkeep_array.Length); + } + ImPlot.EndPlot(); } @@ -76,6 +90,10 @@ ImGui.SameLine(); ImGui.RadioButton("100 years", ref GraphWindow.year, 100); + if (Menu.activeButton("Totals", show_totals, StyleSets.selected, StyleSets.white)) + { + GraphWindow.show_totals = !GraphWindow.show_totals; + } diff --git a/isometric-park-fna/UI/Menu.cs b/isometric-park-fna/UI/Menu.cs --- a/isometric-park-fna/UI/Menu.cs +++ b/isometric-park-fna/UI/Menu.cs @@ -16,7 +16,7 @@ public const int MENU_BAR_HEIGHT = 20; - private static bool activeButton(string label, bool active, Num.Vector4 activeColor, Num.Vector4 activeTextColor) { + public static bool activeButton(string label, bool active, Num.Vector4 activeColor, Num.Vector4 activeTextColor) { if (active) { ImGui.PushStyleColor(ImGuiCol.Button, activeColor);