private void PopulateGraphAndTable() { chart1.Series["Volume - un^3"].Points.Clear(); //clears old dot var chart = chart1.ChartAreas[0]; chart.AxisX.IntervalType = DateTimeIntervalType.Number; chart.AxisX.LabelStyle.Format = ""; chart.AxisY.LabelStyle.Format = ""; chart.AxisY.LabelStyle.IsEndLabelVisible = true; OptimalBase = Calculations.OptimalBase(surfacearea); chart.AxisX.Minimum = minValueBaseBar; //1 chart.AxisX.Maximum = maxValueBaseBar; //140 MinYValue = (int)Math.Floor(Calculations.Volume(minValueBaseBar, Calculations.CalculateHeight(minValueBaseBar, surfacearea))); MaxYValue = (int)Math.Floor(Calculations.Volume(OptimalBase, Calculations.CalculateHeight(OptimalBase, surfacearea)) * 1.1); chart.AxisY.Minimum = MinYValue; chart.AxisY.Maximum = MaxYValue; chart.AxisX.Interval = maxValueBaseBar / 28; //28 intervals chart.AxisY.Interval = (MaxYValue - MinYValue) / 10; //10 intervals int counter = 0; dataGridView1.Rows.Clear(); for (double i = minValueBaseBar; i < maxValueBaseBar; i += BaseTickValue) { tempHeight = Calculations.CalculateHeight(i, surfacearea); tempVolume = Calculations.Volume(i, tempHeight); chart1.Series["Volume - un^3"].Points.AddXY(i, tempVolume); dataGridView1.Rows.Add(); dataGridView1.Rows[counter].Cells["Col1"].Value = i; dataGridView1.Rows[counter].Cells["Col2"].Value = tempHeight; dataGridView1.Rows[counter].Cells["Col3"].Value = tempVolume; counter++; } }
// depending on a change in SA trackbar value or a click, hides or hows the optimized values for volume private void ShowOptimizedValues(object sender, EventArgs e) { OptimizedBaseOutput.Visible = true; OptimizedHeightOutput.Visible = true; OptimizedVolumeOutput.Visible = true; OptimizedBaseOutput.Text = (Calculations.OptimalBase(surfacearea)).ToString(); OptimizedHeightOutput.Text = Calculations.CalculateHeight(Calculations.OptimalBase(surfacearea), surfacearea).ToString(); OptimizedVolumeOutput.Text = Calculations.Volume(Calculations.OptimalBase(surfacearea), Calculations.CalculateHeight(Calculations.OptimalBase(surfacearea), surfacearea)).ToString(); }
// the functions below are to graph the point on the graph along with the curve, // these are two seperact graphs functions that are graphed onto the same chart private void AddingDotGraph(double baseXValue, double heightValue) { var chart = chart1.ChartAreas[0]; chart.AxisX.IntervalType = DateTimeIntervalType.Number; chart.AxisX.LabelStyle.Format = ""; chart.AxisY.LabelStyle.Format = ""; chart.AxisY.LabelStyle.IsEndLabelVisible = false; chart.AxisX.Minimum = 0; //1 chart.AxisX.Maximum = maxValueBaseBar; //140 OptimalBase = Calculations.OptimalBase(surfacearea); MinYValue = (int)Math.Floor(Calculations.Volume(minValueBaseBar, Calculations.CalculateHeight(minValueBaseBar, surfacearea))); MaxYValue = (int)Math.Floor(Calculations.Volume(OptimalBase, Calculations.CalculateHeight(OptimalBase, surfacearea)) * 1.1); chart.AxisY.Minimum = MinYValue; chart.AxisY.Maximum = MaxYValue; chart.AxisX.Interval = maxValueBaseBar / 28; //28 intervals chart.AxisY.Interval = (MaxYValue - MinYValue) / 10; //10 intervals int VolumePoint = (int)Math.Ceiling(Calculations.Volume(BaseVal, height)); chart1.Series["Volume"].Points.AddXY(BaseVal, VolumePoint); }