327 lines
14 KiB
C#
327 lines
14 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Web.UI;
|
|
using System.Web.UI.DataVisualization.Charting;
|
|
|
|
namespace LeafWeb.Web.Charter
|
|
{
|
|
|
|
public partial class LeafWebCharter : UserControl
|
|
{
|
|
protected void ReadFile(StreamReader sr, ref String errMsg)
|
|
{
|
|
var pisOut = new PiscalOutput();
|
|
if (!pisOut.ReadFromStream(sr, ref errMsg))
|
|
{
|
|
ErrorLBL.Text = errMsg;
|
|
ErrorLBL.Visible = true;
|
|
return;
|
|
}
|
|
Session["LeafChartData"] = pisOut;
|
|
var aCopy = (PiscalOutput) Session["LeafChartData"];
|
|
|
|
// The data was successfully read from the file. We must now
|
|
// display the curveIDs from the file and prompt the user to pick
|
|
// one of them for charting.
|
|
|
|
var curveDT = new DataTable();
|
|
curveDT.Columns.Add(new DataColumn("curveID"));
|
|
|
|
var curveData = pisOut.GetCurveData();
|
|
for (var i = 0; i < curveData.Count; i++)
|
|
{
|
|
var aCurve = curveData[i];
|
|
var dr = curveDT.NewRow();
|
|
dr["curveID"] = aCurve.GetCurveId();
|
|
curveDT.Rows.Add(dr);
|
|
}
|
|
|
|
//CurveDDL.DataSource = curveDT;
|
|
//CurveDDL.DataTextField = "curveID";
|
|
//CurveDDL.DataValueField = "curveID";
|
|
//CurveDDL.DataBind();
|
|
}
|
|
|
|
public void ProduceChartBTN_Click(PiscalOutput pisOut)
|
|
{
|
|
// If the session has timed out, use the selected index from the GridView
|
|
// to determine which job to chart.
|
|
|
|
// if (aFile.Name.Contains("cntrlcomparison"))
|
|
// {
|
|
// var sr = new StreamReader(aFile.OpenBinaryStream());
|
|
// var errorMessage = "";
|
|
// ReadFile(sr, ref errorMessage);
|
|
// sr.Close();
|
|
// break;
|
|
// }
|
|
|
|
var curveData = pisOut.GetCurveData();
|
|
var curve = curveData[1];
|
|
var curveId = curve.GetCurveId();
|
|
|
|
var paramSet1 = curve.GetParamSet1();
|
|
var paramSet2 = curve.GetParamSet2();
|
|
var paramSet3 = curve.GetParamSet3();
|
|
var paramSet4 = curve.GetParamSet4();
|
|
|
|
var paramSet1Anet = paramSet1.GetAnetMeasData();
|
|
var paramSet2Anet = paramSet2.GetAnetMeasData();
|
|
var paramSet3Anet = paramSet3.GetAnetMeasData();
|
|
var paramSet4Anet = paramSet4.GetAnetMeasData();
|
|
|
|
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];
|
|
|
|
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];
|
|
|
|
// 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"]);
|
|
|
|
var tpuSeries = newTPUSeries(anetMeasChloro3PS1Data);
|
|
setAnetMeasPoints(anetMeasChloro3PS1Data, tpuSeries);
|
|
ChartChloro1.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);
|
|
|
|
// 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"]);
|
|
|
|
tpuSeries = newTPUSeries(anetMeasInter3PS1Data);
|
|
setAnetMeasPoints(anetMeasInter3PS1Data, tpuSeries);
|
|
ChartInter1.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();
|
|
|
|
// 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"]);
|
|
|
|
// 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"]);
|
|
|
|
// 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;
|
|
|
|
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 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);
|
|
|
|
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;
|
|
}
|
|
|
|
private 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;
|
|
|
|
return series3;
|
|
}
|
|
|
|
private void setAnetMeasPoints(List<XyPoint> data, Series series)
|
|
{
|
|
// Set the points for the series from the ArrayList
|
|
foreach (var xy in data)
|
|
{
|
|
series.Points.AddXY(xy.X, xy.Y);
|
|
}
|
|
}
|
|
|
|
private void setAsymptotePoints(List<XyPoint> data, Series series)
|
|
{
|
|
// Set the points for the series from the ArrayList
|
|
foreach (var xy in data)
|
|
{
|
|
if ((xy.X != -9999) && (xy.Y != -9999))
|
|
{
|
|
series.Points.AddXY(xy.X, xy.Y);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |