From 4046426b2e948bceb6e39af8d1e50586e90bec11 Mon Sep 17 00:00:00 2001 From: Matthew Strasiotto <39424834+matthewstrasiotto@users.noreply.github.com> Date: Tue, 27 Apr 2021 19:44:22 +1000 Subject: set chart props in own function --- grapher/Models/Charts/ChartXY.cs | 50 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'grapher/Models/Charts/ChartXY.cs') diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index bd80ea2..133d314 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -89,6 +89,39 @@ namespace grapher #region Methods + public static void setChartColors(Chart chart) + { + //global::grapher.Models.Serialized.GUISettings + System.Drawing.Color fgColor = global::grapher.Properties.Settings.Default.Chart_FG_Colour; + System.Drawing.Color bgColor = global::grapher.Properties.Settings.Default.Chart_BG_Colour; + System.Drawing.Color bgTrans = System.Drawing.Color.Transparent; + + chart.ForeColor = fgColor; + chart.Titles[0].ForeColor = fgColor; + + chart.ChartAreas[0].AxisX.LabelStyle.ForeColor = fgColor; + chart.ChartAreas[0].AxisY.LabelStyle.ForeColor = fgColor; + + chart.ChartAreas[0].AxisX.LineColor = fgColor; + chart.ChartAreas[0].AxisY.LineColor = fgColor; + chart.ChartAreas[0].AxisY.MajorTickMark.LineColor = fgColor; + chart.ChartAreas[0].AxisX.MajorTickMark.LineColor = fgColor; + + chart.ChartAreas[0].AxisX.MajorGrid.LineColor = fgColor; + chart.ChartAreas[0].AxisY.MajorGrid.LineColor = fgColor; + + chart.ChartAreas[0].AxisX.MinorGrid.LineColor = fgColor; + chart.Legends[0].ForeColor = fgColor; + + chart.ChartAreas[0].AxisX.TitleForeColor = fgColor; + chart.ChartAreas[0].AxisY.TitleForeColor = fgColor; + + chart.ChartAreas[0].BorderColor = fgColor; + + chart.Legends[0].BackColor = bgTrans; + chart.ChartAreas[0].BackColor = bgTrans; + } + public static void SetupChart(Chart chart) { chart.ChartAreas[0].AxisX.RoundAxisValues(); @@ -98,7 +131,7 @@ namespace grapher chart.ChartAreas[0].AxisY.ScaleView.MinSize = 0.01; chart.ChartAreas[0].AxisY.ScaleView.SmallScrollSize = 0.001; - + chart.ChartAreas[0].AxisX.LabelStyle.Format = "0.##"; chart.ChartAreas[0].AxisY.LabelStyle.Format = "0.##"; @@ -116,7 +149,20 @@ namespace grapher chart.Series[1].Points.Clear(); chart.Series[1].Points.AddXY(0, 0); - chart.Titles[0].Font = new System.Drawing.Font(chart.Titles[0].Font.Name, 9.0f, System.Drawing.FontStyle.Italic); + chart.ChartAreas[0].AxisX.TitleFont = new System.Drawing.Font(chart.ChartAreas[0].AxisX.TitleFont.Name, global::grapher.Properties.Settings.Default.Chart_Axis_Font_Size, System.Drawing.FontStyle.Bold); + chart.ChartAreas[0].AxisY.TitleFont = chart.ChartAreas[0].AxisX.TitleFont; + + chart.Titles[0].Font = new System.Drawing.Font(chart.Titles[0].Font.Name, global::grapher.Properties.Settings.Default.Chart_Font_Size, System.Drawing.FontStyle.Italic | System.Drawing.FontStyle.Bold); + int line_width = global::grapher.Properties.Settings.Default.Chart_Series_Line_Width; + chart.Series[0].BorderWidth = line_width; + chart.Series[0].MarkerSize = line_width; + chart.Series[2].BorderWidth = line_width; + chart.Series[2].MarkerSize = line_width; + + chart.ChartAreas[0].AxisX.MinorGrid.Enabled = true; + chart.ChartAreas[0].AxisX.MinorGrid.LineDashStyle = ChartDashStyle.Dot; + + setChartColors(chart); } public static void DrawPoint(Chart chart, PointData pointOne, PointData pointTwo = null) -- cgit v1.2.3 From 576e4837abdc6919c27fb642e3ba95895d15ce63 Mon Sep 17 00:00:00 2001 From: Matthew Strasiotto <39424834+matthewstrasiotto@users.noreply.github.com> Date: Tue, 27 Apr 2021 22:32:27 +1000 Subject: refactor chart styling a bit --- grapher/Models/Charts/ChartXY.cs | 55 +++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 20 deletions(-) (limited to 'grapher/Models/Charts/ChartXY.cs') diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index 133d314..39e1a92 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -91,12 +91,13 @@ namespace grapher public static void setChartColors(Chart chart) { - //global::grapher.Models.Serialized.GUISettings System.Drawing.Color fgColor = global::grapher.Properties.Settings.Default.Chart_FG_Colour; System.Drawing.Color bgColor = global::grapher.Properties.Settings.Default.Chart_BG_Colour; System.Drawing.Color bgTrans = System.Drawing.Color.Transparent; chart.ForeColor = fgColor; + chart.BackColor = bgColor; + chart.Titles[0].ForeColor = fgColor; chart.ChartAreas[0].AxisX.LabelStyle.ForeColor = fgColor; @@ -124,43 +125,57 @@ namespace grapher public static void SetupChart(Chart chart) { - chart.ChartAreas[0].AxisX.RoundAxisValues(); + ChartArea area = chart.ChartAreas[0]; + Legend legend = chart.Legends[0]; + Title title = chart.Titles[0]; + + area.AxisX.RoundAxisValues(); - chart.ChartAreas[0].AxisX.ScaleView.Zoomable = true; - chart.ChartAreas[0].AxisY.ScaleView.Zoomable = true; + area.AxisX.ScaleView.Zoomable = true; + area.AxisY.ScaleView.Zoomable = true; - chart.ChartAreas[0].AxisY.ScaleView.MinSize = 0.01; - chart.ChartAreas[0].AxisY.ScaleView.SmallScrollSize = 0.001; + area.AxisY.ScaleView.MinSize = 0.01; + area.AxisY.ScaleView.SmallScrollSize = 0.001; - chart.ChartAreas[0].AxisX.LabelStyle.Format = "0.##"; - chart.ChartAreas[0].AxisY.LabelStyle.Format = "0.##"; + area.AxisX.LabelStyle.Format = "0.##"; + area.AxisY.LabelStyle.Format = "0.##"; - chart.ChartAreas[0].CursorY.Interval = 0.001; + area.CursorY.Interval = 0.001; - chart.ChartAreas[0].CursorX.AutoScroll = true; - chart.ChartAreas[0].CursorY.AutoScroll = true; + area.CursorX.AutoScroll = true; + area.CursorY.AutoScroll = true; - chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; - chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true; + area.CursorX.IsUserSelectionEnabled = true; + area.CursorY.IsUserSelectionEnabled = true; - chart.ChartAreas[0].CursorX.IsUserEnabled = true; - chart.ChartAreas[0].CursorY.IsUserEnabled = true; + area.CursorX.IsUserEnabled = true; + area.CursorY.IsUserEnabled = true; chart.Series[1].Points.Clear(); chart.Series[1].Points.AddXY(0, 0); - chart.ChartAreas[0].AxisX.TitleFont = new System.Drawing.Font(chart.ChartAreas[0].AxisX.TitleFont.Name, global::grapher.Properties.Settings.Default.Chart_Axis_Font_Size, System.Drawing.FontStyle.Bold); - chart.ChartAreas[0].AxisY.TitleFont = chart.ChartAreas[0].AxisX.TitleFont; + area.AxisX.TitleFont = new System.Drawing.Font(area.AxisX.TitleFont.Name, global::grapher.Properties.Settings.Default.Chart_Axis_Font_Size, System.Drawing.FontStyle.Bold); + area.AxisY.TitleFont = area.AxisX.TitleFont; - chart.Titles[0].Font = new System.Drawing.Font(chart.Titles[0].Font.Name, global::grapher.Properties.Settings.Default.Chart_Font_Size, System.Drawing.FontStyle.Italic | System.Drawing.FontStyle.Bold); + title.Font = new System.Drawing.Font(title.Font.Name, global::grapher.Properties.Settings.Default.Chart_Font_Size, System.Drawing.FontStyle.Italic | System.Drawing.FontStyle.Bold); int line_width = global::grapher.Properties.Settings.Default.Chart_Series_Line_Width; chart.Series[0].BorderWidth = line_width; chart.Series[0].MarkerSize = line_width; chart.Series[2].BorderWidth = line_width; chart.Series[2].MarkerSize = line_width; - chart.ChartAreas[0].AxisX.MinorGrid.Enabled = true; - chart.ChartAreas[0].AxisX.MinorGrid.LineDashStyle = ChartDashStyle.Dot; + area.AxisX.MinorGrid.Enabled = true; + area.AxisX.MinorGrid.LineDashStyle = ChartDashStyle.Dot; + + title.Alignment = System.Drawing.ContentAlignment.MiddleCenter; + + legend.DockedToChartArea = area.Name; + legend.LegendStyle = LegendStyle.Row; + + ElementPosition legendPos = legend.Position; + + ElementPosition legendPosNew = new ElementPosition(100 -, 0, legendPos.Width, legendPos.Height); + legend.Position = legendPosNew; setChartColors(chart); } -- cgit v1.2.3 From 5a08acbffecb50aa8426e221bbd8457c114f7eda Mon Sep 17 00:00:00 2001 From: Matthew Strasiotto <39424834+matthewstrasiotto@users.noreply.github.com> Date: Wed, 28 Apr 2021 13:33:23 +1000 Subject: change legend position for graphs --- grapher/Models/Charts/ChartXY.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grapher/Models/Charts/ChartXY.cs') diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index 39e1a92..237538f 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -174,7 +174,7 @@ namespace grapher ElementPosition legendPos = legend.Position; - ElementPosition legendPosNew = new ElementPosition(100 -, 0, legendPos.Width, legendPos.Height); + ElementPosition legendPosNew = new ElementPosition(75, 0, 25, 25); legend.Position = legendPosNew; setChartColors(chart); -- cgit v1.2.3 From fe5cd0a2f0c02878af32c80655d1bd3f3b6a2107 Mon Sep 17 00:00:00 2001 From: Matthew Strasiotto <39424834+matthewstrasiotto@users.noreply.github.com> Date: Sat, 1 May 2021 20:09:43 +1000 Subject: Implement ChartXY.SetStreaming, sets colours, colors not set in setup --- grapher/Models/Charts/ChartXY.cs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'grapher/Models/Charts/ChartXY.cs') diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index 237538f..d2247cb 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -89,10 +89,10 @@ namespace grapher #region Methods - public static void setChartColors(Chart chart) + public static void setChartColors(Chart chart, System.Drawing.Color fgColor, System.Drawing.Color bgColor) { - System.Drawing.Color fgColor = global::grapher.Properties.Settings.Default.Chart_FG_Colour; - System.Drawing.Color bgColor = global::grapher.Properties.Settings.Default.Chart_BG_Colour; + // System.Drawing.Color fgColor = global::grapher.Properties.Settings.Default.Chart_FG_Colour; + // System.Drawing.Color bgColor = global::grapher.Properties.Settings.Default.Chart_BG_Colour; System.Drawing.Color bgTrans = System.Drawing.Color.Transparent; chart.ForeColor = fgColor; @@ -176,8 +176,6 @@ namespace grapher ElementPosition legendPosNew = new ElementPosition(75, 0, 25, 25); legend.Position = legendPosNew; - - setChartColors(chart); } public static void DrawPoint(Chart chart, PointData pointOne, PointData pointTwo = null) @@ -374,6 +372,22 @@ namespace grapher ChartY.Height = height; } + public void SetStreaming(bool streaming) + { + var fgColor = Constants.fgNoStreamer; + var bgColor = Constants.bgNoStreamer; + + if (streaming) + { + fgColor = Constants.fgStreamer; + bgColor = Constants.bgStreamer; + } + + setChartColors(ChartX, fgColor, bgColor); + setChartColors(ChartY, fgColor, bgColor); + Update(); + } + private string SetComponentTitle(string component) { return $"{Title} : {component}"; -- cgit v1.2.3 From fa12d9c4df758245c34fd61e910d148a83c81b04 Mon Sep 17 00:00:00 2001 From: Matthew Strasiotto <39424834+matthewstrasiotto@users.noreply.github.com> Date: Sat, 1 May 2021 20:22:45 +1000 Subject: Update marker size for charts to be bigger --- grapher/Models/Charts/ChartXY.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'grapher/Models/Charts/ChartXY.cs') diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index d2247cb..969607c 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -160,9 +160,9 @@ namespace grapher title.Font = new System.Drawing.Font(title.Font.Name, global::grapher.Properties.Settings.Default.Chart_Font_Size, System.Drawing.FontStyle.Italic | System.Drawing.FontStyle.Bold); int line_width = global::grapher.Properties.Settings.Default.Chart_Series_Line_Width; chart.Series[0].BorderWidth = line_width; - chart.Series[0].MarkerSize = line_width; + chart.Series[0].MarkerSize = line_width * 2; chart.Series[2].BorderWidth = line_width; - chart.Series[2].MarkerSize = line_width; + chart.Series[2].MarkerSize = line_width * 2; area.AxisX.MinorGrid.Enabled = true; area.AxisX.MinorGrid.LineDashStyle = ChartDashStyle.Dot; -- cgit v1.2.3 From 9a506f235ce7903e345f2deecccdfd91bbc88304 Mon Sep 17 00:00:00 2001 From: Matthew Strasiotto <39424834+matthewstrasiotto@users.noreply.github.com> Date: Sat, 1 May 2021 20:33:57 +1000 Subject: remove Settings.Settings based config, migrate defintitions to constants --- grapher/Models/Charts/ChartXY.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'grapher/Models/Charts/ChartXY.cs') diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index 969607c..d247264 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -91,8 +91,6 @@ namespace grapher public static void setChartColors(Chart chart, System.Drawing.Color fgColor, System.Drawing.Color bgColor) { - // System.Drawing.Color fgColor = global::grapher.Properties.Settings.Default.Chart_FG_Colour; - // System.Drawing.Color bgColor = global::grapher.Properties.Settings.Default.Chart_BG_Colour; System.Drawing.Color bgTrans = System.Drawing.Color.Transparent; chart.ForeColor = fgColor; @@ -154,15 +152,15 @@ namespace grapher chart.Series[1].Points.Clear(); chart.Series[1].Points.AddXY(0, 0); - area.AxisX.TitleFont = new System.Drawing.Font(area.AxisX.TitleFont.Name, global::grapher.Properties.Settings.Default.Chart_Axis_Font_Size, System.Drawing.FontStyle.Bold); + area.AxisX.TitleFont = new System.Drawing.Font(area.AxisX.TitleFont.Name, Constants.ChartAxisFontSize, System.Drawing.FontStyle.Bold); area.AxisY.TitleFont = area.AxisX.TitleFont; - title.Font = new System.Drawing.Font(title.Font.Name, global::grapher.Properties.Settings.Default.Chart_Font_Size, System.Drawing.FontStyle.Italic | System.Drawing.FontStyle.Bold); - int line_width = global::grapher.Properties.Settings.Default.Chart_Series_Line_Width; - chart.Series[0].BorderWidth = line_width; - chart.Series[0].MarkerSize = line_width * 2; - chart.Series[2].BorderWidth = line_width; - chart.Series[2].MarkerSize = line_width * 2; + title.Font = new System.Drawing.Font(title.Font.Name, Constants.ChartTitleFontSize, System.Drawing.FontStyle.Italic | System.Drawing.FontStyle.Bold); + + chart.Series[0].BorderWidth = Constants.ChartSeriesLineWidth; + chart.Series[0].MarkerSize = Constants.ChartSeriesLineWidth * 2; + chart.Series[2].BorderWidth = Constants.ChartSeriesLineWidth; + chart.Series[2].MarkerSize = Constants.ChartSeriesLineWidth * 2; area.AxisX.MinorGrid.Enabled = true; area.AxisX.MinorGrid.LineDashStyle = ChartDashStyle.Dot; -- cgit v1.2.3 From 039cb2a72735dd4a28d9bca38cb08c3dc8f09e8a Mon Sep 17 00:00:00 2001 From: Matthew Strasiotto <39424834+matthewstrasiotto@users.noreply.github.com> Date: Sat, 1 May 2021 20:58:30 +1000 Subject: set transparencies for chart elements in setup method --- grapher/Models/Charts/ChartXY.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'grapher/Models/Charts/ChartXY.cs') diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index d247264..98c7fe5 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -91,8 +91,6 @@ namespace grapher public static void setChartColors(Chart chart, System.Drawing.Color fgColor, System.Drawing.Color bgColor) { - System.Drawing.Color bgTrans = System.Drawing.Color.Transparent; - chart.ForeColor = fgColor; chart.BackColor = bgColor; @@ -117,8 +115,7 @@ namespace grapher chart.ChartAreas[0].BorderColor = fgColor; - chart.Legends[0].BackColor = bgTrans; - chart.ChartAreas[0].BackColor = bgTrans; + } public static void SetupChart(Chart chart) @@ -174,6 +171,11 @@ namespace grapher ElementPosition legendPosNew = new ElementPosition(75, 0, 25, 25); legend.Position = legendPosNew; + + System.Drawing.Color bgTrans = System.Drawing.Color.Transparent; + + area.BackColor = bgTrans; + legend.BackColor = bgTrans; } public static void DrawPoint(Chart chart, PointData pointOne, PointData pointTwo = null) -- cgit v1.2.3 From f7b46406eebf3c606e042c7f1853d3d78a65fea5 Mon Sep 17 00:00:00 2001 From: Matthew Strasiotto <39424834+matthewstrasiotto@users.noreply.github.com> Date: Sat, 1 May 2021 21:03:11 +1000 Subject: remove unused variable, improve legend position --- grapher/Models/Charts/ChartXY.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'grapher/Models/Charts/ChartXY.cs') diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index 98c7fe5..5bafb94 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -166,10 +166,8 @@ namespace grapher legend.DockedToChartArea = area.Name; legend.LegendStyle = LegendStyle.Row; - - ElementPosition legendPos = legend.Position; - ElementPosition legendPosNew = new ElementPosition(75, 0, 25, 25); + ElementPosition legendPosNew = new ElementPosition(25, 0, 50, 25); legend.Position = legendPosNew; System.Drawing.Color bgTrans = System.Drawing.Color.Transparent; -- cgit v1.2.3