protected void chart2_PostPaint(object sender, ChartPaintEventArgs e) { if (e.ChartElement.ToString() == "ChartArea-Data Chart Area1") { for (int jj = 0; jj < 1; jj++) { string bxname = "BoxPlotLabel" + jj; // Position point chart type series on the points of the box plot to display labels chart2.Series[bxname].Points[0].YValues[0] = chart2.Series["BoxPlotSeries"].Points[0].YValues[0]; chart2.Series[bxname].Points[1].YValues[0] = chart2.Series["BoxPlotSeries"].Points[0].YValues[1]; chart2.Series[bxname].Points[2].YValues[0] = chart2.Series["BoxPlotSeries"].Points[0].YValues[2]; chart2.Series[bxname].Points[3].YValues[0] = chart2.Series["BoxPlotSeries"].Points[0].YValues[3]; chart2.Series[bxname].Points[4].YValues[0] = chart2.Series["BoxPlotSeries"].Points[0].YValues[4]; chart2.Series[bxname].Points[5].YValues[0] = chart2.Series["BoxPlotSeries"].Points[0].YValues[5]; chart2.Series[bxname].Points[0].Label = string.Format("{0:F1}", chart2.Series["BoxPlotSeries"].Points[0].YValues[0]); chart2.Series[bxname].Points[1].Label = string.Format("{0:F1}", chart2.Series["BoxPlotSeries"].Points[0].YValues[1]); chart2.Series[bxname].Points[2].Label = string.Format("{0:F1}", chart2.Series["BoxPlotSeries"].Points[0].YValues[2]); chart2.Series[bxname].Points[3].Label = string.Format("{0:F1}", chart2.Series["BoxPlotSeries"].Points[0].YValues[3]); chart2.Series[bxname].Points[4].Label = string.Format("{0:F1}", chart2.Series["BoxPlotSeries"].Points[0].YValues[4]); chart2.Series[bxname].Points[5].Label = string.Format("{0:F1}", chart2.Series["BoxPlotSeries"].Points[0].YValues[5]); } } }
private void ChartPicture_BeforePaint(object sender, ChartPaintEventArgs e) { int num = 1; for (int i = 0; i < Series.Count; i++) { Series series = Series[i]; series.xValuesZerosChecked = false; series.xValuesZeros = false; IChartType chartType = e.CommonElements.ChartTypeRegistry.GetChartType(series.ChartTypeName); bool pointsApplyPaletteColors = chartType.ApplyPaletteColorsToPoints; if (series.Palette != 0) { pointsApplyPaletteColors = true; } PrepareData(Palette != 0 || PaletteCustomColors.Length != 0, pointsApplyPaletteColors, series.Name); if (series.tempMarkerStyleIsSet) { series.MarkerStyle = MarkerStyle.None; series.tempMarkerStyleIsSet = false; } if (chartType.GetLegendImageStyle(series) == LegendImageStyle.Marker && series.MarkerStyle == MarkerStyle.None) { series.MarkerStyle = (MarkerStyle)(num++); series.tempMarkerStyleIsSet = true; if (num > 9) { num = 1; } } } }
private void chart_PostPaint(object sender, ChartPaintEventArgs e) { if (ChartPostPaint != null) { ChartPostPaint(this, EventArgs.Empty); } }
//private void comboPriceUpColor_SelectedIndexChanged(object sender, EventArgs e) //{ // UpdateChartSettings(); //} private void chart1_PrePaint(object sender, ChartPaintEventArgs e) { // read the calculated Box Size - CurrentBoxSize attribute var calculatedBoxSize = _chart1.Series["Default"]["CurrentBoxSize"]; // update chart title _chart1.Titles[0].Text = "Renko chart, Box Size = " + calculatedBoxSize; }
/// <summary> /// For customized event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void chart1_Load(object sender, ChartPaintEventArgs e) { if (e.ChartElement is Series) { Series series = (Series)e.ChartElement; series.MapAreaAttributes = "onmouseover=\"javascript: chart1_event('" + series.Name + ": #VALY-#VALX');\""; } }
private void chart_PostPaint(object aSender, ChartPaintEventArgs aEventArgs) { if (mReInit) { return; } var lGraphics = aEventArgs.ChartGraphics.Graphics; if (mShowCursor) { lGraphics.DrawLine(Pens.Black, mCursorX, mTopY, mCursorX, mBottomY); int lHeight = 0; int lWidth = 0; SizeF lSize = SizeF.Empty; int lCount = mCursorValue.Count; int[] lW = new int[lCount]; for (int i = 0; i < lCount; i++) { if (String.IsNullOrWhiteSpace(mCursorValue[i]) == false) { lSize = lGraphics.MeasureString(mCursorValue[i], mCursorFont); lW[i] = (int)lSize.Width; if (lWidth < lW[i]) { lWidth = lW[i]; } } } if (lWidth > 0) { lHeight = (int)lSize.Height * mCursorValue.Count; int lX; if (mCursorX + lWidth + 2 > mRightX) { lX = mCursorX - lWidth; lGraphics.FillRectangle(Brushes.White, lX - 1, mTopY, lWidth, lHeight); } else { lX = mCursorX + 1; lGraphics.FillRectangle(Brushes.White, lX, mTopY, lWidth, lHeight); } int lY = mTopY; for (int i = 0; i < lCount; i++) { lGraphics.DrawString(mCursorValue[i], mCursorFont, mCursorBrush[i], lX + (lWidth - lW[i]), lY); lY = lY + (int)lSize.Height; } } } }
protected override void OnPostPaint(ChartPaintEventArgs e) { base.OnPostPaint(e); if (Series[0].Points.Count > 0) { //drawRefLines(e.ChartGraphics.Graphics); drawClose(e.ChartGraphics.Graphics); } }
protected void Chart5_PrePaint(object sender, ChartPaintEventArgs e) { foreach (Series charts in Chart5.Series) { foreach (DataPoint point in charts.Points) { point.Label = string.Format("{1}-{0:0} ", point.AxisLabel, point.YValues[0]); } } }
private void chart2_PostPaint(object sender, ChartPaintEventArgs e) { Graphics g = e.ChartGraphics.Graphics; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; ChartArea ca = chart2.ChartAreas[0]; Font font = ca.AxisX.LabelStyle.Font; Color col = ca.AxisX.MajorGrid.LineColor; int padding = 10; int y0 = (int)ca.AxisY.ValueToPixelPosition(ca.AxisY.Minimum); int y1 = (int)ca.AxisY.ValueToPixelPosition(ca.AxisY.Maximum); foreach (int sx in MyInterval) { int x = (int)ca.AxisX.ValueToPixelPosition(sx); ///////////////////COMMENT 2 LINES TO NOT LET IT DRAW LINES////////////////////////////// using (Pen pen = new Pen(col)) g.DrawLine(pen, x, y0, x, y1); string s = sx + ""; if (ca.AxisX.LabelStyle.Format != "") { s = string.Format(ca.AxisX.LabelStyle.Format, s); } SizeF sz = g.MeasureString(s, font, 999); g.DrawString(s, font, Brushes.Black, (int)(x - sz.Width / 2), y0 + padding); ca.AxisX.MajorGrid.Enabled = false; ca.AxisX.MajorTickMark.Enabled = false; ca.AxisX.LabelStyle.Enabled = false; } //private void panel1_MouseClick(object sender, MouseEventArgs e) //{ // Brush aBrush = (Brush)Brushes.Black; // Graphics g = this.CreateGraphics(); // g.FillRectangle(aBrush, e.X, e.Y, 1, 1); //} //private void panel1_Paint(object sender, PaintEventArgs e) //{ // //Graphics g = e.Graphics; // //Pen pen = new Pen(Color.Red); // //g.DrawLine(pen, new Point(13, 13), new Point(20, 20)); //} }
private void chart1_PrePaint(object sender, ChartPaintEventArgs e) { if (e.ChartElement.ToString() == "ChartArea-Data Chart Area") { for (int jj = 0; jj < 21; jj++) { string bxname = "BoxPlotLabels" + jj; // Position point chart type series on the points of the box plot to display labels chart1.Series[bxname].Points[0].YValues[0] = chart1.Series["BoxPlotSeries"].Points[jj].YValues[0]; chart1.Series[bxname].Points[1].YValues[0] = chart1.Series["BoxPlotSeries"].Points[jj].YValues[1]; chart1.Series[bxname].Points[2].YValues[0] = chart1.Series["BoxPlotSeries"].Points[jj].YValues[2]; chart1.Series[bxname].Points[3].YValues[0] = chart1.Series["BoxPlotSeries"].Points[jj].YValues[3]; chart1.Series[bxname].Points[4].YValues[0] = chart1.Series["BoxPlotSeries"].Points[jj].YValues[4]; chart1.Series[bxname].Points[5].YValues[0] = chart1.Series["BoxPlotSeries"].Points[jj].YValues[5]; chart1.Series[bxname].Points[0].Label = string.Format("{0:F2}", chart1.Series["BoxPlotSeries"].Points[jj].YValues[0]); if (chart1.Series["BoxPlotSeries"].Points[jj].YValues[0] != 0) { chart1.Series[bxname].Points[0].CustomProperties = "LabelStyle=Left"; // 2015.02.09 denny chart1.Series[bxname].Points[0].LabelAngle = -45; // 2015.02.09 denny } chart1.Series[bxname].Points[1].Label = string.Format("{0:F2}", chart1.Series["BoxPlotSeries"].Points[jj].YValues[1]); if (chart1.Series["BoxPlotSeries"].Points[jj].YValues[1] != 0) { chart1.Series[bxname].Points[1].CustomProperties = "LabelStyle=Left"; // 2015.02.09 denny chart1.Series[bxname].Points[1].LabelAngle = 45; // 2015.02.09 denny } chart1.Series[bxname].Points[2].Label = string.Format("{0:F2}", chart1.Series["BoxPlotSeries"].Points[jj].YValues[2]); if (chart1.Series["BoxPlotSeries"].Points[jj].YValues[2] != 0) { chart1.Series[bxname].Points[2].CustomProperties = "LabelStyle=Right"; // 2015.02.09 denny chart1.Series[bxname].Points[2].LabelAngle = 45; // 2015.02.09 denny } chart1.Series[bxname].Points[3].Label = string.Format("{0:F2}", chart1.Series["BoxPlotSeries"].Points[jj].YValues[3]); if (chart1.Series["BoxPlotSeries"].Points[jj].YValues[3] != 0) { chart1.Series[bxname].Points[3].CustomProperties = "LabelStyle=Right"; // 2015.02.09 denny chart1.Series[bxname].Points[3].LabelAngle = -45; // 2015.02.09 denny } chart1.Series[bxname].Points[4].Label = string.Format("{0:F2}", chart1.Series["BoxPlotSeries"].Points[jj].YValues[4]); if (chart1.Series["BoxPlotSeries"].Points[jj].YValues[4] != 0) { chart1.Series[bxname].Points[4].CustomProperties = "LabelStyle=Left"; // 2015.02.09 denny chart1.Series[bxname].Points[4].LabelAngle = 0; // 2015.02.09 denny } chart1.Series[bxname].Points[5].Label = string.Format("{0:F2}", chart1.Series["BoxPlotSeries"].Points[jj].YValues[5]); if (chart1.Series["BoxPlotSeries"].Points[jj].YValues[5] != 0) { chart1.Series[bxname].Points[5].CustomProperties = "LabelStyle=Right"; // 2015.02.09 denny chart1.Series[bxname].Points[5].LabelAngle = 0; // 2015.02.09 denny } } } }
private void OnPostPaintDepth(object sender, ChartPaintEventArgs e) { /*ChartGraphics cg = e.ChartGraphics; * * PointF p = new PointF { X = (float)cg.GetPositionFromAxis(kDepthChartAreaName, AxisName.X, m_vwap) }; * p = cg.GetAbsolutePoint(p); * * Pen bp = new Pen(Color.Black); * * cg.Graphics.DrawLine(bp, p.X, 0, p.X, m_depthChart.Height);*/ }
/// <summary> /// The event called after the chart control has been painted. /// </summary> /// <param name="sender">The Sender.</param> /// <param name="e">The ChartPaintEventArgs.</param> private void Chart1Paint(object sender, ChartPaintEventArgs e) { if (this.rectangle1 != null) { this.DrawRectangle(this.rectangle1, e, Color.Red); } if (this.rectangle2 != null) { this.DrawRectangle(this.rectangle2, e, Color.Blue); } }
private void customchart_PostPaint(object sender, ChartPaintEventArgs e) { int x, y; if (customToolTipEnabled == true && this.Series.Count > 0 && lastPointIsHovered == true) { x = (int)this.ChartAreas[0].AxisX.ValueToPixelPosition(lastPoint.XValue); y = (int)this.ChartAreas[0].AxisY.ValueToPixelPosition(lastPoint.YValues[0]); DrawCustomToolTip(new Point(x, y), e.ChartGraphics.Graphics); } }
protected void Chart1_PostPaint(object sender, ChartPaintEventArgs e) { if (e.ChartElement == Chart1) { for (Int32 i = Chart1.ChartAreas.Count - 1; i >= 0; i--) { ChartArea area = Chart1.ChartAreas[i]; MapArea mapArea = new MapArea(area.Name, String.Empty, String.Empty, area.Name, area.Position.ToRectangleF(), null); Chart1.MapAreas.Add(mapArea); } } }
private void chart_Test_PrePaint(object sender, ChartPaintEventArgs e) { if (e.ChartElement is ChartArea) { // displayNowGoal.Text = "81%"; displayNowGoal.Width = e.Position.Width; displayNowGoal.Height = e.Position.Height; displayNowGoal.X = e.Position.X; displayNowGoal.Y = e.Position.Y; displayNowGoal.ForeColor = Color.FromArgb(80, 80, 80); displayNowGoal.Font = new Font("맑은 고딕", 24, FontStyle.Bold); } }
private void chart_PrePaint(object aSender, ChartPaintEventArgs aEventArgs) { if (mMove) { if (mMouseY > 0 && mMouseY < chart.Height) { double lY = chart.ChartAreas[0].AxisY.PixelPositionToValue(mMouseY); chart.Series[0].Points[mSelected].YValues[0] = lY; mPoints[mIndex[mSelected]] = lY; updateSelectedPoint(); } } }
private void chart2_PrePaint(object sender, ChartPaintEventArgs e) { if (e.ChartElement is ChartArea) { ta.Text = "81%"; ta.Width = e.Position.Width; ta.Height = e.Position.Height; ta.X = e.Position.X; ta.Y = e.Position.Y; ta.ForeColor = Color.White; ta.Font = new Font("Ms Sans Serif", 24, FontStyle.Bold); } }
private void OnDrawingFinished(object sender, ChartPaintEventArgs e) { var chart = (Chart)sender; var points = chart.Series.SelectMany(x => x.Points).Count(); if (points < _pointsCount) { return; } MessageBox.Show("Done!"); chart1.PostPaint -= OnDrawingFinished; }
/// <summary> /// Hook such a method to the chart paint event listeners /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ChartOverlayPainter(object sender, ChartPaintEventArgs e) { // Don't want to print instructions to file if (this.PrintMode) { return; } var g = e.Graphics; var chart = e.Chart; // Demo: Static billboards begin ----------------------------------- // Demonstrate how to draw static billboards // "push matrix" -- save our transformation matrix e.Chart.BeginBillboardMode(e.Graphics); // draw mouse command instructions int margin = 300; int left = 20; var color = chart.HeaderFormat.Color; StringBuilder builder = new StringBuilder(); builder.AppendLine("THIS IS DRAWN BY A CUSTOM OVERLAY PAINTER TO SHOW DEFAULT MOUSE COMMANDS."); builder.AppendLine("*******************************************************************************************************"); builder.AppendLine("Left Click - Select task and display properties in PropertyGrid"); builder.AppendLine("Left Mouse Drag - Change task starting point"); builder.AppendLine("Right Mouse Drag - Change task duration"); builder.AppendLine("Middle Mouse Drag - Change task complete percentage"); builder.AppendLine("Left Doubleclick - Toggle collaspe on task group"); builder.AppendLine("Right Doubleclick - Split task into task parts"); builder.AppendLine("Left Mouse Dragdrop onto another task - Group drag task under drop task"); builder.AppendLine("Right Mouse Dragdrop onto another task part - Join task parts"); builder.AppendLine("SHIFT + Left Mouse Dragdrop onto another task - Make drop task precedent of drag task"); builder.AppendLine("ALT + Left Dragdrop onto another task - Ungroup drag task from drop task / Remove drop task from drag task precedent list"); builder.AppendLine("SHIFT + Left Mouse Dragdrop - Order tasks"); builder.AppendLine("SHIFT + Middle Click - Create new task"); builder.AppendLine("ALT + Middle Click - Delete task"); builder.AppendLine("Left Doubleclick - Toggle collaspe on task group"); var size = g.MeasureString(builder.ToString(), e.Chart.Font); var background = new Rectangle(left, chart.Height - margin, (int)size.Width, (int)size.Height); background.Inflate(10, 10); g.FillRectangle(new System.Drawing.Drawing2D.LinearGradientBrush(background, Color.LightYellow, Color.Transparent, System.Drawing.Drawing2D.LinearGradientMode.Vertical), background); g.DrawRectangle(Pens.Brown, background); g.DrawString(builder.ToString(), chart.Font, color, new PointF(left, chart.Height - margin)); // "pop matrix" -- restore the previous matrix e.Chart.EndBillboardMode(e.Graphics); // Demo: Static billboards end ----------------------------------- }
private void ChartPicture_AfterPaint(object sender, ChartPaintEventArgs e) { if ((Chart)serviceContainer.GetService(typeof(Chart)) == null) { return; } for (int i = 0; i < Series.Count; i++) { if (Series[i].UnPrepareData(null)) { i--; } } }
private void Chart1_PostPaint(object sender, ChartPaintEventArgs e) { // Painting series object if (e.ChartElement is Series) { // Add custom painting only to the series with name "Series2" Series series = (Series)e.ChartElement; if (series.Name == "Series2" && series.Tag == null) { // Find data point with maximum Y value DataPoint dataPoint = series.Points.FindMaxByValue(); // Load bitmap from file System.Drawing.Image bitmap = Bitmap.FromFile(this.Page.MapPath("money.png")); // Set White color as transparent ImageAttributes attrib = new ImageAttributes(); attrib.SetColorKey(Color.White, Color.White, ColorAdjustType.Default); // Calculates marker position depending on the data point X and Y values RectangleF imagePosition = RectangleF.Empty; imagePosition.X = (float)e.ChartGraphics.GetPositionFromAxis( "Chart Area 1", AxisName.X, dataPoint.XValue); imagePosition.Y = (float)e.ChartGraphics.GetPositionFromAxis( "Chart Area 1", AxisName.Y, dataPoint.YValues[0]); imagePosition = e.ChartGraphics.GetAbsoluteRectangle(imagePosition); imagePosition.Width = bitmap.Width; imagePosition.Height = bitmap.Height; imagePosition.Y -= bitmap.Height; imagePosition.X -= bitmap.Width / 2; // Draw image e.ChartGraphics.Graphics.DrawImage(bitmap, Rectangle.Round(imagePosition), 0, 0, bitmap.Width, bitmap.Height, GraphicsUnit.Pixel, attrib); // Add a custom map area in the coordinates of the image RectangleF rect = e.ChartGraphics.GetRelativeRectangle(imagePosition); MapArea area = new MapArea("Maximum Y value marker. Y = " + dataPoint.YValues[0], "money.htm", "target=\"_blank\"", String.Empty, rect, null); Chart1.MapAreas.Add(area); // Dispose image object bitmap.Dispose(); series.Tag = true; } } }
protected void PointsChart_PrePaint(object sender, ChartPaintEventArgs e) { if (e.ChartElement is ChartArea) { var ann = new TextAnnotation(); ann.Text = "Total: " + totalpoints.ToString(); ann.Width = e.Position.Width; ann.Height = e.Position.Height; ann.X = e.Position.X; ann.Y = e.Position.Y; ann.Font = new System.Drawing.Font("Arial", 10, System.Drawing.FontStyle.Bold); PointsChart.Annotations.Add(ann); } }
private void Chart1_PostPaint(object sender, ChartPaintEventArgs e) { // Painting series object if(e.ChartElement is Series) { // Add custom painting only to the series with name "Series2" Series series = (Series)e.ChartElement; if(series.Name == "Series2" && series.Tag == null) { // Find data point with maximum Y value DataPoint dataPoint = series.Points.FindMaxByValue(); // Load bitmap from file System.Drawing.Image bitmap = Bitmap.FromFile(this.Page.MapPath("money.png")); // Set White color as transparent ImageAttributes attrib = new ImageAttributes(); attrib.SetColorKey(Color.White, Color.White, ColorAdjustType.Default); // Calculates marker position depending on the data point X and Y values RectangleF imagePosition = RectangleF.Empty; imagePosition.X = (float)e.ChartGraphics.GetPositionFromAxis( "Chart Area 1", AxisName.X, dataPoint.XValue); imagePosition.Y = (float)e.ChartGraphics.GetPositionFromAxis( "Chart Area 1", AxisName.Y, dataPoint.YValues[0]); imagePosition = e.ChartGraphics.GetAbsoluteRectangle(imagePosition); imagePosition.Width = bitmap.Width; imagePosition.Height = bitmap.Height; imagePosition.Y -= bitmap.Height; imagePosition.X -= bitmap.Width /2; // Draw image e.ChartGraphics.Graphics.DrawImage(bitmap, Rectangle.Round(imagePosition), 0, 0, bitmap.Width, bitmap.Height, GraphicsUnit.Pixel, attrib); // Add a custom map area in the coordinates of the image RectangleF rect = e.ChartGraphics.GetRelativeRectangle(imagePosition); MapArea area = new MapArea("Maximum Y value marker. Y = " + dataPoint.YValues[0], "money.htm", "target=\"_blank\"", String.Empty, rect, null); Chart1.MapAreas.Add(area); // Dispose image object bitmap.Dispose(); series.Tag = true; } } }
//used for 3D drawing on chart private void chart1_PostPaint(object sender, ChartPaintEventArgs e) { Chart chart = sender as Chart; if (chart.Series.Count < 1) { return; } if (chart.Series[0].Points.Count < 1) { return; } visualisator.HandlePaintEventForChart(chart, e); }
private void chart1_PostPaint(object sender, ChartPaintEventArgs e) { if (invalidated && unknown_traces.Count > 0) { int index = 0; for (index = 0; index < _displaying_traces.Count; index++) { if (unknown_traces.Contains(data.Series[index])) { _legends.Add(data.Series[index], chart1.Series[index].Color, true); } } } invalidated = false; }
private void ChartPicture_AfterPaint(object sender, ChartPaintEventArgs e) { Chart chart = (Chart)this.serviceContainer.GetService(typeof(Chart)); if (chart != null) { for (int i = 0; i < this.Series.Count; i++) { Series series = this.Series[i]; if (series.UnPrepareData(null)) { i--; } } } }
protected void Chart1_PostPaint(object sender, ChartPaintEventArgs e) { if (e.ChartElement.ToString().Contains("Series")) { int count = Chart1.Series[0].Points.Count - 1; for (int i = count; i >= 0; i--) { DataPoint dp = Chart1.Series[0].Points[i]; float size = (float)(deltax * (dp.YValues[1] - dp.YValues[0] + deltay2)); float x = (float)(deltax * dp.YValues[0]); float y = (float)(deltay * (count - dp.XValue + 2)); e.ChartGraphics.Graphics.DrawString(string.Format("{0}", dp.YValues[0]), font, brush, new PointF(x, y)); e.ChartGraphics.Graphics.DrawString(string.Format("{0}", dp.YValues[1]), font, brush, new PointF(x + size, y)); } } }
private void Charter_PostPaint(object sender, ChartPaintEventArgs e) { ChartArea area = e.ChartElement as ChartArea; if (area != selectedChartArea) { return; } int cx, cy, ey; StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Far; format.LineAlignment = StringAlignment.Center; Graphics grfx = e.ChartGraphics.Graphics; Bitmap bmp; using (Font font = new Font(FontFamily.GenericSansSerif, 12)) { for (int index = 0; index < Globals.GPUs.Count; index++) { cx = (int)area.AxisX.ValueToPixelPosition(index + 1); cy = (int)area.AxisY.ValueToPixelPosition(0); ey = (int)area.AxisY.ValueToPixelPosition(e.Chart.Series[area.Name].Points[index].YValues[0]); SizeF textSize = grfx.MeasureString(Globals.GPUs[index].Text, font, cy - ey, format); //RectangleF textRect = new RectangleF(cx - textSize.Width, ey, textSize.Width, cy - ey); bmp = new Bitmap((int)textSize.Width, (int)textSize.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); using (Graphics bgrfx = Graphics.FromImage(bmp)) { //bgrfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel; //using (SolidBrush backBr = new SolidBrush(ThemeColors.PresetColors[index])) // bgrfx.FillRectangle(backBr, 0, 0, bmp.Width, bmp.Height); bgrfx.DrawString(Globals.GPUs[index].Text, font, Brushes.White, 0, 0); //TextRenderer.DrawText(bgrfx, Globals.GPUs[index].Text, font, new Point(0,0), Color.White); } bmp.RotateFlip(RotateFlipType.Rotate270FlipNone); //grfx.FillRectangle(Brushes.Lime, cx - textSize.Width / 2, cy - textSize.Height, textSize.Width, textSize.Height); grfx.DrawImage(bmp, cx - bmp.Width / 2, cy - bmp.Height); //grfx.DrawImage(bmp, 10, 10); } } }
protected override void OnPostPaint(ChartPaintEventArgs e) { base.OnPostPaint(e); if (!(e.ChartElement is ThresholdBarChart)) { return; } if (Series.Count != 2) { return; } for (int i = 0; i < Series[0].Points.Count; i++) { Series[0].Points[i].YValues[0] += Series[1].Points[i].YValues[0]; } Series.Remove(Series[1]); }
/// <summary> /// Event fired when chart picture is going to be painted. /// </summary> /// <param name="sender">Sender object.</param> /// <param name="e">Event arguments.</param> private void ChartPicture_BeforePaint(object sender, ChartPaintEventArgs e) { // Prepare series for drawing int markerIndex = 1; for (int index = 0; index < this.Series.Count; index++) { Series series = this.Series[index]; // Reset series "X values are zeros" flag series.xValuesZerosChecked = false; series.xValuesZeros = false; // Set series colors from palette IChartType chartType = e.CommonElements.ChartTypeRegistry.GetChartType(series.ChartTypeName); bool paletteColorsInPoints = chartType.ApplyPaletteColorsToPoints; // if the series palette is set the we can color all data points, even on column chart. if (series.Palette != ChartColorPalette.None) { paletteColorsInPoints = true; } this.PrepareData( paletteColorsInPoints, series.Name); // Clear temp. marker style if (series.tempMarkerStyleIsSet) { series.MarkerStyle = MarkerStyle.None; series.tempMarkerStyleIsSet = false; } // Set marker style for chart types based on markes if (chartType.GetLegendImageStyle(series) == LegendImageStyle.Marker && series.MarkerStyle == MarkerStyle.None) { series.MarkerStyle = (MarkerStyle)markerIndex++; series.tempMarkerStyleIsSet = true; if (markerIndex > 9) { markerIndex = 1; } } } }
/// <summary> /// Event fired after chart picture was painted. /// </summary> /// <param name="sender">Sender object.</param> /// <param name="e">Event arguments.</param> private void ChartPicture_AfterPaint(object sender, ChartPaintEventArgs e) { Chart control = (Chart)serviceContainer.GetService(typeof(Chart)); if (control != null) { // Clean up series after drawing for (int index = 0; index < this.Series.Count; index++) { Series series = this.Series[index]; if (series.UnPrepareData(control.Site)) { --index; } } } }
private void chart1_PostPaint(object sender, ChartPaintEventArgs e) { //唉,直接拿graphics撸一个吧 if (_chartType == ChartType.SequenceChart) { chart1.Annotations.Clear(); var y1 = chart1.ChartAreas[0].AxisY.ValueToPixelPosition(0); for (int i = 0; i < chart1.Series[0].Points.Count; i++) { var x1 = chart1.ChartAreas[0].AxisX.ValueToPixelPosition(chart1.Series[0].Points[i].XValue); var y2 = y1 - chart1.Series[0].Points[i].YValues[0] * 6; e.ChartGraphics.Graphics.DrawLine(new Pen(Color.Red, 1.0f), (float)x1, (float)y1, (float)x1, (float)y2); } chart1.Invalidate(); } }
/// <summary> /// Post Paint - Empty Chart /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void PostPaint_EmptyChart(object sender, ChartPaintEventArgs e) { // If the series count is 0, this means that there is no data. if (artifactReport.Series.Count == 0) { // create text to draw if (textToDraw.Equals(string.Empty)) { textToDraw = "No events reported as of " + String.Format("{0:f}", DateTime.UtcNow); } // get graphics tools System.Drawing.Graphics g = e.ChartGraphics.Graphics; System.Drawing.Font drawFont = System.Drawing.SystemFonts.CaptionFont; System.Drawing.Brush drawBrush = System.Drawing.Brushes.Gray; // see how big the text will be int txtWidth = (int)g.MeasureString(textToDraw, drawFont).Width; int txtHeight = (int)g.MeasureString(textToDraw, drawFont).Height; // where to draw int x = 150; // a few pixels from the left border int y = (int)e.Chart.Height.Value; y = y - txtHeight - 200; // a few pixels off the bottom // draw the string g.DrawString(textToDraw, drawFont, drawBrush, x, y); } }
public void Paint(ChartPaintEventArgs e) { var g = e.Graphics; var chart = e.Chart; // dragging outline / trail if (DraggedRect != RectangleF.Empty) g.DrawRectangle(Pens.Red, DraggedRect); // insertion indicator line if (Row != int.MinValue) { float y = e.Chart._ChartRowToChartCoord(Row) + e.Chart.BarHeight / 2.0f; g.DrawLine(Pens.CornflowerBlue, new PointF(0, y), new PointF(e.Chart.Width, y)); } // tool tip if (_mToolTipMouse != Point.Empty && _mToolTipText != string.Empty) { var size = g.MeasureString(_mToolTipText, chart.Font).ToSize(); var tooltiprect = new RectangleF(_mToolTipMouse, size); tooltiprect.Offset(0, -tooltiprect.Height); var textstart = new PointF(tooltiprect.Left, tooltiprect.Top); tooltiprect.Inflate(5, 5); g.FillRectangle(Brushes.LightYellow, tooltiprect); g.DrawString(_mToolTipText, chart.Font, Brushes.Black, textstart); } }
/// <summary> /// Hook such a method to the chart paint event listeners /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ChartOverlayPainter(object sender, ChartPaintEventArgs e) { // Don't want to print instructions to file if (this.PrintMode) return; var g = e.Graphics; var chart = e.Chart; // Demo: Static billboards begin ----------------------------------- // Demonstrate how to draw static billboards // "push matrix" -- save our transformation matrix e.Chart.BeginBillboardMode(e.Graphics); // draw mouse command instructions int margin = 300; int left = 20; var color = chart.HeaderFormat.Color; StringBuilder builder = new StringBuilder(); builder.AppendLine("THIS IS DRAWN BY A CUSTOM OVERLAY PAINTER TO SHOW DEFAULT MOUSE COMMANDS."); builder.AppendLine("*******************************************************************************************************"); builder.AppendLine("Left Click - Select task and display properties in PropertyGrid"); builder.AppendLine("Left Mouse Drag - Change task starting point"); builder.AppendLine("Right Mouse Drag - Change task duration"); builder.AppendLine("Middle Mouse Drag - Change task complete percentage"); builder.AppendLine("Left Doubleclick - Toggle collaspe on task group"); builder.AppendLine("Right Doubleclick - Split task into task parts"); builder.AppendLine("Left Mouse Dragdrop onto another task - Group drag task under drop task"); builder.AppendLine("Right Mouse Dragdrop onto another task part - Join task parts"); builder.AppendLine("SHIFT + Left Mouse Dragdrop onto another task - Make drop task precedent of drag task"); builder.AppendLine("ALT + Left Dragdrop onto another task - Ungroup drag task from drop task / Remove drop task from drag task precedent list"); builder.AppendLine("SHIFT + Left Mouse Dragdrop - Order tasks"); builder.AppendLine("SHIFT + Middle Click - Create new task"); builder.AppendLine("ALT + Middle Click - Delete task"); builder.AppendLine("Left Doubleclick - Toggle collaspe on task group"); var size = g.MeasureString(builder.ToString(), e.Chart.Font); var background = new Rectangle(left, chart.Height - margin, (int)size.Width, (int)size.Height); background.Inflate(10, 10); g.FillRectangle(new System.Drawing.Drawing2D.LinearGradientBrush(background, Color.LightYellow, Color.Transparent, System.Drawing.Drawing2D.LinearGradientMode.Vertical), background); g.DrawRectangle(Pens.Brown, background); g.DrawString(builder.ToString(), chart.Font, color, new PointF(left, chart.Height - margin)); // "pop matrix" -- restore the previous matrix e.Chart.EndBillboardMode(e.Graphics); // Demo: Static billboards end ----------------------------------- }
protected void Chart1_PostPaint(object sender, ChartPaintEventArgs e) { if (e.ChartElement == Chart1) { for (Int32 i = Chart1.ChartAreas.Count-1; i >= 0; i--) { ChartArea area = Chart1.ChartAreas[i]; MapArea mapArea = new MapArea(area.Name, String.Empty, String.Empty, area.Name, area.Position.ToRectangleF(), null); Chart1.MapAreas.Add(mapArea); } } }
protected void taskChart_PostPaint(object sender, ChartPaintEventArgs e) { // If the series count is 0, this means that there is no data. if (taskChart.Series[0].Points.Count == 0) { // create text to draw if (textToDraw.Equals(string.Empty)) { textToDraw = "No tasks found"; } // get graphics tools System.Drawing.Graphics g = e.ChartGraphics.Graphics; System.Drawing.Font drawFont = System.Drawing.SystemFonts.DefaultFont; System.Drawing.Brush drawBrush = System.Drawing.Brushes.Gray; // see how big the text will be int txtWidth = (int)g.MeasureString(textToDraw, drawFont).Width; int txtHeight = (int)g.MeasureString(textToDraw, drawFont).Height; // where to draw int x = 120; // a few pixels from the left border int y = (int)e.Chart.Height.Value; y = y - txtHeight - 100; // a few pixels off the bottom // draw the string g.DrawString(textToDraw, drawFont, drawBrush, x, y); } }