diff --git a/WebCms/App_Data/Models/all.dll.path b/WebCms/App_Data/Models/all.dll.path index c81d02c..2530678 100644 --- a/WebCms/App_Data/Models/all.dll.path +++ b/WebCms/App_Data/Models/all.dll.path @@ -1 +1 @@ -C:\Users\poprhythm\AppData\Local\Temp\Temporary ASP.NET Files\vs\f80e29bb\faae20bf\App_Web_all.generated.cs.8f9494c4.0nm7wrgc.dll \ No newline at end of file +C:\Users\poprhythm\AppData\Local\Temp\Temporary ASP.NET Files\vs\f80e29bb\faae20bf\App_Web_all.generated.cs.8f9494c4.pdoxzkxo.dll \ No newline at end of file diff --git a/WebCms/Controllers/ChartController.cs b/WebCms/Controllers/ChartController.cs index 0508e3b..2a8dc64 100644 --- a/WebCms/Controllers/ChartController.cs +++ b/WebCms/Controllers/ChartController.cs @@ -121,7 +121,7 @@ namespace LeafWeb.WebCms.Controllers private IEnumerable GetChartBitmaps(CurveData curveData) { - var charts = LeafGasCharter.ProduceCharts(curveData); + var charts = LeafGasCharter.ProduceCharts(curveData, 1.5); foreach (var chart in charts) { diff --git a/WebCms/Services/LeafGasCharter.cs b/WebCms/Services/LeafGasCharter.cs index 2731557..27b20dc 100644 --- a/WebCms/Services/LeafGasCharter.cs +++ b/WebCms/Services/LeafGasCharter.cs @@ -11,30 +11,85 @@ namespace LeafWeb.WebCms.Services { public static class LeafGasCharter { - private static readonly Font TitleFont = new Font(new FontFamily("Times New Roman"), 10, FontStyle.Bold); - private static readonly Font AxisFont = new Font(new FontFamily("Times New Roman"), 10, FontStyle.Bold); - private static readonly Font Font = new Font(new FontFamily("Trebuchet MS"), 9, FontStyle.Bold); - public const int ChartWidth = 550; - public const int ChartHeight = 400; + private struct Fonts + { + public Font Regular { get; } + public Font Title { get; } + public Font Axis { get; } - // cntrlcomparison - public static IEnumerable ProduceCharts(CurveData curve) + public Fonts(double multiplier) + { + var regSize = CeilingMultiply(9, multiplier); + var titleSize = CeilingMultiply(10, multiplier); + Regular = new Font(new FontFamily("Trebuchet MS"), regSize, FontStyle.Bold); + Title = new Font(new FontFamily("Times New Roman"), titleSize, FontStyle.Bold); + Axis = new Font(new FontFamily("Times New Roman"), titleSize, FontStyle.Bold); + } + } + + private struct ChartSizes + { + public int Width { get; } + public int Height { get; } + public int BorderlineWidth { get; } + + public int RubiscoLimitedMarkerSize { get; } + public int RubiscoLimitedBorderWidth { get; } + + public int RuBPMarkerSize { get; } + public int RuBPBorderWidth { get; } + + public int TpuLimitedMarkerSize { get; } + public int TpuLimitedBorderWidth { get; } + + public int aCurveMarkerSize { get; } + public int aCurveBorderWidth { get; } + + public ChartSizes(double multiplier) + { + Width = CeilingMultiply(550, multiplier); + Height = CeilingMultiply(400, multiplier); + BorderlineWidth = CeilingMultiply(1, multiplier); + + RubiscoLimitedMarkerSize = CeilingMultiply(8, multiplier); + RubiscoLimitedBorderWidth = CeilingMultiply(3, multiplier); + + RuBPMarkerSize = CeilingMultiply(9, multiplier); + RuBPBorderWidth = CeilingMultiply(3, multiplier); + + TpuLimitedMarkerSize = CeilingMultiply(9, multiplier); + TpuLimitedBorderWidth = CeilingMultiply(3, multiplier); + + aCurveMarkerSize = CeilingMultiply(2, multiplier); + aCurveBorderWidth = CeilingMultiply(1, multiplier); + } + } + + private static int CeilingMultiply(int num, double multiplier) + { + return Convert.ToInt32(Math.Ceiling(num * multiplier)); + } + + // cntrlcomparison + public static IEnumerable ProduceCharts(CurveData curve, double multiplier = 1d) { - var curveId = curve.CurveId; + var curveId = curve.CurveId; + var fonts = new Fonts(multiplier); + var sizes = new ChartSizes(multiplier); - return curve.ParamSets.SelectMany(item => CurveSeries(curveId, item, item.CurveType.GetDescription())); + return curve.ParamSets.SelectMany(item => CurveSeries(curveId, item, item.CurveType.GetDescription(), sizes, fonts)); } - private static IEnumerable CurveSeries(string curveId, CurveParamSet paramSet, string chartTitle) + private static IEnumerable CurveSeries(string curveId, CurveParamSet paramSet, string chartTitle, ChartSizes sizes, Fonts fonts) { - var chloroChart = CreateEmptyChart("Chloroplastic CO2 partial pressure (Pa)", ChartWidth, ChartHeight); - var interChart = CreateEmptyChart("Intercellular CO2 partial pressure (Pa)", ChartWidth, ChartHeight); + var chloroChart = CreateEmptyChart("Chloroplastic CO2 partial pressure (Pa)", sizes, fonts); + var interChart = CreateEmptyChart("Intercellular CO2 partial pressure (Pa)", sizes, fonts); // Set the points for the symbol series for paramater set 1, chloroplastic AddAnetMeasPoints(paramSet.AnetMeasChloro1Data, chloroChart.Series["Rubisco-limited"]); AddAnetMeasPoints(paramSet.AnetMeasChloro2Data, chloroChart.Series["RuBP regeneration-limited"]); - var tpuSeries = NewTpuSeries(paramSet.AnetMeasChloro3Data); + var tpuSeries = NewTpuSeries(paramSet.AnetMeasChloro3Data, sizes); AddAnetMeasPoints(paramSet.AnetMeasChloro3Data, tpuSeries); chloroChart.Series.Add(tpuSeries); @@ -42,7 +97,7 @@ namespace LeafWeb.WebCms.Services AddAnetMeasPoints(paramSet.AnetMeasInter1Data, interChart.Series["Rubisco-limited"]); AddAnetMeasPoints(paramSet.AnetMeasInter2Data, interChart.Series["RuBP regeneration-limited"]); - tpuSeries = NewTpuSeries(paramSet.AnetMeasInter3Data); + tpuSeries = NewTpuSeries(paramSet.AnetMeasInter3Data, sizes); AddAnetMeasPoints(paramSet.AnetMeasInter3Data, tpuSeries); interChart.Series.Add(tpuSeries); @@ -56,29 +111,29 @@ namespace LeafWeb.WebCms.Services AddAsymptotePoints(paramSet.AjInterData, interChart.Series["ajCurve"]); AddAsymptotePoints(paramSet.AtInterData, interChart.Series["atCurve"]); - var title = new Title($"LeafWeb curveID = {curveId}\n{chartTitle}"){Font = TitleFont}; + var title = new Title($"LeafWeb curveID = {curveId}\n{chartTitle}"){Font = fonts.Title}; chloroChart.Titles.Add(title); interChart.Titles.Add(title); - chloroChart.ChartAreas["ChartArea"].AxisX.TitleFont = AxisFont; - chloroChart.ChartAreas["ChartArea"].AxisY.TitleFont = AxisFont; + chloroChart.ChartAreas["ChartArea"].AxisX.TitleFont = fonts.Axis; + chloroChart.ChartAreas["ChartArea"].AxisY.TitleFont = fonts.Axis; - interChart.ChartAreas["ChartArea"].AxisX.TitleFont = AxisFont; - interChart.ChartAreas["ChartArea"].AxisY.TitleFont = AxisFont; + interChart.ChartAreas["ChartArea"].AxisX.TitleFont = fonts.Axis; + interChart.ChartAreas["ChartArea"].AxisY.TitleFont = fonts.Axis; yield return chloroChart; yield return interChart; } - private static Series NewTpuSeries(IReadOnlyCollection data) + private static Series NewTpuSeries(IReadOnlyCollection data, ChartSizes sizes) { var seriesName = "TPU-limited"; if (data.Count == 0) seriesName = "Curve Asymptote"; var series3 = new Series(seriesName) { - MarkerSize = 9, - BorderWidth = 3, + MarkerSize = sizes.TpuLimitedMarkerSize, + BorderWidth = sizes.TpuLimitedBorderWidth, XValueType = ChartValueType.Double, ChartType = SeriesChartType.Point, MarkerStyle = MarkerStyle.Square, @@ -110,18 +165,18 @@ namespace LeafWeb.WebCms.Services } } - private static Chart CreateEmptyChart(string axisXTitle, int width=700, int height=500) + private static Chart CreateEmptyChart(string axisXTitle, ChartSizes sizes, Fonts fonts) { var borderColor = Color.FromArgb(180, 26, 59, 105); var chart = new Chart { BackColor = Color.White, - Width = Unit.Pixel(width), - Height = Unit.Pixel(height), + Width = Unit.Pixel(sizes.Width), + Height = Unit.Pixel(sizes.Height), //BorderSkin = {SkinStyle = BorderSkinStyle.None}, BorderColor = borderColor, BorderlineColor = borderColor, - BorderlineWidth = 1, + BorderlineWidth = sizes.BorderlineWidth, BorderlineDashStyle = ChartDashStyle.Solid }; @@ -132,8 +187,8 @@ namespace LeafWeb.WebCms.Services Name = "Default", Docking = Docking.Bottom, BackColor = Color.Transparent, - Font = Font - }); + Font = fonts.Regular + }); chart.ChartAreas.Add(new ChartArea { @@ -148,7 +203,7 @@ namespace LeafWeb.WebCms.Services { LineColor = Color.FromArgb(64, 64, 64, 64), Title = "Net assimilation rate (umol/m2/s)", - LabelStyle = { Font = Font }, + LabelStyle = { Font = fonts.Regular }, MajorGrid = new Grid { LineColor = Color.FromArgb(64, 64, 64, 64)} }, AxisX = new Axis @@ -156,15 +211,15 @@ namespace LeafWeb.WebCms.Services LineColor = Color.FromArgb(64, 64, 64, 64), Minimum = 0, Title = axisXTitle, - LabelStyle = { Font = Font }, + LabelStyle = { Font = fonts.Regular }, MajorGrid = new Grid { LineColor = Color.FromArgb(64, 64, 64, 64)} } }); chart.Series.Add(new Series { - MarkerSize = 8, - BorderWidth = 3, + MarkerSize = sizes.RubiscoLimitedMarkerSize, + BorderWidth = sizes.RubiscoLimitedBorderWidth, XValueType = ChartValueType.Double, Name = "Rubisco-limited", ChartType = SeriesChartType.Point, @@ -178,8 +233,8 @@ namespace LeafWeb.WebCms.Services chart.Series.Add(new Series { - MarkerSize = 9, - BorderWidth = 3, + MarkerSize = sizes.RuBPMarkerSize, + BorderWidth = sizes.RuBPBorderWidth, XValueType = ChartValueType.Double, Name = "RuBP regeneration-limited", ChartType = SeriesChartType.Point, @@ -193,8 +248,8 @@ namespace LeafWeb.WebCms.Services chart.Series.Add(new Series { - MarkerSize = 2, - BorderWidth = 1, + MarkerSize = sizes.aCurveMarkerSize, + BorderWidth = sizes.aCurveBorderWidth, XValueType = ChartValueType.Double, Name = "acCurve", ChartType = SeriesChartType.Line, @@ -209,8 +264,8 @@ namespace LeafWeb.WebCms.Services chart.Series.Add(new Series { - MarkerSize = 2, - BorderWidth = 1, + MarkerSize = sizes.aCurveMarkerSize, + BorderWidth = sizes.aCurveBorderWidth, XValueType = ChartValueType.Double, Name = "ajCurve", ChartType = SeriesChartType.Line, @@ -225,8 +280,8 @@ namespace LeafWeb.WebCms.Services chart.Series.Add(new Series { - MarkerSize = 2, - BorderWidth = 1, + MarkerSize = sizes.aCurveMarkerSize, + BorderWidth = sizes.aCurveBorderWidth, XValueType = ChartValueType.Double, Name = "atCurve", ChartType = SeriesChartType.Line,