private void chart1_MouseMove(object sender, MouseEventArgs e) { if (isLeftButtonPressed) { var result = chart1.HitTest(e.X, e.Y); if (result.ChartElementType == System.Windows.Forms.DataVisualization.Charting.ChartElementType.PlottingArea) { var oldXValue = result.ChartArea.AxisX.PixelPositionToValue(mouseDown.X); var newXValue = result.ChartArea.AxisX.PixelPositionToValue(e.X); var oldYValue = result.ChartArea.AxisX.PixelPositionToValue(mouseDown.Y); var newYValue = result.ChartArea.AxisX.PixelPositionToValue(e.Y); chart1.ChartAreas[0].AxisY.ScaleView.Position -= oldYValue - newYValue; mouseDown.Y = e.Y; chart1.ChartAreas[0].AxisX.ScaleView.Position += oldXValue - newXValue; mouseDown.X = e.X; } } label1.Visible = true; label2.Visible = true; var res = chart1.HitTest(e.X, e.Y); if (res.Series != null) { try { double ph = -9999.99; //foreach (Hash item in TimeTable) HashPoints a = (HashPoints)res.Series; foreach (Hash item in a.TimeTable) { if (item.key == res.Series.Points[res.PointIndex].XValue) { ph = item.value; } } label2.Text = "LKK: " + res.Series.Points[res.PointIndex].YValues[0].ToString(); label1.Text = "T: " + res.Series.Points[res.PointIndex].XValue.ToString(); if (ph != -9999.99) { label1.Text += " ph:" + ph.ToString(); } } catch { label2.Text = "LKK: "; label1.Text = "T: "; } } label1.Location = new Point(this.PointToClient(Cursor.Position).X, this.PointToClient(Cursor.Position).Y + 10); label2.Location = new Point(this.PointToClient(Cursor.Position).X - 25, this.PointToClient(Cursor.Position).Y + 25); }
public void Testrostki(int i, int r, int g, int b, double A0, double A1, double A2, double B1, double B2, double C0, double C1, double C2, double D1, double D2, int limj) { chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.Beige; chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.Beige; chart1.ChartAreas[0].AxisX.LineColor = Color.Beige; chart1.ChartAreas[0].AxisY.LineColor = Color.Beige; chart1.ChartAreas[0].AxisX.InterlacedColor = Color.Beige; chart1.ChartAreas[0].AxisY.InterlacedColor = Color.Beige; chart1.ChartAreas[0].BackColor = Color.FromArgb(80, 70, 100); chart1.ChartAreas[0].AxisX.ScrollBar.Enabled = true; double[] LK = new double[30000]; double[] LKK = new double[30000]; double[] T = new double[30000]; List <Hash> d = new List <Hash>(); List <Hash> c = new List <Hash>(); HashPoints a = new HashPoints(c); int j = 0; double ph = 0; for (int iph = -10000; iph < 10000; iph++) { if (radioButton1.Checked) { ph = 7.0 * iph / 120; } else if (radioButton2.Checked) { ph = 8 + 8.0 * iph / 130; } else if (radioButton3.Checked) { ph = 6 + 7.5 * iph / 32; } else { ph = 9 + 8.0 * iph / 140; } if (1 - 120.0 / (A0 + A1 * ph + A2 * ph * ph) > 0) { try { T[j] = Math.Pow(Math.Log(1 - 120.0 / (A0 + A1 * ph + A2 * ph * ph)) / -B1, 1.0 / B2); LK[j] = (C0 + C1 * ph + C2 * ph * ph) * (1 - Math.Pow(Math.E, -D1 * Math.Pow(T[j], D2))); LKK[j] = (C0 + C1 * ph + C2 * ph * ph) * (1 - Math.Pow(Math.E, (-D1 * Math.Pow(T[j], D2)))); if (T[j] > 0 && T[j] < 10000 && LKK[j] > 0 && LKK[j] < 10000) { d.Add(new Hash(T[j], ph)); c.Add(new Hash(T[j], LKK[j])); } } catch { int f = 0; } } j++; } a = new HashPoints(d); a.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline; foreach (Hash p in c) { a.Points.AddXY(p.key, p.value); } chart1.Series.Add(a); chart1.Series[i].Color = Color.FromArgb(r, g, b); chart1.Series[i].BorderWidth = 2; chart1.ChartAreas[0].CursorX.AutoScroll = true; // let's zoom to [0,blockSize] (e.g. [0,100]) chart1.ChartAreas[0].AxisX.ScaleView.Zoomable = true; chart1.ChartAreas[0].AxisY.ScaleView.Zoomable = true; chart1.ChartAreas[0].AxisX.ScaleView.SizeType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Number; chart1.ChartAreas[0].AxisX.LabelStyle.Format = "{0:F3}"; chart1.ChartAreas[0].AxisY.LabelStyle.Format = "{0:F2}"; // disable zoom-reset button (only scrollbar's arrows are available) chart1.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = System.Windows.Forms.DataVisualization.Charting.ScrollBarButtonStyles.SmallScroll; // set scrollbar small change to blockSize (e.g. 100) chart1.ChartAreas[0].AxisY.ScaleView.SmallScrollSize = 10; chart1.ChartAreas[0].AxisY.ScrollBar.ButtonStyle = System.Windows.Forms.DataVisualization.Charting.ScrollBarButtonStyles.SmallScroll; // set scrollbar small change to blockSize (e.g. 100) chart1.ChartAreas[0].AxisY.ScaleView.SmallScrollSize = 10; }