private void tsmzoom_Click(object sender, EventArgs e) { //this.ChartAreas[0].AxisX.ScaleView.Zoomable = true; //this.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true; Control c = this.Parent; chartcopy = this; ZoomedChart frm = new ZoomedChart(this); frm.WindowState = FormWindowState.Maximized; frm.ShowDialog(); c.Controls.Add(chartcopy); chartcopy.Invalidate(); chartcopy.Show(); }
private void ShowChart(DataRowView drv, System.Drawing.Point point) { int MaxX = drv["Chukys"].ToString().Split(',').Length; int MaxY = int.Parse(drv["ChuKyLonNhat"].ToString()); // Create new Graph Graph.Chart chart = new Graph.Chart(); chart.Location = point; chart.Size = new System.Drawing.Size(1100, 1500); // Add a chartarea called "draw", add axes to it and color the area black chart.ChartAreas.Add("draw"); chart.ChartAreas["draw"].AxisX.Minimum = 0; chart.ChartAreas["draw"].AxisX.Maximum = MaxX; chart.ChartAreas["draw"].AxisX.Interval = 5; chart.ChartAreas["draw"].AxisX.MajorGrid.LineColor = Color.White; chart.ChartAreas["draw"].AxisX.MajorGrid.LineDashStyle = Graph.ChartDashStyle.Dash; chart.ChartAreas["draw"].AxisY.Minimum = 0; chart.ChartAreas["draw"].AxisY.Maximum = MaxY; chart.ChartAreas["draw"].AxisY.Interval = 1; chart.ChartAreas["draw"].AxisY.MajorGrid.LineColor = Color.White; chart.ChartAreas["draw"].AxisY.MajorGrid.LineDashStyle = Graph.ChartDashStyle.Dash; chart.ChartAreas["draw"].BackColor = Color.Black; // Create a new function series chart.Series.Add("MyFunc"); // Set the type to line chart.Series["MyFunc"].ChartType = Graph.SeriesChartType.Line; // Color the line of the graph light green and give it a thickness of 3 chart.Series["MyFunc"].Color = Color.LightGreen; chart.Series["MyFunc"].BorderWidth = 3; //This function cannot include zero, and we walk through it in steps of 0.1 to add coordinates to our series chart.Series["MyFunc"].Points.DataBindXY(drv["Chukys"].ToString().Split(','), drv["Chukys"].ToString().Split(',').Select(x=>int.Parse(x)).ToArray()); chart.Series["MyFunc"].LegendText = "Hai so cuoi: " + drv["HaiSoCuoi"].ToString(); // Create a new legend called "MyLegend". chart.Legends.Add("MyLegend"); chart.Legends["MyLegend"].Position = new Graph.ElementPosition(10,10,10,10) ;// .BorderColor = Color.Tomato; // I like tomato juice! panel1.Controls.Add(chart); chart.Show(); DataTable dt = new DataTable(); string str = ""; foreach (DataColumn dc in dt.Columns) { str += dc.ColumnName + ","; } }
private void ScanCompute() { foreach (TaskGroup g in task.TaskGroups) { PictureBox p = new PictureBox(); p.Width=252; p.Height = 142; p.Load(g.OriginalImageFileName); p.SizeMode = PictureBoxSizeMode.StretchImage; OriginalImage.Load(g.OriginalImageFileName); p.Show(); ChartArea chartArea1 = new ChartArea(); chartArea1.Name="ChartArea1"; Legend legend1 = new Legend(); legend1.Name = "Legend1"; Series series1 = new Series(); Series series2 = new Series(); Chart chart = new Chart(); chart.ChartAreas.Add(chartArea1); chart.Legends.Add(legend1); series1.ChartArea = "ChartArea1"; series1.Legend = "Legend1"; series1.Name = "PSNR"; series1.ChartType = SeriesChartType.Line; series2.ChartArea = "ChartArea1"; series2.Legend = "Legend1"; series2.Name = "SSIM"; series2.ChartType = SeriesChartType.Line; chart.Series.Add(series1); chart.Series.Add(series2); chart.Size = new System.Drawing.Size(375, 142); chart.Show(); foreach (TaskItem item in g.TaskItems) { double distortionLevel = 0; bool doProcess = false; switch (distortionType) { case "blur": doProcess = (item.BlurLevel > 0 && item.JpegLevel == 0 && item.NoiseLevel == 0); distortionLevel = item.BlurLevel; break; case "noise": doProcess = (item.NoiseLevel > 0 && item.JpegLevel == 0 && item.BlurLevel == 0); distortionLevel = item.NoiseLevel; break; case "jpeg": doProcess = (item.JpegLevel > 0 && item.NoiseLevel== 0 && item.BlurLevel == 0); distortionLevel = item.JpegLevel; break; case "blur_jpeg": doProcess = (item.JpegLevel > 0 && item.BlurLevel > 0 && item.NoiseLevel == 0); distortionLevel = (double)(item.JpegLevel + item.BlurLevel) / 2; break; case "blur_noise": doProcess = (item.BlurLevel > 0 && item.NoiseLevel > 0 && item.JpegLevel == 0); distortionLevel = (double)(item.BlurLevel + item.NoiseLevel) / 2; break; } if (doProcess) { compressedImage.Load(item.FileName); Bitmap bm = (Bitmap)OriginalImage.Image; Bitmap originalBitMap = new Bitmap(OriginalImage.Image); Bitmap compressedBitMap = new Bitmap(compressedImage.Image); int width = OriginalImage.Image.Width; int height = OriginalImage.Image.Height; int modW = width % 8; int modH = height % 8; int newWidth = width; if (modW > 0) { newWidth = width + (8 - modW); } int newHeight = height; if (modH > 0) { newHeight = height + (8 - modH); } Bitmap newOrBitmap = new Bitmap(newWidth, newHeight); Bitmap newPrBitmap = new Bitmap(newWidth, newHeight); Graphics graphicOrImage = Graphics.FromImage(newOrBitmap); Graphics graphicPrImage = Graphics.FromImage(newPrBitmap); graphicOrImage.DrawImage(originalBitMap, 0, 0, width, height); graphicPrImage.DrawImage(compressedBitMap, 0, 0, width, height); List<Bitmap> orBlockArray = new List<Bitmap>(); List<Bitmap> prBlockArray = new List<Bitmap>(); for (int i = 0; i < newWidth / 8; i++) { for (int j = 0; j < newHeight / 8; j++) { Bitmap orBlock = new Bitmap(8, 8); orBlock = Cut(newOrBitmap, i * 8, j * 8, 8, 8); orBlockArray.Add(orBlock); Bitmap prBlock = new Bitmap(8, 8); prBlock = Cut(newPrBitmap, i * 8, j * 8, 8, 8); prBlockArray.Add(prBlock); } } //end preparing images double PSNR = GetPSNR(orBlockArray, prBlockArray); double SSIM = GetSSIM(orBlockArray, prBlockArray) * 100; chart.Series["PSNR"].Points.Add(new System.Windows.Forms.DataVisualization.Charting.DataPoint(distortionLevel, PSNR)); chart.Series["SSIM"].Points.Add(new System.Windows.Forms.DataVisualization.Charting.DataPoint(distortionLevel, SSIM)); } } chart.Series["PSNR"].Sort(PointSortOrder.Ascending); chart.Series["SSIM"].Sort(PointSortOrder.Ascending); this.Invoke(new Action<PictureBox, Chart>(this.updateUI), p, chart); this.Invoke(new Action(this.UpdateProcessThread)); g.Done = true; } uiThread.Abort(); }
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(); }