Add Leaf Charting

This commit is contained in:
2015-12-02 11:53:15 -05:00
parent 93e0a35cf5
commit 743ea4c3f3
10 changed files with 298 additions and 220 deletions
+4 -4
View File
@@ -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;
}
+193 -211
View File
@@ -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<XyPoint> data)
private static Series newTPUSeries(IReadOnlyCollection<XyPoint> 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<XyPoint> data, Series series)
private static void setAnetMeasPoints(List<XyPoint> 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<XyPoint> data, Series series)
private static void setAsymptotePoints(List<XyPoint> data, Series series)
{
// Set the points for the series from the ArrayList
foreach (var xy in data)
+2 -1
View File
@@ -7,8 +7,9 @@ namespace LeafWeb.Web.Charter
[Serializable]
public class PiscalOutput
{
private readonly List<CurveData> _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> _curveData;
public PiscalOutput()
{