diff options
| author | Jacob Palecki <[email protected]> | 2020-08-12 19:22:21 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-08-12 19:22:21 -0700 |
| commit | cc531c79f2bd664551071ef315a54814bd9ab914 (patch) | |
| tree | e6d1db3477e8ba41299d1d92eac4748a648c960b /grapher/Models/Charts/ChartXY.cs | |
| parent | Add ability to have x\y graphs (diff) | |
| download | rawaccel-cc531c79f2bd664551071ef315a54814bd9ab914.tar.xz rawaccel-cc531c79f2bd664551071ef315a54814bd9ab914.zip | |
Reorganized solution into directories
Diffstat (limited to 'grapher/Models/Charts/ChartXY.cs')
| -rw-r--r-- | grapher/Models/Charts/ChartXY.cs | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs new file mode 100644 index 0000000..4bb1bd5 --- /dev/null +++ b/grapher/Models/Charts/ChartXY.cs @@ -0,0 +1,142 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Windows.Forms.DataVisualization.Charting; + +namespace grapher +{ + public class ChartXY + { + public const int ChartSeparationHorizontal = 10; + + public ChartXY(Chart chartX, Chart chartY) + { + ChartX = chartX; + ChartY = chartY; + + ChartY.Top = ChartX.Top; + ChartY.Height = ChartX.Height; + ChartY.Width = ChartX.Width; + ChartY.Left = ChartX.Left + ChartX.Width + ChartSeparationHorizontal; + + SetupChart(ChartX); + SetupChart(ChartY); + } + + public Chart ChartX { get; } + + public Chart ChartY { get; } + + public static void SetupChart(Chart chart) + { + chart.ChartAreas[0].AxisX.RoundAxisValues(); + + chart.ChartAreas[0].AxisX.ScaleView.Zoomable = true; + chart.ChartAreas[0].AxisY.ScaleView.Zoomable = true; + + chart.ChartAreas[0].AxisY.ScaleView.MinSize = 0.01; + chart.ChartAreas[0].AxisY.ScaleView.SmallScrollSize = 0.001; + + chart.ChartAreas[0].CursorY.Interval = 0.001; + + chart.ChartAreas[0].CursorX.AutoScroll = true; + chart.ChartAreas[0].CursorY.AutoScroll = true; + + chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; + chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true; + + chart.ChartAreas[0].CursorX.IsUserEnabled = true; + chart.ChartAreas[0].CursorY.IsUserEnabled = true; + } + + public int Height { + get + { + return ChartX.Height; + } + } + + public int Width { + get + { + if (Combined) + { + return ChartX.Width; + } + else + { + return ChartY.Left + ChartY.Width - ChartX.Left; + } + } + } + + public int Top { + get + { + return ChartX.Height; + } + } + + public int Left { + get + { + return ChartX.Left; + } + } + + public bool Combined { get; private set; } + + public void SetCombined() + { + if (!Combined) + { + ChartY.Hide(); + Combined = true; + } + } + + public void SetSeparate() + { + if (Combined) + { + if (ChartX.Visible) + { + ChartY.Show(); + } + + Combined = false; + } + } + + public void Hide() + { + ChartX.Hide(); + ChartY.Hide(); + } + + public void Show() + { + ChartX.Show(); + + if (!Combined) + { + ChartY.Show(); + } + } + + public void SetTop(int top) + { + ChartX.Top = top; + ChartY.Top = top; + } + + public void SetHeight(int height) + { + ChartX.Height = height; + ChartY.Height = height; + } + } +} |