diff --git a/Core.Tests/Parsers/CntrlComparisonParserTests.cs b/Core.Tests/Parsers/CntrlComparisonParserTests.cs
index 4a4d98c..8821cd6 100644
--- a/Core.Tests/Parsers/CntrlComparisonParserTests.cs
+++ b/Core.Tests/Parsers/CntrlComparisonParserTests.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using LeafWeb.Core.Models;
+using LeafWeb.Core.Models;
using LeafWeb.Core.Parsers;
using NUnit.Framework;
diff --git a/Core/Charter/XYPoint.cs b/Core/Charter/XYPoint.cs
index b75c947..c0b0360 100644
--- a/Core/Charter/XYPoint.cs
+++ b/Core/Charter/XYPoint.cs
@@ -2,9 +2,9 @@
{
public class XyPoint
{
- public double X { get; private set; }
+ public double X { get; }
- public double Y { get; private set; }
+ public double Y { get; }
public XyPoint(double x, double y)
{
diff --git a/Core/Utility/ReflectionExtensions.cs b/Core/Utility/ReflectionExtensions.cs
index 0dfd48f..2ac1fe2 100644
--- a/Core/Utility/ReflectionExtensions.cs
+++ b/Core/Utility/ReflectionExtensions.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Concurrent;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
@@ -9,26 +8,6 @@ using Fasterflect;
namespace LeafWeb.Core.Utility
{
- public static class MemoizationExtensions
- {
- static Func ThreadsafeMemoize(this Func f)
- {
- var cache = new ConcurrentDictionary();
-
- return argument => cache.GetOrAdd(argument, f);
- }
- //static Func ThreadsafeMemoize(this Func f)
- //{
- // var cache = new ConcurrentDictionary>();
-
- // return (a, b) =>
- // {
-
- // return cache.GetOrAdd(a, new ConcurrentDictionary()).GetOrAdd(b, f);
-
- // };
- //}
- }
public static class ReflectionExtensions
{
public static string GetPropertyDisplayName(Expression> propertyExpression)
diff --git a/Web/Charter/LeafWebCharter.cs b/Web/Charter/LeafWebCharter.cs
index 1b08638..5aacff1 100644
--- a/Web/Charter/LeafWebCharter.cs
+++ b/Web/Charter/LeafWebCharter.cs
@@ -4,11 +4,18 @@ using System.Linq;
using System.Web.UI.DataVisualization.Charting;
using System.Web.UI.WebControls;
using LeafWeb.Core.Charter;
+using LeafWeb.Core.Utility;
namespace LeafWeb.Web.Charter
{
public static class LeafWebCharter
{
+ private static readonly Font TitleFont = new Font("Times New Roman", 10, FontStyle.Bold);
+ private static readonly Font AxisFont = new Font("Times New Roman", 10, FontStyle.Bold);
+ private static readonly Font Font = new Font(new FontFamily("Trebuchet MS"), 9, FontStyle.Bold);
+ private const int ChartWidth = 550;
+ private const int ChartHeight = 400;
+
// cntrlcomparison
public static IEnumerable ProduceCharts(CurveData curve)
{
@@ -16,10 +23,10 @@ namespace LeafWeb.Web.Charter
var paramTitles = new[]
{
- new {param = curve.FixedCndFixedCmp, title = "Internal conductance fixed, compensation point and M-M constants fixed" },
- new {param = curve.FixedCndEstimatedCmp, title = "Internal conductance fixed, compensation point and M-M constants estimated" },
- new {param = curve.EstimatedCndFixedCmp, title = "Internal conductance estimated, compensation point and M-M constants fixed" },
- new {param = curve.EstimatedCndEstimatedCmp,title = "Internal conductance estimated, compensation point and M-M constants estimated" },
+ new {param = curve.FixedCndFixedCmp, title = ReflectionExtensions.GetPropertyDisplayName(c => c.FixedCndFixedCmp) },
+ new {param = curve.FixedCndEstimatedCmp, title = ReflectionExtensions.GetPropertyDisplayName(c => c.FixedCndEstimatedCmp) },
+ new {param = curve.EstimatedCndFixedCmp, title = ReflectionExtensions.GetPropertyDisplayName(c => c.EstimatedCndFixedCmp) },
+ new {param = curve.EstimatedCndEstimatedCmp,title = ReflectionExtensions.GetPropertyDisplayName(c => c.EstimatedCndEstimatedCmp) },
};
return paramTitles.SelectMany(item => CurveSeries(curveId, item.param, item.title));
@@ -27,47 +34,44 @@ namespace LeafWeb.Web.Charter
private static IEnumerable CurveSeries(string curveId, CurveParamSet paramSet, string chartTitle)
{
- var chloroChart = GetChart("Chloroplastic CO2 partial pressure (Pa)");
- var interChart = GetChart("Intercellular CO2 partial pressure (Pa)");
+ var chloroChart = CreateEmptyChart("Chloroplastic CO2 partial pressure (Pa)", ChartWidth, ChartHeight);
+ var interChart = CreateEmptyChart("Intercellular CO2 partial pressure (Pa)", ChartWidth, ChartHeight);
// Set the points for the symbol series for paramater set 1, chloroplastic
- SetAnetMeasPoints(paramSet.AnetMeasChloro1Data, chloroChart.Series["Rubisco-limited"]);
- SetAnetMeasPoints(paramSet.AnetMeasChloro2Data, chloroChart.Series["RuBP regeneration-limited"]);
+ AddAnetMeasPoints(paramSet.AnetMeasChloro1Data, chloroChart.Series["Rubisco-limited"]);
+ AddAnetMeasPoints(paramSet.AnetMeasChloro2Data, chloroChart.Series["RuBP regeneration-limited"]);
var tpuSeries = NewTpuSeries(paramSet.AnetMeasChloro3Data);
- SetAnetMeasPoints(paramSet.AnetMeasChloro3Data, tpuSeries);
+ AddAnetMeasPoints(paramSet.AnetMeasChloro3Data, tpuSeries);
chloroChart.Series.Add(tpuSeries);
// Set the points for the symbol series for paramater set 1, intercellular
- SetAnetMeasPoints(paramSet.AnetMeasInter1Data, interChart.Series["Rubisco-limited"]);
- SetAnetMeasPoints(paramSet.AnetMeasInter2Data, interChart.Series["RuBP regeneration-limited"]);
+ AddAnetMeasPoints(paramSet.AnetMeasInter1Data, interChart.Series["Rubisco-limited"]);
+ AddAnetMeasPoints(paramSet.AnetMeasInter2Data, interChart.Series["RuBP regeneration-limited"]);
tpuSeries = NewTpuSeries(paramSet.AnetMeasInter3Data);
- SetAnetMeasPoints(paramSet.AnetMeasInter3Data, tpuSeries);
+ AddAnetMeasPoints(paramSet.AnetMeasInter3Data, tpuSeries);
interChart.Series.Add(tpuSeries);
// Set the points on the asymptote curve for parameter set 1, chloroplast
- SetAsymptotePoints(paramSet.AcChloroData, chloroChart.Series["acCurve"]);
- SetAsymptotePoints(paramSet.AjChloroData, chloroChart.Series["ajCurve"]);
- SetAsymptotePoints(paramSet.AtChloroData, chloroChart.Series["atCurve"]);
+ AddAsymptotePoints(paramSet.AcChloroData, chloroChart.Series["acCurve"]);
+ AddAsymptotePoints(paramSet.AjChloroData, chloroChart.Series["ajCurve"]);
+ AddAsymptotePoints(paramSet.AtChloroData, chloroChart.Series["atCurve"]);
// Set the points on the asymptote curve for parameter set 1, intercellular
- SetAsymptotePoints(paramSet.AcInterData, interChart.Series["acCurve"]);
- SetAsymptotePoints(paramSet.AjInterData, interChart.Series["ajCurve"]);
- SetAsymptotePoints(paramSet.AtInterData, interChart.Series["atCurve"]);
+ AddAsymptotePoints(paramSet.AcInterData, interChart.Series["acCurve"]);
+ AddAsymptotePoints(paramSet.AjInterData, interChart.Series["ajCurve"]);
+ AddAsymptotePoints(paramSet.AtInterData, interChart.Series["atCurve"]);
- var axisFont = new Font("Times New Roman", 12, FontStyle.Bold);
- var titleFont = new Font("Times New Roman", 12, FontStyle.Bold);
-
- var title = new Title($"LeafWeb curveID = {curveId}\n{chartTitle}"){Font = titleFont};
+ var title = new Title($"LeafWeb curveID = {curveId}\n{chartTitle}"){Font = TitleFont};
chloroChart.Titles.Add(title);
interChart.Titles.Add(title);
- chloroChart.ChartAreas["ChartArea1"].AxisX.TitleFont = axisFont;
- chloroChart.ChartAreas["ChartArea1"].AxisY.TitleFont = axisFont;
+ chloroChart.ChartAreas["ChartArea"].AxisX.TitleFont = AxisFont;
+ chloroChart.ChartAreas["ChartArea"].AxisY.TitleFont = AxisFont;
- interChart.ChartAreas["ChartArea1"].AxisX.TitleFont = axisFont;
- interChart.ChartAreas["ChartArea1"].AxisY.TitleFont = axisFont;
+ interChart.ChartAreas["ChartArea"].AxisX.TitleFont = AxisFont;
+ interChart.ChartAreas["ChartArea"].AxisY.TitleFont = AxisFont;
yield return chloroChart;
yield return interChart;
@@ -95,7 +99,7 @@ namespace LeafWeb.Web.Charter
return series3;
}
- private static void SetAnetMeasPoints(List data, Series series)
+ private static void AddAnetMeasPoints(IEnumerable data, Series series)
{
// Set the points for the series from the ArrayList
foreach (var xy in data)
@@ -104,30 +108,28 @@ namespace LeafWeb.Web.Charter
}
}
- private static void SetAsymptotePoints(List data, Series series)
+ private static void AddAsymptotePoints(IEnumerable data, Series series)
{
// Set the points for the series from the ArrayList
- foreach (var xy in data)
+ foreach (var xy in data.Where(xy => (xy.X != -9999) && (xy.Y != -9999)))
{
- if ((xy.X != -9999) && (xy.Y != -9999))
- {
- series.Points.AddXY(xy.X, xy.Y);
- }
+ series.Points.AddXY(xy.X, xy.Y);
}
}
- private static Chart GetChart(string axisXTitle, int width=700, int height=500)
+ private static Chart CreateEmptyChart(string axisXTitle, int width=700, int height=500)
{
- var font = new Font(new FontFamily("Trebuchet MS"), 12, FontStyle.Bold);
-
var borderColor = Color.FromArgb(180, 26, 59, 105);
var chart = new Chart
{
BackColor = Color.White,
Width = Unit.Pixel(width),
Height = Unit.Pixel(height),
- BorderSkin = {SkinStyle = BorderSkinStyle.Emboss},
- BorderColor = borderColor
+ //BorderSkin = {SkinStyle = BorderSkinStyle.None},
+ BorderColor = borderColor,
+ BorderlineColor = borderColor,
+ BorderlineWidth = 1,
+ BorderlineDashStyle = ChartDashStyle.Solid
};
chart.Legends.Add(new Legend
@@ -137,42 +139,32 @@ namespace LeafWeb.Web.Charter
Name = "Default",
Docking = Docking.Bottom,
BackColor = Color.Transparent,
- Font = font
+ Font = Font
});
chart.ChartAreas.Add(new ChartArea
{
- Name = "ChartArea1",
+ Name = "ChartArea",
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)}
+ LabelStyle = { Font = Font },
+ MajorGrid = new Grid { LineColor = Color.FromArgb(64, 64, 64, 64)}
},
AxisX = new Axis
{
LineColor = Color.FromArgb(64, 64, 64, 64),
Minimum = 0,
Title = axisXTitle,
- LabelStyle = {Font = font},
- MajorGrid = new Grid {LineColor = Color.FromArgb(64, 64, 64, 64)}
+ LabelStyle = { Font = Font },
+ MajorGrid = new Grid { LineColor = Color.FromArgb(64, 64, 64, 64)}
}
});