public void plot_on_graph_values_process_diagram(double dbt, double hr, double xval, double yval)
{
//chart1.Series.Clear();
try
{
series1.ChartType = SeriesChartType.Point;
//int r, g, b;
series1.MarkerSize = 20;
series1.MarkerStyle = MarkerStyle.Circle;
//string label = "DBT=" + dbt + ",HR=" + hr;
//series1.Label = label;
//chart1.Series["SeriesDBT_HR" + index].;
//series1.Points[0].Color = colorValue;//blue
// MessageBox.Show("finally added xvalue = " + xval + " yvalue = " + yval);
series1.Points.AddXY(xval, yval);
string s = "source : " + tbSource + "\n Name : " + tbName + "\nLable : " + tbLabel;
series1.Points[index].Color = colorValue;
series1.Points[index].ToolTip = s;
string labelStringValue = null;
//labeling part
if (comboboxItemText == "Label")
{
//label is selected
labelStringValue = tbLabel;
}
else if (comboboxItemText == "Name")
{
//Name is selected
labelStringValue = tbName;
}
else
{
//Source is selected
labelStringValue = tbSource;
}
series1.Points[index].Label = labelStringValue;
// MessageBox.Show("value xval =" + xval + ",yval = " + yval);
//series1.Points[index_series++].Color = colorValue;//blue
// MessageBox.Show("end re");
//index_series++;
//series1.Enabled = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
//now lets move on to storing those values and futher porcessing it...
//the value is added...
menuStripNodeInfoValues.Add(new TempDataType
{
id = index,
xVal = xval,
yVal = yval,
source = tbSource,
name = tbName,
label = tbLabel,
colorValue = colorValue,
showItemText = comboboxItemText
});
if(flagForInsertOrUpdateDataToDB == 1) {
//do only if the flag is raised.
//--Adding these values to the database....
InsertNodeInfoToDB(index, xval, yval, tbSource, tbName, tbLabel, colorValue,comboboxItemText);
}
//the liine plot part is only done when ther is two points or more
if (index > 0)
{
double startHumidity1 = 0;
double startEnthalpy1 = 0;
double endHumidity1 = 0;//--this is for the start and end humidity print in the tooltip
double endEnthalpy1 = 0;
//now lets plot lines between tow points...
Series newLineSeries = new Series("LineSeries" + index);
//string nameSeries = newLineSeries.Name;
//--If the series already present lets remove from the chart ok ol :)
if (chart1.Series.IndexOf(newLineSeries.Name) != -1)
{
//MessageBox.Show("Series exits");
//--This means the series is present....
chart1.Series.RemoveAt(chart1.Series.IndexOf(newLineSeries.Name));
}
//--Lets store the nodeline info as well
menuStripNodeLineInfoValues.Add(new lineNodeDataType
{
//--Id of this ..
ID = index,
prevNodeId = index - 1,
nextNodeId = index,
lineColorValue = menuStripNodeInfoValues[index - 1].colorValue,
lineSeriesID = newLineSeries
});
//--Inserting the line to database here....
if(flagForInsertOrUpdateDataToDB == 1)
{
//--Insert the values when the flag is raised.
InsertLineInfoToDB(index, index - 1, index, menuStripNodeInfoValues[index - 1].colorValue, newLineSeries);
}
//newSeries.MarkerStyle = MarkerStyle.Triangle;
newLineSeries.ChartType = SeriesChartType.Line;
//newLineSeries.MarkerStyle = MarkerStyle.Circle;
//newLineSeries.MarkerStyle = MarkerStyle.Star6;
newLineSeries.MarkerBorderWidth.Equals(15);
newLineSeries.MarkerSize.Equals(1);
newLineSeries.BorderWidth.Equals(15);
// newLineSeries.SetCustomProperty(newLineSeries.MarkerSize.ToString(),newLineSeries.MarkerSize.Equals(25).ToString());
newLineSeries.Color = menuStripNodeInfoValues[index].colorValue;
//--this sets the initial values of humidity and enthalpy
CalculateHumidityEnthalpy((double)menuStripNodeInfoValues[index - 1].xVal, (double)menuStripNodeInfoValues[index - 1].yVal);
startHumidity1 = Math.Round(humidityCalculated, 2);//--Fro showing only up to 2 dec. eg."34.52"
startEnthalpy1 = Math.Round(enthalpyCalculated, 2);
//--This calculates the end humidity and the enthalpy values..
CalculateHumidityEnthalpy((double)menuStripNodeInfoValues[index].xVal, (double)menuStripNodeInfoValues[index].yVal);
endHumidity1 = Math.Round(humidityCalculated, 2);
endEnthalpy1 = Math.Round(enthalpyCalculated, 2);
double enthalpyChange = endEnthalpy1 - startEnthalpy1;
string sequenceDetected = menuStripNodeInfoValues[index - 1].name + " to " + menuStripNodeInfoValues[index].name;
string tooltipString = "Sequence : " + sequenceDetected + " \n" + " start end \n" + "Temp :" + Math.Round(menuStripNodeInfoValues[index - 1].xVal, 2) + " " + Math.Round(menuStripNodeInfoValues[index].xVal, 2) + "\nHumidity :" + startHumidity1 + " " + endHumidity1 + "\nEnthalpy : " + startEnthalpy1 + " " + endEnthalpy1 + "\nEnthalpy Change:" + enthalpyChange;
newLineSeries.ToolTip = tooltipString;
//newSeries.MarkerStyle = MarkerStyle.Circle;
//newSeries.Points.AddXY(menuStripNodeInfoValues[index - 1].xVal, menuStripNodeInfoValues[index].xVal, menuStripNodeInfoValues[index - 1].yVal, menuStripNodeInfoValues[index].yVal);
newLineSeries.Points.Add(new DataPoint(menuStripNodeInfoValues[index - 1].xVal, menuStripNodeInfoValues[index - 1].yVal));
newLineSeries.Points.Add(new DataPoint(menuStripNodeInfoValues[index].xVal, menuStripNodeInfoValues[index].yVal));
chart1.Series.Add(newLineSeries);
chart1.Series[newLineSeries.Name].BorderWidth = 3;
}
index++;
}