/// <summary> /// Gaphの初期化 /// </summary> private void InitializeGraph() { // グラフ初期化 this.chart.Series.Clear(); // カーソルの取得 this.cursorX = this.chart.ChartAreas[0].CursorX; this.cursorY = this.chart.ChartAreas[0].CursorY; // X軸カーソルの設定 cursorX.LineWidth = 1; cursorX.LineDashStyle = ChartDashStyle.Solid; cursorX.LineColor = Color.Red; cursorX.SelectionColor = SystemColors.Highlight; // Y軸カーソルの設定 cursorY.LineWidth = 1; cursorY.LineDashStyle = ChartDashStyle.Solid; cursorY.LineColor = Color.Red; cursorY.SelectionColor = SystemColors.Highlight; // Enable range selection and zooming end user interface chart.ChartAreas[0].CursorX.IsUserEnabled = true; chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; chart.ChartAreas[0].CursorY.IsUserEnabled = true; chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true; chart.ChartAreas[0].AxisX.ScaleView.Zoomable = true; chart.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true; chart.ChartAreas[0].AxisY.ScaleView.Zoomable = true; chart.ChartAreas[0].AxisY.ScrollBar.IsPositionedInside = true; }
public void SelectChange_2(object sender, EventArgs e) { System.Windows.Forms.DataVisualization.Charting.Cursor moving = TimeChannel2.ChartArea.CursorX; TimeChannel1.ChartArea.CursorX.Position = moving.Position; TimeChannel1.ChartArea.CursorX.SelectionStart = moving.SelectionStart; TimeChannel1.ChartArea.CursorX.SelectionEnd = moving.SelectionEnd; }
public void SelectChange_1(object sender, EventArgs e) { System.Windows.Forms.DataVisualization.Charting.Cursor moving = TimeChannel1.ChartArea.CursorX; Console.WriteLine(moving.Position); if (TimeChannel2 != null) { TimeChannel2.ChartArea.CursorX.Position = moving.Position; TimeChannel2.ChartArea.CursorX.SelectionStart = moving.SelectionStart; TimeChannel2.ChartArea.CursorX.SelectionEnd = moving.SelectionEnd; } }
//------------------------------------------------------ private void AppliqueCursor(CAxisCursor f, System.Windows.Forms.DataVisualization.Charting.Cursor ms) { ms.AutoScroll = f.AutoScroll; ms.AxisType = CConvertisseurChartEnumToMSEnum.GetMSAxisType(f.AxisType); ms.Interval = f.Interval; ms.IntervalOffset = f.IntervalOffset; ms.IntervalOffsetType = CConvertisseurChartEnumToMSEnum.GetMSDateTimeIntervalType(f.IntervalOffsetType); ms.IntervalType = CConvertisseurChartEnumToMSEnum.GetMSDateTimeIntervalType(f.IntervalType); ms.IsUserEnabled = f.IsUserEnabled; ms.IsUserSelectionEnabled = ModeSouris == EModeMouseChart.Loupe; ms.LineColor = f.LineColor; ms.LineDashStyle = CConvertisseurChartEnumToMSEnum.GetMSChartDashStyle(f.LineDashStyle); ms.LineWidth = f.LineWith; ms.SelectionColor = f.SelectionColor; }
private void YControl_SelectedIndexChanged(object sender, System.EventArgs e) { System.Windows.Forms.DataVisualization.Charting.Cursor cursor = Chart1.ChartAreas["Default"].CursorY; if (YLineSize.SelectedIndex >= 0) { cursor.LineWidth = int.Parse(YLineSize.SelectedItem.ToString()); } if (YLineDashStyle.SelectedIndex >= 0) { cursor.LineDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), YLineDashStyle.SelectedItem.ToString()); } if (YLineColor.SelectedIndex >= 0) { cursor.LineColor = Color.FromName(YLineColor.SelectedItem.ToString()); } }
protected override bool ProcessDialogKey(Keys keyData) { System.Windows.Forms.DataVisualization.Charting.Cursor curCursor = chart1.ChartAreas["Price"].CursorX; switch (keyData) { case Keys.Left: curCursor.SetCursorPosition(curCursor.Position - curCursor.Interval); break; case Keys.Right: curCursor.SetCursorPosition(curCursor.Position + curCursor.Interval); break; default: break; } return(true); }
public void SetCursorSelectionState() { chartMain.SuspendLayout(); ChartArea area1 = chartMain.ChartAreas["ChartArea1"]; ChartArea area2 = chartMain.ChartAreas["ChartArea2"]; System.Windows.Forms.DataVisualization.Charting.Cursor cursorX1 = area1.CursorX; System.Windows.Forms.DataVisualization.Charting.Cursor cursorY1 = area1.CursorY; System.Windows.Forms.DataVisualization.Charting.Cursor cursorX2 = area2.CursorX; System.Windows.Forms.DataVisualization.Charting.Cursor cursorY2 = area2.CursorY; cursorX1.IsUserSelectionEnabled = true; cursorX1.IntervalType = DateTimeIntervalType.Hours; cursorX2.IsUserSelectionEnabled = true; cursorX2.IntervalType = DateTimeIntervalType.Hours; cursorY1.IsUserEnabled = false; cursorY1.LineWidth = 0; cursorY2.IsUserEnabled = false; cursorY2.LineWidth = 0; chartMain.ResumeLayout(); }
private void chart_MouseUp(object sender, MouseEventArgs e) { if (!isSelecting) { return; } System.Windows.Forms.DataVisualization.Charting.Cursor xCursor = chart.ChartAreas[0].CursorX; System.Windows.Forms.DataVisualization.Charting.Cursor yCursor = chart.ChartAreas[0].CursorY; double minX = Math.Min(xCursor.SelectionStart, xCursor.SelectionEnd); double maxX = Math.Max(xCursor.SelectionStart, xCursor.SelectionEnd); double minY = Math.Min(yCursor.SelectionStart, yCursor.SelectionEnd); double maxY = Math.Max(yCursor.SelectionStart, yCursor.SelectionEnd); if (Control.ModifierKeys != Keys.Control) { ClearSelectedRuns(); } //check for click to select a single model if (minX == maxX && minY == maxY) { HitTestResult hitTest = chart.HitTest(e.X, e.Y, ChartElementType.DataPoint); if (hitTest.ChartElementType == ChartElementType.DataPoint) { int pointIndex = hitTest.PointIndex; var point = chart.Series[0].Points[pointIndex]; IRun run = (IRun)point.Tag; if (selectedRuns.Contains(run)) { point.MarkerStyle = MarkerStyle.Circle; point.Color = Color.FromArgb(255 - LogTransform(transparencyTrackBar.Value), run.Color); selectedRuns.Remove(run); } else { point.Color = Color.Red; point.MarkerStyle = MarkerStyle.Cross; selectedRuns.Add(run); } } } else { foreach (DataPoint point in this.chart.Series[0].Points) { if (point.XValue < minX || point.XValue > maxX) { continue; } if (point.YValues[0] < minY || point.YValues[0] > maxY) { continue; } point.MarkerStyle = MarkerStyle.Cross; point.Color = Color.Red; IRun run = (IRun)point.Tag; selectedRuns.Add(run); } } this.chart.ChartAreas[0].CursorX.SelectionStart = this.chart.ChartAreas[0].CursorX.SelectionEnd; this.chart.ChartAreas[0].CursorY.SelectionStart = this.chart.ChartAreas[0].CursorY.SelectionEnd; this.OnChanged(); }
private void SpawnPlot(Button btn) { // make same plot as the master plot, but in a new window. Must add all the settings that are hidden in the Visual GUI Form spawn = new Form(); Panel p = new Panel(); Chart chart = new Chart(); ChartArea ca = new ChartArea(); Legend legend = new Legend(); Title title = new Title(); /// Set Form values spawn.Text = "SPE DSA-TS DQA Surface Derived Data Calculations - Spawned Plot"; spawn.Height = 600; spawn.Width = 800; /// Set Panel values p.Dock = DockStyle.Fill; /// Set Chart Area values ca.Name = "chartArea"; ca.AxisX.Title = "Elapsed Time in Seconds"; ca.AxisX.Minimum = 0; // Legion values legend.Name = "Data Trace"; legend.LegendStyle = LegendStyle.Column; legend.TableStyle = LegendTableStyle.Tall; // Title values title.Text = "Rig Data Display in Seconds"; // Link chart elements into the main chart chart.ChartAreas.Add(ca); chart.Legends.Add(legend); chart.Titles.Add(title); /// Set Chart values chart.Dock = DockStyle.Fill; System.Windows.Forms.DataVisualization.Charting.Cursor cursorX = null; System.Windows.Forms.DataVisualization.Charting.Cursor cursorY = null; cursorX = chart.ChartAreas["chartArea"].CursorX; cursorX.Interval = 1; cursorY = chart.ChartAreas["chartArea"].CursorY; cursorX.LineWidth = 2; cursorY.LineWidth = 2; cursorX.LineDashStyle = ChartDashStyle.DashDot; cursorY.LineDashStyle = ChartDashStyle.DashDot; cursorX.LineColor = Color.Red; cursorY.LineColor = Color.Red; cursorX.SelectionColor = Color.Yellow; cursorY.SelectionColor = Color.Yellow; // Enable end user interactivity chart.ChartAreas["chartArea"].CursorX.IsUserEnabled = true; chart.ChartAreas["chartArea"].CursorX.IsUserSelectionEnabled = true; chart.ChartAreas["chartArea"].CursorY.IsUserEnabled = true; chart.ChartAreas["chartArea"].CursorY.IsUserSelectionEnabled = true; /// Get data to display DataValues dv = util.FindDataColumn(Data, btn.Name); int index = util.FindDataColumnIndex(Data, dv.Name); /// Create Series Series series = new Series(dv.Name); chart.Series.Add(series); /// Set line properies - type, color, width /// Use color table mod 10 to repeat color table chart.Series[dv.Name].ChartType = SeriesChartType.FastLine; chart.Series[dv.Name].BorderWidth = 2; chart.Series[dv.Name].Color = Color.FromName(PlotColor[index % 10]); /// Convert DateTime stamp to seconds /// /// Get timestamp of first data sample and use as Time zero - the value to be subtracted from each timestamp DateTime origin = dv.DataColumn[0].Timestamp; double od = Convert.ToDouble(origin.Ticks / 10000000); /// For each value - change the string value to a double and timestamp to seconds for (int i = 0; i < dv.DataColumn.Count; i++) { double val = Convert.ToDouble(Convert.ToDateTime(dv.DataColumn[i].Timestamp).Ticks / 10000000) - od; double rc = Convert.ToDouble(dv.DataColumn[i].Value); /// Add data to plot series - skip if -999.25 Schlumberger null if (rc != -999.25) { chart.Series[dv.Name].Points.AddXY(val, rc); } } p.Controls.Add(chart); spawn.Controls.Add(p); chart.Show(); spawn.Show(); }