public void PlotOuterBorderForComfortZone(double Tmin, double Tmax, double Hmin, double Hmax, Color c)
{
//Check out-of-bound condition
if ((Tmin < 0 || Tmin > 50)|| (Tmax < 0 || Tmax > 50))
{
return;
}
if ((Hmin < 0 || Hmin > 100) || (Hmax < 0 || Hmax > 100))
{
return;
}
//This function will help to plot the values in the chart.
//First reset the series if present and the re add them
//ADDING LEFT SIDE SERIES => LEFT SIDE BORDER
Series leftSideSeries = new Series("Vertical_Temp_Left_Side");
if (chart1.Series.IndexOf(leftSideSeries.Name) != -1)
{
chart1.Series.RemoveAt(chart1.Series.IndexOf(leftSideSeries.Name));
}
//Now adding it
leftSideSeries.Color = c;
leftSideSeries.ChartType = SeriesChartType.Line ;
leftSideSeries.BorderWidth = 3;
chart1.Series.Add(leftSideSeries);
//This series is for down side
Series rightSideSeries = new Series("Vertical_Temp_Right_Side");
if (chart1.Series.IndexOf(rightSideSeries.Name) != -1)
{
//--This means the series is present....
chart1.Series.RemoveAt(chart1.Series.IndexOf(rightSideSeries.Name));
}
//Now adding it
rightSideSeries.Color = c;
rightSideSeries.ChartType = SeriesChartType.Line;
rightSideSeries.BorderWidth = 3;
chart1.Series.Add(rightSideSeries);
Series downSideSeries = new Series("Horizontal_Hum_Down_Side" );
if (chart1.Series.IndexOf(downSideSeries.Name) != -1)
{
//--This means the series is present....
chart1.Series.RemoveAt(chart1.Series.IndexOf(downSideSeries.Name));
}
//Now adding it
downSideSeries.Color = c;
downSideSeries.ChartType = SeriesChartType.Spline;
downSideSeries.BorderWidth = 3;
chart1.Series.Add(downSideSeries);
Series upperSideSeries = new Series("Horizontal_Hum_Upper_Side");
if (chart1.Series.IndexOf(upperSideSeries.Name) != -1)
{
//--This means the series is present....
chart1.Series.RemoveAt(chart1.Series.IndexOf(upperSideSeries.Name));
}
//Now adding it
upperSideSeries.Color = c;
upperSideSeries.ChartType = SeriesChartType.Spline;
upperSideSeries.BorderWidth = 3;
chart1.Series.Add(upperSideSeries);
//Now lets do the actual plotting part.
double phi_min = Hmin / 100;//need to change to decimal
double phi_max = Hmax / 100;
//This one is for adding horizontal lines
double phi = phi_min; //0.1;
double x2 = 0;
// double indexValue = Hmin;
double patm1 = AirPressureFromDB * 0.001;//101.325; ;//thsi need tochange
for (int temp = (int)Tmin; temp <= (int)Tmax; temp++)
{
double pg_valueX = Double.Parse(pg[temp].ToString());
double wg_calcX = (622 * phi_min * pg_valueX / (patm1 - phi_min * pg_valueX));
double y =wg_calcX;
x2 = temp;//double.Parse(t[i].ToString());
chart1.Series["Horizontal_Hum_Down_Side"].Points.AddXY(x2, y); //Lower Humidity line
//Test
//if (temp == (int)Tmin)
//{
// lb_test1.Text += "horizontal humdown x2-" + x2 + ",y -" + y;
//}
}//close of for
//--Now adding the upper side humidity lines
// phi = phi_max;
for (int temp = (int)Tmin; temp <= (int)Tmax; temp++)
//for (double temp = Tmin; temp <Tmax;temp+=0.25)
{
double pg_value = Double.Parse(pg[temp].ToString());
double wg_calc = (622 * phi_max * pg_value / (patm1 - phi_max * pg_value));
double y =wg_calc;
x2 = temp;//double.Parse(t[i].ToString());
chart1.Series["Horizontal_Hum_Upper_Side"].Points.AddXY(x2, y); //Lower Humidity line
}//close of for
int dataPointNumber =(int)(Tmax - Tmin) / 2;//Middle value
//Now lets add the text to these
string upperHumText = "H= "+(int)Hmax;
string lowerHumText = "H= "+(int)Hmin;
chart1.Series["Horizontal_Hum_Upper_Side"].Points[dataPointNumber].Label = upperHumText;
chart1.Series["Horizontal_Hum_Down_Side"].Points[dataPointNumber].Label = lowerHumText;
//--Now lets add the two lines min temp and max temp lines
//Yvalue of lower left part line
int min_temperature = (int)Tmin;
double min_humidity_yvalue_y1 = 0;
// phi = phi_min;
double pg_value11 = Double.Parse(pg[min_temperature].ToString());
double wg_calc11 = (622 * phi_min * pg_value11 / (patm1 - phi_min * pg_value11));
double y1 = wg_calc11;
min_humidity_yvalue_y1 = y1; // Math.Round(y1,2);//This contains the min humidity lower section value
//Yvalue of upper left part line
double min_humidity_yvalue_y2 = 0;
// phi = phi_min;
double pg_value1122 = Double.Parse(pg[min_temperature].ToString());
double wg_calc1122 = (622 * phi_max * pg_value1122 / (patm1 - phi_max * pg_value1122));
double y122 = wg_calc1122;
min_humidity_yvalue_y2 = y122; //Math.Round(y122, 2);//This contains the min humidity upper section value
//Yvalue of the lower right part line
int max_temperature = (int)Tmax;
double max_humidity_yvalue_y1 = 0;
// phi = phi_max;
double pg_value12 = Double.Parse(pg[max_temperature].ToString());
double wg_calc1223 = (622 * phi_min * pg_value12 / (patm1 - phi_min * pg_value12));
double y21 = wg_calc1223;
max_humidity_yvalue_y1 = y21;// Math.Round(y21, 2);
//Yvalue of the upper right part line
double max_humidity_yvalue_y2 = 0;
// phi = phi_max;
double pg_value123 = Double.Parse(pg[max_temperature].ToString());
double wg_calc123 = (622 * phi_max * pg_value123 / (patm1 - phi_max * pg_value12));
double y23 = wg_calc123;
max_humidity_yvalue_y2 = y23;// Math.Round(y23, 2);
//lets find the value between min_hum_yvalue and max_hum_yvalue so we can label at that position
int midHumYvalueByDifference =(int) (min_humidity_yvalue_y1 + min_humidity_yvalue_y2) / 2;
int midHumDiffYvalueForRightSideLine =(int) (max_humidity_yvalue_y1 + max_humidity_yvalue_y2) / 2;
//Now lets actually add to the series
//First to the left side
chart1.Series["Vertical_Temp_Left_Side"].Points.AddXY((int)Tmin, min_humidity_yvalue_y1); // same as (x1,y1) for left side
chart1.Series["Vertical_Temp_Left_Side"].Points.AddXY((int)Tmin, midHumYvalueByDifference);//This is middle point (x_mid,y_mid)
chart1.Series["Vertical_Temp_Left_Side"].Points.AddXY((int)Tmin, min_humidity_yvalue_y2); // same as (x2,y2) for left side
//Now testing
// if (temp == (int)Tmin)
// {
// lb_test1.Text += "\n Vertical left side minT-" + Tmin + ",minHumY lower -" + min_humidity_yvalue_y1;
//}
//Now to the right side
chart1.Series["Vertical_Temp_Right_Side"].Points.AddXY((int)Tmax, max_humidity_yvalue_y1); // same as (x1,y1) for right side
chart1.Series["Vertical_Temp_Right_Side"].Points.AddXY((int)Tmax, midHumDiffYvalueForRightSideLine); //This is middle
chart1.Series["Vertical_Temp_Right_Side"].Points.AddXY((int)Tmax, max_humidity_yvalue_y2); // same as (x2,y2) for right side
//--Now adding text to left and right side of line
chart1.Series["Vertical_Temp_Left_Side"].Points[1].Label = "T= "+(int)Tmin;
chart1.Series["Vertical_Temp_Right_Side"].Points[1].Label = "T= "+ (int)Tmax;
//Refresh the chart now
chart1.Invalidate();
chart1.Refresh();//This is for refresh
} //Close of our function