From 743ea4c3f34f20857409063ba87aa85a5f846f95 Mon Sep 17 00:00:00 2001 From: James Kolpack Date: Wed, 2 Dec 2015 11:53:15 -0500 Subject: [PATCH] Add Leaf Charting --- Core/Services/ParseInfoAttribute.cs | 2 +- Web/App_Start/BundleConfig.cs | 2 +- Web/App_Start/RouteConfig.cs | 2 + Web/Charter/CurveData.cs | 8 +- Web/Charter/LeafWebCharter.ascx.cs | 404 +++++++++++++--------------- Web/Charter/PiscalOutput.cs | 3 +- Web/Content/site.css | 15 ++ Web/Controllers/PagesController.cs | 63 ++++- Web/Views/Pages/LeafCharter.cshtml | 1 + Web/Web.csproj | 18 +- 10 files changed, 298 insertions(+), 220 deletions(-) create mode 100644 Web/Content/site.css create mode 100644 Web/Views/Pages/LeafCharter.cshtml diff --git a/Core/Services/ParseInfoAttribute.cs b/Core/Services/ParseInfoAttribute.cs index d1b6d49..ef39b68 100644 --- a/Core/Services/ParseInfoAttribute.cs +++ b/Core/Services/ParseInfoAttribute.cs @@ -5,7 +5,7 @@ using LeafWeb.Core.Utility; namespace LeafWeb.Core.Services { - [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] + [AttributeUsage(AttributeTargets.Property)] public class ParseInfoAttribute : Attribute { public int Position { get; private set; } diff --git a/Web/App_Start/BundleConfig.cs b/Web/App_Start/BundleConfig.cs index 4fe1f76..351bb81 100644 --- a/Web/App_Start/BundleConfig.cs +++ b/Web/App_Start/BundleConfig.cs @@ -27,7 +27,7 @@ namespace LeafWeb.Web.App_Start bundles.Add(new StyleBundle("~/bundles/css").Include( "~/Content/bootstrap.css", - "~/Content/LeafWeb.css" + "~/Content/site.css" )); } } diff --git a/Web/App_Start/RouteConfig.cs b/Web/App_Start/RouteConfig.cs index 4264471..2d681f3 100644 --- a/Web/App_Start/RouteConfig.cs +++ b/Web/App_Start/RouteConfig.cs @@ -8,6 +8,8 @@ namespace LeafWeb.Web.App_Start public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); + routes.IgnoreRoute("Content/{*pathInfo}"); + routes.IgnoreRoute("Charter/LeafWebCharter.ascx"); routes.MapRoute( name: "Default", diff --git a/Web/Charter/CurveData.cs b/Web/Charter/CurveData.cs index ebe0985..73a3827 100644 --- a/Web/Charter/CurveData.cs +++ b/Web/Charter/CurveData.cs @@ -36,22 +36,22 @@ namespace LeafWeb.Web.Charter return _curveId; } - public CurveParamSet GetParamSet1() + public CurveParamSet CndctFixedCmpPntFixedParams() { return _paramSet1; } - public CurveParamSet GetParamSet2() + public CurveParamSet CndctFixedCmpPntEstimatedParams() { return _paramSet2; } - public CurveParamSet GetParamSet3() + public CurveParamSet CndctEstimatedCmpPntFixedParams() { return _paramSet3; } - public CurveParamSet GetParamSet4() + public CurveParamSet CndctEstimatedCmpPntEstimatedParams() { return _paramSet4; } diff --git a/Web/Charter/LeafWebCharter.ascx.cs b/Web/Charter/LeafWebCharter.ascx.cs index c45b7c3..f7a807f 100644 --- a/Web/Charter/LeafWebCharter.ascx.cs +++ b/Web/Charter/LeafWebCharter.ascx.cs @@ -5,6 +5,7 @@ using System.Drawing; using System.IO; using System.Web.UI; using System.Web.UI.DataVisualization.Charting; +using System.Web.UI.WebControls; namespace LeafWeb.Web.Charter { @@ -45,7 +46,9 @@ namespace LeafWeb.Web.Charter //CurveDDL.DataBind(); } - public void ProduceChartBTN_Click(PiscalOutput pisOut) + + // cntrlcomparison + public void ProduceCharts(PiscalOutput pisOut) { // If the session has timed out, use the selected index from the GridView // to determine which job to chart. @@ -61,249 +64,228 @@ namespace LeafWeb.Web.Charter var curveData = pisOut.GetCurveData(); var curve = curveData[1]; + var curveId = curve.GetCurveId(); + CurveSeries(curveId, curve.CndctFixedCmpPntFixedParams(), ChartChloro1, ChartInter1, "Internal conductance fixed, compensation point and M-M constants fixed"); + CurveSeries(curveId, curve.CndctFixedCmpPntEstimatedParams(), ChartChloro2, ChartInter2, "Internal conductance fixed, compensation point and M-M constants estimated"); + CurveSeries(curveId, curve.CndctEstimatedCmpPntFixedParams(), ChartChloro3, ChartInter3, "Internal conductance estimated, compensation point and M-M constants fixed"); + CurveSeries(curveId, curve.CndctEstimatedCmpPntEstimatedParams(), ChartChloro4, ChartInter4, "Internal conductance estimated, compensation point and M-M constants estimated"); + } - var paramSet1 = curve.GetParamSet1(); - var paramSet2 = curve.GetParamSet2(); - var paramSet3 = curve.GetParamSet3(); - var paramSet4 = curve.GetParamSet4(); + private static Chart GetChart() + { + var font = new Font(new FontFamily("Trebuchet MS"), 12, FontStyle.Bold); - var paramSet1Anet = paramSet1.GetAnetMeasData(); - var paramSet2Anet = paramSet2.GetAnetMeasData(); - var paramSet3Anet = paramSet3.GetAnetMeasData(); - var paramSet4Anet = paramSet4.GetAnetMeasData(); + var borderColor = Color.FromArgb(180, 26, 59, 105); + var chart = new Chart + { + BackColor = Color.Transparent, + Width = Unit.Pixel(700), + Height = Unit.Pixel(500), + BorderSkin = {SkinStyle = BorderSkinStyle.Emboss}, + BorderColor = borderColor + }; - var anetMeasChloro1PS1Data = paramSet1Anet[0]; - var anetMeasChloro2PS1Data = paramSet1Anet[1]; - var anetMeasChloro3PS1Data = paramSet1Anet[2]; - var anetMeasChloro1PS2Data = paramSet2Anet[0]; - var anetMeasChloro2PS2Data = paramSet2Anet[1]; - var anetMeasChloro3PS2Data = paramSet2Anet[2]; - var anetMeasChloro1PS3Data = paramSet3Anet[0]; - var anetMeasChloro2PS3Data = paramSet3Anet[1]; - var anetMeasChloro3PS3Data = paramSet3Anet[2]; - var anetMeasChloro1PS4Data = paramSet4Anet[0]; - var anetMeasChloro2PS4Data = paramSet4Anet[1]; - var anetMeasChloro3PS4Data = paramSet4Anet[2]; + chart.Legends.Add(new Legend + { + Enabled = true, + IsTextAutoFit = false, + Name = "Default", + Docking = Docking.Bottom, + BackColor = Color.Transparent, + Font = font + }); - var anetMeasInter1PS1Data = paramSet1Anet[3]; - var anetMeasInter2PS1Data = paramSet1Anet[4]; - var anetMeasInter3PS1Data = paramSet1Anet[5]; - var anetMeasInter1PS2Data = paramSet2Anet[3]; - var anetMeasInter2PS2Data = paramSet2Anet[4]; - var anetMeasInter3PS2Data = paramSet2Anet[5]; - var anetMeasInter1PS3Data = paramSet3Anet[3]; - var anetMeasInter2PS3Data = paramSet3Anet[4]; - var anetMeasInter3PS3Data = paramSet3Anet[5]; - var anetMeasInter1PS4Data = paramSet4Anet[3]; - var anetMeasInter2PS4Data = paramSet4Anet[4]; - var anetMeasInter3PS4Data = paramSet4Anet[5]; + chart.ChartAreas.Add(new ChartArea + { + Name = "ChartArea1", + BorderColor = Color.FromArgb(64, 64, 64, 64), + BorderDashStyle = ChartDashStyle.Solid, + BackSecondaryColor = Color.White, + BackColor = Color.OldLace, + ShadowColor = Color.Transparent, + BackGradientStyle = GradientStyle.TopBottom, + Area3DStyle = new ChartArea3DStyle + { + Rotation = 25, + Perspective = 9, + LightStyle = LightStyle.Realistic, + Inclination = 40, + IsRightAngleAxes = false, + WallWidth = 3, + IsClustered = false + }, + AxisY = new Axis + { + LineColor = Color.FromArgb(64, 64, 64, 64), + Title = "Net assimilation rate (umol/m2/s)", + LabelStyle = {Font = font}, + MajorGrid = new Grid {LineColor = Color.FromArgb(64, 64, 64, 64)} + } + }); + + var rubiscoLimited = new Series + { + MarkerSize = 8, + BorderWidth = 3, + XValueType = ChartValueType.Double, + Name = "Rubisco-limited", + ChartType = SeriesChartType.Point, + MarkerStyle = MarkerStyle.Diamond, + ShadowColor = Color.Black, + BorderColor = borderColor, + Color = Color.Red, + ShadowOffset = 0, + YValueType = ChartValueType.Double + }; + var rubpRegenerationLimited = new Series + { + MarkerSize = 9, + BorderWidth = 3, + XValueType = ChartValueType.Double, + Name = "RuBP regeneration-limited", + ChartType = SeriesChartType.Point, + MarkerStyle = MarkerStyle.Circle, + ShadowColor = Color.Black, + BorderColor = borderColor, + Color = Color.Blue, + ShadowOffset = 0, + YValueType = ChartValueType.Double + }; + var acCurve = new Series + { + MarkerSize = 2, + BorderWidth = 1, + XValueType = ChartValueType.Double, + Name = "acCurve", + ChartType = SeriesChartType.Line, + MarkerStyle = MarkerStyle.None, + ShadowColor = Color.Black, + BorderColor = borderColor, + Color = Color.Red, + ShadowOffset = 0, + YValueType = ChartValueType.Double, + IsVisibleInLegend = false + }; + var ajCurve = new Series + { + MarkerSize = 2, + BorderWidth = 1, + XValueType = ChartValueType.Double, + Name = "ajCurve", + ChartType = SeriesChartType.Line, + MarkerStyle = MarkerStyle.None, + ShadowColor = Color.Black, + BorderColor = borderColor, + Color = Color.Blue, + ShadowOffset = 0, + YValueType = ChartValueType.Double, + IsVisibleInLegend = false + }; + var atCurve = new Series + { + MarkerSize = 2, + BorderWidth = 1, + XValueType = ChartValueType.Double, + Name = "atCurve", + ChartType = SeriesChartType.Line, + MarkerStyle = MarkerStyle.None, + ShadowColor = Color.Black, + BorderColor = borderColor, + Color = Color.Orange, + ShadowOffset = 0, + YValueType = ChartValueType.Double, + IsVisibleInLegend = false + }; + + return chart; + } + + private static void CurveSeries(string curveId, CurveParamSet paramSet, Chart chloroChart, Chart interChart, string chartTitle) + { + var paramSetAnet = paramSet.GetAnetMeasData(); + + var anetMeasChloro1 = paramSetAnet[0]; + var anetMeasChloro2 = paramSetAnet[1]; + var anetMeasChloro3 = paramSetAnet[2]; // Set the points for the symbol series for paramater set 1, chloroplastic - setAnetMeasPoints(anetMeasChloro1PS1Data, ChartChloro1.Series["Rubisco-limited"]); - setAnetMeasPoints(anetMeasChloro2PS1Data, ChartChloro1.Series["RuBP regeneration-limited"]); + setAnetMeasPoints(anetMeasChloro1, chloroChart.Series["Rubisco-limited"]); + setAnetMeasPoints(anetMeasChloro2, chloroChart.Series["RuBP regeneration-limited"]); - var tpuSeries = newTPUSeries(anetMeasChloro3PS1Data); - setAnetMeasPoints(anetMeasChloro3PS1Data, tpuSeries); - ChartChloro1.Series.Add(tpuSeries); + var tpuSeries = newTPUSeries(anetMeasChloro3); + setAnetMeasPoints(anetMeasChloro3, tpuSeries); + chloroChart.Series.Add(tpuSeries); - // Set the points for the symbol series for paramater set 2, chloroplastic - setAnetMeasPoints(anetMeasChloro1PS2Data, ChartChloro2.Series["Rubisco-limited"]); - setAnetMeasPoints(anetMeasChloro2PS2Data, ChartChloro2.Series["RuBP regeneration-limited"]); - - tpuSeries = newTPUSeries(anetMeasChloro3PS2Data); - setAnetMeasPoints(anetMeasChloro3PS2Data, tpuSeries); - ChartChloro2.Series.Add(tpuSeries); - - // Set the points for the symbol series for paramater set 3, chloroplastic - setAnetMeasPoints(anetMeasChloro1PS3Data, ChartChloro3.Series["Rubisco-limited"]); - setAnetMeasPoints(anetMeasChloro2PS3Data, ChartChloro3.Series["RuBP regeneration-limited"]); - - tpuSeries = newTPUSeries(anetMeasChloro3PS3Data); - setAnetMeasPoints(anetMeasChloro3PS3Data, tpuSeries); - ChartChloro3.Series.Add(tpuSeries); - - // Set the points for the symbol series for paramater set 4, chloroplastic - setAnetMeasPoints(anetMeasChloro1PS4Data, ChartChloro4.Series["Rubisco-limited"]); - setAnetMeasPoints(anetMeasChloro2PS4Data, ChartChloro4.Series["RuBP regeneration-limited"]); - - tpuSeries = newTPUSeries(anetMeasChloro3PS4Data); - setAnetMeasPoints(anetMeasChloro3PS4Data, tpuSeries); - ChartChloro4.Series.Add(tpuSeries); + var anetMeasInter1 = paramSetAnet[3]; + var anetMeasInter2 = paramSetAnet[4]; + var anetMeasInter3 = paramSetAnet[5]; // Set the points for the symbol series for paramater set 1, intercellular - setAnetMeasPoints(anetMeasInter1PS1Data, ChartInter1.Series["Rubisco-limited"]); - setAnetMeasPoints(anetMeasInter2PS1Data, ChartInter1.Series["RuBP regeneration-limited"]); + setAnetMeasPoints(anetMeasInter1, interChart.Series["Rubisco-limited"]); + setAnetMeasPoints(anetMeasInter2, interChart.Series["RuBP regeneration-limited"]); - tpuSeries = newTPUSeries(anetMeasInter3PS1Data); - setAnetMeasPoints(anetMeasInter3PS1Data, tpuSeries); - ChartInter1.Series.Add(tpuSeries); + tpuSeries = newTPUSeries(anetMeasInter3); + setAnetMeasPoints(anetMeasInter3, tpuSeries); + interChart.Series.Add(tpuSeries); - // Set the points for the symbol series for paramater set 2, intercellular - setAnetMeasPoints(anetMeasInter1PS2Data, ChartInter2.Series["Rubisco-limited"]); - setAnetMeasPoints(anetMeasInter2PS2Data, ChartInter2.Series["RuBP regeneration-limited"]); - - tpuSeries = newTPUSeries(anetMeasInter3PS2Data); - setAnetMeasPoints(anetMeasInter3PS2Data, tpuSeries); - ChartInter2.Series.Add(tpuSeries); - - // Set the points for the symbol series for paramater set 3, intercellular - setAnetMeasPoints(anetMeasInter1PS3Data, ChartInter3.Series["Rubisco-limited"]); - setAnetMeasPoints(anetMeasInter2PS3Data, ChartInter3.Series["RuBP regeneration-limited"]); - - tpuSeries = newTPUSeries(anetMeasInter3PS3Data); - setAnetMeasPoints(anetMeasInter3PS3Data, tpuSeries); - ChartInter3.Series.Add(tpuSeries); - - // Set the points for the symbol series for paramater set 4, intercellular - setAnetMeasPoints(anetMeasInter1PS4Data, ChartInter4.Series["Rubisco-limited"]); - setAnetMeasPoints(anetMeasInter2PS4Data, ChartInter4.Series["RuBP regeneration-limited"]); - - tpuSeries = newTPUSeries(anetMeasInter3PS4Data); - setAnetMeasPoints(anetMeasInter3PS4Data, tpuSeries); - ChartInter4.Series.Add(tpuSeries); - - var acChloroListPS1 = paramSet1.GetAcChloroData(); - var ajChloroListPS1 = paramSet1.GetAjChloroData(); - var atChloroListPS1 = paramSet1.GetAtChloroData(); - var acChloroListPS2 = paramSet2.GetAcChloroData(); - var ajChloroListPS2 = paramSet2.GetAjChloroData(); - var atChloroListPS2 = paramSet2.GetAtChloroData(); - var acChloroListPS3 = paramSet3.GetAcChloroData(); - var ajChloroListPS3 = paramSet3.GetAjChloroData(); - var atChloroListPS3 = paramSet3.GetAtChloroData(); - var acChloroListPS4 = paramSet4.GetAcChloroData(); - var ajChloroListPS4 = paramSet4.GetAjChloroData(); - var atChloroListPS4 = paramSet4.GetAtChloroData(); - - var acInterListPS1 = paramSet1.GetAcInterData(); - var ajInterListPS1 = paramSet1.GetAjInterData(); - var atInterListPS1 = paramSet1.GetAtInterData(); - var acInterListPS2 = paramSet2.GetAcInterData(); - var ajInterListPS2 = paramSet2.GetAjInterData(); - var atInterListPS2 = paramSet2.GetAtInterData(); - var acInterListPS3 = paramSet3.GetAcInterData(); - var ajInterListPS3 = paramSet3.GetAjInterData(); - var atInterListPS3 = paramSet3.GetAtInterData(); - var acInterListPS4 = paramSet4.GetAcInterData(); - var ajInterListPS4 = paramSet4.GetAjInterData(); - var atInterListPS4 = paramSet4.GetAtInterData(); + var acChloroList = paramSet.GetAcChloroData(); + var ajChloroList = paramSet.GetAjChloroData(); + var atChloroList = paramSet.GetAtChloroData(); // Set the points on the asymptote curve for parameter set 1, chloroplast - setAsymptotePoints(acChloroListPS1, ChartChloro1.Series["acCurve"]); - setAsymptotePoints(ajChloroListPS1, ChartChloro1.Series["ajCurve"]); - setAsymptotePoints(atChloroListPS1, ChartChloro1.Series["atCurve"]); + setAsymptotePoints(acChloroList, chloroChart.Series["acCurve"]); + setAsymptotePoints(ajChloroList, chloroChart.Series["ajCurve"]); + setAsymptotePoints(atChloroList, chloroChart.Series["atCurve"]); - // Set the points on the asymptote curve for parameter set 2, chloroplast - setAsymptotePoints(acChloroListPS2, ChartChloro2.Series["acCurve"]); - setAsymptotePoints(ajChloroListPS2, ChartChloro2.Series["ajCurve"]); - setAsymptotePoints(atChloroListPS2, ChartChloro2.Series["atCurve"]); - - // Set the points on the asymptote curve for parameter set 3, chloroplast - setAsymptotePoints(acChloroListPS3, ChartChloro3.Series["acCurve"]); - setAsymptotePoints(ajChloroListPS3, ChartChloro3.Series["ajCurve"]); - setAsymptotePoints(atChloroListPS3, ChartChloro3.Series["atCurve"]); - - // Set the points on the asymptote curve for parameter set 4, chloroplast - setAsymptotePoints(acChloroListPS4, ChartChloro4.Series["acCurve"]); - setAsymptotePoints(ajChloroListPS4, ChartChloro4.Series["ajCurve"]); - setAsymptotePoints(atChloroListPS4, ChartChloro4.Series["atCurve"]); + var acInterList = paramSet.GetAcInterData(); + var ajInterList = paramSet.GetAjInterData(); + var atInterList = paramSet.GetAtInterData(); // Set the points on the asymptote curve for parameter set 1, intercellular - setAsymptotePoints(acInterListPS1, ChartInter1.Series["acCurve"]); - setAsymptotePoints(ajInterListPS1, ChartInter1.Series["ajCurve"]); - setAsymptotePoints(atInterListPS1, ChartInter1.Series["atCurve"]); - - // Set the points on the asymptote curve for parameter set 2, intercellular - setAsymptotePoints(acInterListPS2, ChartInter2.Series["acCurve"]); - setAsymptotePoints(ajInterListPS2, ChartInter2.Series["ajCurve"]); - setAsymptotePoints(atInterListPS2, ChartInter2.Series["atCurve"]); - - // Set the points on the asymptote curve for parameter set 3, intercellular - setAsymptotePoints(acInterListPS3, ChartInter3.Series["acCurve"]); - setAsymptotePoints(ajInterListPS3, ChartInter3.Series["ajCurve"]); - setAsymptotePoints(atInterListPS3, ChartInter3.Series["atCurve"]); - - // Set the points on the asymptote curve for parameter set 4, intercellular - setAsymptotePoints(acInterListPS4, ChartInter4.Series["acCurve"]); - setAsymptotePoints(ajInterListPS4, ChartInter4.Series["ajCurve"]); - setAsymptotePoints(atInterListPS4, ChartInter4.Series["atCurve"]); - - // Now, set the minimum and maximum values for the X-axis. The - // Y-axis seems to be doing OK in auto mode. - - //Chart1.ChartAreas["ChartArea1"].AxisX.Minimum = 0; - //Chart1.ChartAreas["ChartArea1"].AxisX.Maximum = - // ((int)(maxX / 10) + 1) * 10; - //Chart1.ChartAreas["ChartArea1"].AxisX.Interval = 10; + setAsymptotePoints(acInterList, interChart.Series["acCurve"]); + setAsymptotePoints(ajInterList, interChart.Series["ajCurve"]); + setAsymptotePoints(atInterList, interChart.Series["atCurve"]); var axisFont = new Font("Times New Roman", 12, FontStyle.Bold); var titleFont = new Font("Times New Roman", 12, FontStyle.Bold); - var titlePS1 = new Title("LeafWeb curveID = " + curveId + - "\nInternal conductance fixed, compensation point and M-M constants fixed"); - titlePS1.Font = titleFont; - ChartChloro1.Titles.Add(titlePS1); - ChartInter1.Titles.Add(titlePS1); + var title = new Title("LeafWeb curveID = " + curveId + + "\n" + chartTitle); + title.Font = titleFont; + chloroChart.Titles.Add(title); + interChart.Titles.Add(title); - var titlePS2 = new Title("LeafWeb curveID = " + curveId + - "\nInternal conductance fixed, compensation point and M-M constants estimated"); - titlePS2.Font = titleFont; - ChartChloro2.Titles.Add(titlePS2); - ChartInter2.Titles.Add(titlePS2); + chloroChart.ChartAreas["ChartArea1"].AxisX.TitleFont = axisFont; + chloroChart.ChartAreas["ChartArea1"].AxisY.TitleFont = axisFont; - var titlePS3 = new Title("LeafWeb curveID = " + curveId + - "\nInternal conductance estimated, compensation point and M-M constants fixed"); - titlePS3.Font = titleFont; - ChartChloro3.Titles.Add(titlePS3); - ChartInter3.Titles.Add(titlePS3); - - var titlePS4 = new Title("LeafWeb curveID = " + curveId + - "\nInternal conductance estimated, compensation point and M-M constants estimated"); - titlePS4.Font = titleFont; - ChartChloro4.Titles.Add(titlePS4); - ChartInter4.Titles.Add(titlePS4); - - ChartChloro1.ChartAreas["ChartArea1"].AxisX.TitleFont = axisFont; - ChartChloro1.ChartAreas["ChartArea1"].AxisY.TitleFont = axisFont; - ChartChloro2.ChartAreas["ChartArea1"].AxisX.TitleFont = axisFont; - ChartChloro2.ChartAreas["ChartArea1"].AxisY.TitleFont = axisFont; - ChartChloro3.ChartAreas["ChartArea1"].AxisX.TitleFont = axisFont; - ChartChloro3.ChartAreas["ChartArea1"].AxisY.TitleFont = axisFont; - ChartChloro4.ChartAreas["ChartArea1"].AxisX.TitleFont = axisFont; - ChartChloro4.ChartAreas["ChartArea1"].AxisY.TitleFont = axisFont; - - ChartInter1.ChartAreas["ChartArea1"].AxisX.TitleFont = axisFont; - ChartInter1.ChartAreas["ChartArea1"].AxisY.TitleFont = axisFont; - ChartInter2.ChartAreas["ChartArea1"].AxisX.TitleFont = axisFont; - ChartInter2.ChartAreas["ChartArea1"].AxisY.TitleFont = axisFont; - ChartInter3.ChartAreas["ChartArea1"].AxisX.TitleFont = axisFont; - ChartInter3.ChartAreas["ChartArea1"].AxisY.TitleFont = axisFont; - ChartInter4.ChartAreas["ChartArea1"].AxisX.TitleFont = axisFont; - ChartInter4.ChartAreas["ChartArea1"].AxisY.TitleFont = axisFont; + interChart.ChartAreas["ChartArea1"].AxisX.TitleFont = axisFont; + interChart.ChartAreas["ChartArea1"].AxisY.TitleFont = axisFont; } - private Series newTPUSeries(IReadOnlyCollection data) + private static Series newTPUSeries(IReadOnlyCollection data) { var seriesName = "TPU-limited"; if (data.Count == 0) seriesName = "Curve Asymptote"; - var series3 = new Series(seriesName); - series3.MarkerSize = 9; - series3.BorderWidth = 3; - series3.XValueType = ChartValueType.Double; - series3.ChartType = SeriesChartType.Point; - series3.MarkerStyle = MarkerStyle.Square; - series3.ShadowColor = Color.Black; - series3.BorderColor = Color.Black; - series3.Color = Color.Orange; - series3.ShadowOffset = 0; - series3.YValueType = ChartValueType.Double; + var series3 = new Series(seriesName) + { + MarkerSize = 9, + BorderWidth = 3, + XValueType = ChartValueType.Double, + ChartType = SeriesChartType.Point, + MarkerStyle = MarkerStyle.Square, + ShadowColor = Color.Black, + BorderColor = Color.Black, + Color = Color.Orange, + ShadowOffset = 0, + YValueType = ChartValueType.Double + }; return series3; } - private void setAnetMeasPoints(List data, Series series) + private static void setAnetMeasPoints(List data, Series series) { // Set the points for the series from the ArrayList foreach (var xy in data) @@ -312,7 +294,7 @@ namespace LeafWeb.Web.Charter } } - private void setAsymptotePoints(List data, Series series) + private static void setAsymptotePoints(List data, Series series) { // Set the points for the series from the ArrayList foreach (var xy in data) diff --git a/Web/Charter/PiscalOutput.cs b/Web/Charter/PiscalOutput.cs index cfc1afe..b0580ee 100644 --- a/Web/Charter/PiscalOutput.cs +++ b/Web/Charter/PiscalOutput.cs @@ -7,8 +7,9 @@ namespace LeafWeb.Web.Charter [Serializable] public class PiscalOutput { - private readonly List _curveData; // Each element will be a PiscalCurve element that contains + // Each element will be a PiscalCurve element that contains // all of the output data for one curve. + private readonly List _curveData; public PiscalOutput() { diff --git a/Web/Content/site.css b/Web/Content/site.css new file mode 100644 index 0000000..ba73a12 --- /dev/null +++ b/Web/Content/site.css @@ -0,0 +1,15 @@ +* { + margin: 0; +} +html, body { + height: 100%; +} +.wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -155px; /* the bottom margin is the negative value of the footer's height */ +} +footer, .push { + height: 155px; /* .push must be the same height as .footer */ +} \ No newline at end of file diff --git a/Web/Controllers/PagesController.cs b/Web/Controllers/PagesController.cs index 87a5a05..6039ee4 100644 --- a/Web/Controllers/PagesController.cs +++ b/Web/Controllers/PagesController.cs @@ -1,4 +1,9 @@ -using System.Web.Mvc; +using System; +using System.Drawing; +using System.IO; +using System.Web.Mvc; +using System.Web.UI.DataVisualization.Charting; +using System.Web.UI.WebControls; namespace LeafWeb.Web.Controllers { @@ -33,5 +38,61 @@ namespace LeafWeb.Web.Controllers { return View(); } + + public ActionResult LeafCharter() + { + return View(); + } + + public ActionResult ChartSample() + { + var chart = new Chart + { + BackColor = Color.FromArgb(255, 255, 255), + Width = Unit.Pixel(250), + Height = Unit.Pixel(2500) + }; + + var series = new Series + { + ChartArea = "ca1", + ChartType = SeriesChartType.Line + }; + + //series.Font = new Font("Verdana", 8.25f, FontStyle.Regular); + + var myRandom = new Random(); + + for (int i = 0; i < 100; i++) + { + var dp = new DataPoint(); + dp.AxisLabel = String.Format("{0}-{1}", i, Guid.NewGuid().ToString().Substring(0, 4)); + dp.YValues = new double[] { myRandom.Next(5, 100) }; + series.Points.Add(dp); + } + + + chart.Series.Add(series); + + var area = new ChartArea("ca1"); + area.Area3DStyle.Enable3D = false; + area.AxisX.Interval = 1; + //area.BackColor = Color.Transparent; + //var labelStyle = new LabelStyle(); + //labelStyle.Enabled = true; + //labelStyle.Font = new Font("Arial", 3f); + area.AxisX.LabelStyle.Font = new Font("Verdana", 8.25f, FontStyle.Underline);//Why does it recognize the style but not the font!!!??? + + chart.ChartAreas.Add(area); + + using (var ms = new MemoryStream()) + { + chart.SaveImage(ms, ChartImageFormat.Png); + ms.Seek(0, SeekOrigin.Begin); + + return File(ms.ToArray(), "image/png", "mychart.png"); + } + } + } } \ No newline at end of file diff --git a/Web/Views/Pages/LeafCharter.cshtml b/Web/Views/Pages/LeafCharter.cshtml new file mode 100644 index 0000000..0130a4b --- /dev/null +++ b/Web/Views/Pages/LeafCharter.cshtml @@ -0,0 +1 @@ +image \ No newline at end of file diff --git a/Web/Web.csproj b/Web/Web.csproj index 36764f0..0dacb8c 100644 --- a/Web/Web.csproj +++ b/Web/Web.csproj @@ -20,6 +20,7 @@ ..\packages\WebGrease.1.5.2\lib + true @@ -48,6 +49,7 @@ ..\packages\Newtonsoft.Json.5.0.4\lib\net45\Newtonsoft.Json.dll True + @@ -104,10 +106,12 @@ + + @@ -139,6 +143,17 @@ + + + + LeafWebCharter.ascx + ASPXCodeBehind + + + LeafWebCharter.ascx + + + Global.asax @@ -157,6 +172,7 @@ + Web.config @@ -181,7 +197,7 @@ True True - 0 + 34173 / http://localhost:1640/ False