protected virtual LabelAlignmentTypes GetAutoLabelPosition(ChartArea area, Series series, int pointIndex) { LabelAlignmentTypes result = LabelAlignmentTypes.Top; float num = 360f / (float)area.CircularSectorsNumber * (float)pointIndex; if (num == 0f) { result = LabelAlignmentTypes.TopRight; } else if (num >= 0f && num <= 45f) { result = LabelAlignmentTypes.Top; } else if (num >= 45f && num <= 90f) { result = LabelAlignmentTypes.TopRight; } else if (num >= 90f && num <= 135f) { result = LabelAlignmentTypes.BottomRight; } else if (num >= 135f && num <= 180f) { result = LabelAlignmentTypes.BottomRight; } else if (num >= 180f && num <= 225f) { result = LabelAlignmentTypes.BottomLeft; } else if (num >= 225f && num <= 270f) { result = LabelAlignmentTypes.BottomLeft; } else if (num >= 270f && num <= 315f) { result = LabelAlignmentTypes.TopLeft; } else if (num >= 315f && num <= 360f) { result = LabelAlignmentTypes.TopLeft; } return(result); }
internal void DrawLabels3D(CommonElements common, ChartGraphics graph, ChartArea area, DataPoint3D pointEx, int pointIndex, Series series, RectangleF rectangle) { DataPoint dataPoint = pointEx.dataPoint; StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; Region clip = graph.Clip; graph.Clip = new Region(); if (dataPoint.ShowLabelAsValue || dataPoint.Label.Length > 0) { string text; if (dataPoint.Label.Length == 0) { double value = GetYValue(common, area, series, dataPoint, pointIndex, -2); if (hundredPercentStacked && dataPoint.LabelFormat.Length == 0) { value = Math.Round(value, 2); } text = ValueConverter.FormatValue(series.chart, dataPoint, value, dataPoint.LabelFormat, series.YValueType, ChartElementType.DataPoint); } else { text = dataPoint.ReplaceKeywords(dataPoint.Label); if (series.chart != null && series.chart.LocalizeTextHandler != null) { text = series.chart.LocalizeTextHandler(dataPoint, text, dataPoint.ElementId, ChartElementType.DataPoint); } } PointF pointF = PointF.Empty; pointF.X = rectangle.X + rectangle.Width / 2f; pointF.Y = rectangle.Y + rectangle.Height / 2f; Point3D[] array = new Point3D[1] { new Point3D(pointF.X, pointF.Y, pointEx.zPosition + pointEx.depth) }; area.matrix3D.TransformPoints(array); pointF.X = array[0].X; pointF.Y = array[0].Y; int angle = dataPoint.FontAngle; SizeF labelSize = SizeF.Empty; if (series.SmartLabels.Enabled) { labelSize = graph.GetRelativeSize(graph.MeasureString(text, dataPoint.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic))); bool markerOverlapping = series.SmartLabels.MarkerOverlapping; LabelAlignmentTypes movingDirection = series.SmartLabels.MovingDirection; series.SmartLabels.MarkerOverlapping = true; if (series.SmartLabels.MovingDirection == (LabelAlignmentTypes.Top | LabelAlignmentTypes.Bottom | LabelAlignmentTypes.Right | LabelAlignmentTypes.Left | LabelAlignmentTypes.TopLeft | LabelAlignmentTypes.TopRight | LabelAlignmentTypes.BottomLeft | LabelAlignmentTypes.BottomRight)) { series.SmartLabels.MovingDirection = (LabelAlignmentTypes.Top | LabelAlignmentTypes.Bottom); } pointF = area.smartLabels.AdjustSmartLabelPosition(common, graph, area, series.SmartLabels, pointF, labelSize, ref format, pointF, new SizeF(0f, 0f), LabelAlignmentTypes.Center); series.SmartLabels.MarkerOverlapping = markerOverlapping; series.SmartLabels.MovingDirection = movingDirection; angle = 0; } if (!pointF.IsEmpty) { if (labelSize.IsEmpty) { labelSize = graph.GetRelativeSize(graph.MeasureString(text, dataPoint.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic))); } RectangleF empty = RectangleF.Empty; SizeF sizeF = new SizeF(labelSize.Width, labelSize.Height); sizeF.Height += labelSize.Height / 8f; sizeF.Width += sizeF.Width / (float)text.Length; graph.DrawPointLabelStringRel(backPosition: new RectangleF(pointF.X - sizeF.Width / 2f, pointF.Y - sizeF.Height / 2f - labelSize.Height / 10f, sizeF.Width, sizeF.Height), common: common, text: text, font: dataPoint.Font, brush: new SolidBrush(dataPoint.FontColor), position: pointF, format: format, angle: angle, backColor: dataPoint.LabelBackColor, borderColor: dataPoint.LabelBorderColor, borderWidth: dataPoint.LabelBorderWidth, borderStyle: dataPoint.LabelBorderStyle, series: series, point: dataPoint, pointIndex: pointIndex); } } graph.Clip = clip; }
public void DrawLabels(CommonElements common, ChartGraphics graph, ChartArea area, DataPoint point, int pointIndex, Series series, RectangleF rectangle) { StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; Region clip = graph.Clip; graph.Clip = new Region(); if (point.ShowLabelAsValue || point.Label.Length > 0) { string text; if (point.Label.Length == 0) { double value = GetYValue(common, area, series, point, pointIndex, 0); if (hundredPercentStacked && point.LabelFormat.Length == 0) { value = Math.Round(value, 2); } text = ValueConverter.FormatValue(series.chart, point, value, point.LabelFormat, series.YValueType, ChartElementType.DataPoint); } else { text = point.ReplaceKeywords(point.Label); if (series.chart != null && series.chart.LocalizeTextHandler != null) { text = series.chart.LocalizeTextHandler(point, text, point.ElementId, ChartElementType.DataPoint); } } PointF pointF = PointF.Empty; pointF.X = rectangle.X + rectangle.Width / 2f; pointF.Y = rectangle.Y + rectangle.Height / 2f; int angle = point.FontAngle; if (text.Trim().Length != 0) { SizeF labelSize = SizeF.Empty; if (series.SmartLabels.Enabled) { labelSize = graph.GetRelativeSize(graph.MeasureString(text, point.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic))); bool markerOverlapping = series.SmartLabels.MarkerOverlapping; LabelAlignmentTypes movingDirection = series.SmartLabels.MovingDirection; series.SmartLabels.MarkerOverlapping = true; if (series.SmartLabels.MovingDirection == (LabelAlignmentTypes.Top | LabelAlignmentTypes.Bottom | LabelAlignmentTypes.Right | LabelAlignmentTypes.Left | LabelAlignmentTypes.TopLeft | LabelAlignmentTypes.TopRight | LabelAlignmentTypes.BottomLeft | LabelAlignmentTypes.BottomRight)) { series.SmartLabels.MovingDirection = (LabelAlignmentTypes.Top | LabelAlignmentTypes.Bottom); } pointF = area.smartLabels.AdjustSmartLabelPosition(common, graph, area, series.SmartLabels, pointF, labelSize, ref format, pointF, new SizeF(0f, 0f), LabelAlignmentTypes.Center); series.SmartLabels.MarkerOverlapping = markerOverlapping; series.SmartLabels.MovingDirection = movingDirection; angle = 0; } if (!pointF.IsEmpty) { PointF absolutePoint = graph.GetAbsolutePoint(pointF); if (graph.TextRenderingHint != TextRenderingHint.AntiAlias) { absolutePoint.X = (float)Math.Ceiling(absolutePoint.X) + 1f; pointF = graph.GetRelativePoint(absolutePoint); } if (labelSize.IsEmpty) { labelSize = graph.GetRelativeSize(graph.MeasureString(text, point.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic))); } RectangleF empty = RectangleF.Empty; SizeF sizeF = new SizeF(labelSize.Width, labelSize.Height); sizeF.Height += labelSize.Height / 8f; sizeF.Width += sizeF.Width / (float)text.Length; graph.DrawPointLabelStringRel(backPosition: new RectangleF(pointF.X - sizeF.Width / 2f, pointF.Y - sizeF.Height / 2f - labelSize.Height / 10f, sizeF.Width, sizeF.Height), common: common, text: text, font: point.Font, brush: new SolidBrush(point.FontColor), position: pointF, format: format, angle: angle, backColor: point.LabelBackColor, borderColor: point.LabelBorderColor, borderWidth: point.LabelBorderWidth, borderStyle: point.LabelBorderStyle, series: series, point: point, pointIndex: pointIndex); } } } graph.Clip = clip; }
private static float GetLabelYPosition(RectangleF treeMapNodeRelativeRect, float labelRelativeHeight, LabelAlignmentTypes labelAlignment) { float result = 0f; switch (labelAlignment) { case LabelAlignmentTypes.Bottom: case LabelAlignmentTypes.BottomLeft: case LabelAlignmentTypes.BottomRight: result = treeMapNodeRelativeRect.Y + treeMapNodeRelativeRect.Height - labelRelativeHeight; break; case LabelAlignmentTypes.Right: case LabelAlignmentTypes.Left: case LabelAlignmentTypes.Center: result = (float)(treeMapNodeRelativeRect.Y + (treeMapNodeRelativeRect.Height - labelRelativeHeight) / 2.0); break; case LabelAlignmentTypes.Top: case LabelAlignmentTypes.TopLeft: case LabelAlignmentTypes.TopRight: result = treeMapNodeRelativeRect.Y; break; } return(result); }
private static RectangleF GetLabelRelativeRect(ChartGraphics graph, Font font, RectangleF treeMapNodeRelativeRect, string text, LabelAlignmentTypes labelAlignment) { if (string.IsNullOrEmpty(text)) { return(RectangleF.Empty); } SizeF relativeSize = graph.GetRelativeSize(graph.MeasureString(text.Replace("\\n", "\n"), font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic))); float num = relativeSize.Width + relativeSize.Width / (float)text.Length; float num2 = (float)(relativeSize.Height + relativeSize.Height / 8.0); return(new RectangleF(TreeMapChart.GetLabelXPosition(treeMapNodeRelativeRect, num, labelAlignment), TreeMapChart.GetLabelYPosition(treeMapNodeRelativeRect, num2, labelAlignment), num, num2)); }
private bool FindNewPosition(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelsStyle smartLabelsStyle, ref PointF labelPosition, SizeF labelSize, ref StringFormat format, PointF markerPosition, ref SizeF markerSize, ref LabelAlignmentTypes labelAlignment, bool checkCalloutLineOverlapping) { SizeF sizeF = SizeF.Empty; PointF pointF = PointF.Empty; int i = 0; float num = 0f; bool flag = false; LabelAlignmentTypes[] array = new LabelAlignmentTypes[9] { LabelAlignmentTypes.Top, LabelAlignmentTypes.Bottom, LabelAlignmentTypes.Left, LabelAlignmentTypes.Right, LabelAlignmentTypes.TopLeft, LabelAlignmentTypes.TopRight, LabelAlignmentTypes.BottomLeft, LabelAlignmentTypes.BottomRight, LabelAlignmentTypes.Center }; SizeF relativeSize = graph.GetRelativeSize(new SizeF(1f, 1f)); bool flag2 = false; float num2 = 2f; float num3 = (float)Math.Min(smartLabelsStyle.MinMovingDistance, smartLabelsStyle.MaxMovingDistance); float num4 = (float)Math.Max(smartLabelsStyle.MinMovingDistance, smartLabelsStyle.MaxMovingDistance); num = num3; while (!flag2 && num <= num4) { sizeF = new SizeF(markerSize.Width + num * (relativeSize.Width * 2f), markerSize.Height + num * (relativeSize.Height * 2f)); for (i = 0; i < array.Length; i++) { if ((array[i] != LabelAlignmentTypes.Center || num == num3) && (smartLabelsStyle.MovingDirection & array[i]) == array[i]) { pointF = CalculatePosition(array[i], markerPosition, sizeF, labelSize, ref format); if (!IsSmartLabelCollide(common, null, area, smartLabelsStyle, pointF, labelSize, markerPosition, format, array[i], checkCalloutLineOverlapping)) { flag2 = true; flag = ((num != 0f) ? true : false); break; } } } num += num2; } if (flag2) { markerSize = sizeF; labelPosition = pointF; labelAlignment = array[i]; } if (!flag2 && smartLabelsStyle.HideOverlapped) { labelPosition = PointF.Empty; } if (!(flag && flag2)) { return(false); } return(true); }
private void DrawLabels3D(ChartArea area, Axis hAxis, ChartGraphics graph, CommonElements common, RectangleF rectSize, DataPoint3D pointEx, Series ser, double barStartPosition, double barSize, double width, int pointIndex) { DataPoint dataPoint = pointEx.dataPoint; if (!ser.ShowLabelAsValue && !dataPoint.ShowLabelAsValue && dataPoint.Label.Length <= 0) { return; } RectangleF rectangleF = RectangleF.Empty; StringFormat format = new StringFormat(); string text; if (dataPoint.Label.Length == 0) { double value = GetYValue(common, area, ser, dataPoint, pointIndex, -2); if (hundredPercentStacked && dataPoint.LabelFormat.Length == 0) { value = Math.Round(value, 2); } text = ValueConverter.FormatValue(ser.chart, dataPoint, value, dataPoint.LabelFormat, ser.YValueType, ChartElementType.DataPoint); } else { text = dataPoint.ReplaceKeywords(dataPoint.Label); if (ser.chart != null && ser.chart.LocalizeTextHandler != null) { text = ser.chart.LocalizeTextHandler(dataPoint, text, dataPoint.ElementId, ChartElementType.DataPoint); } } SizeF size = SizeF.Empty; if ((dataPoint.MarkerStyle != 0 || dataPoint.MarkerImage.Length > 0) && pointEx.index % ser.MarkerStep == 0) { if (dataPoint.MarkerImage.Length == 0) { size.Width = dataPoint.MarkerSize; size.Height = dataPoint.MarkerSize; } else { Image image = common.ImageLoader.LoadImage(dataPoint.MarkerImage); size.Width = image.Width; size.Height = image.Height; } size = graph.GetRelativeSize(size); } BarValueLabelDrawingStyle barValueLabelDrawingStyle = BarValueLabelDrawingStyle.Center; string text2 = ""; if (dataPoint.IsAttributeSet("BarLabelStyle")) { text2 = dataPoint["BarLabelStyle"]; } else if (ser.IsAttributeSet("BarLabelStyle")) { text2 = ser["BarLabelStyle"]; } if (text2 != null && text2.Length > 0) { if (string.Compare(text2, "Left", StringComparison.OrdinalIgnoreCase) == 0) { barValueLabelDrawingStyle = BarValueLabelDrawingStyle.Left; } else if (string.Compare(text2, "Right", StringComparison.OrdinalIgnoreCase) == 0) { barValueLabelDrawingStyle = BarValueLabelDrawingStyle.Right; } else if (string.Compare(text2, "Center", StringComparison.OrdinalIgnoreCase) == 0) { barValueLabelDrawingStyle = BarValueLabelDrawingStyle.Center; } else if (string.Compare(text2, "Outside", StringComparison.OrdinalIgnoreCase) == 0) { barValueLabelDrawingStyle = BarValueLabelDrawingStyle.Outside; } } bool flag = false; while (!flag) { format.Alignment = StringAlignment.Near; format.LineAlignment = StringAlignment.Center; if (barStartPosition < barSize) { rectangleF.X = rectSize.Right; rectangleF.Width = area.PlotAreaPosition.Right() - rectSize.Right; } else { rectangleF.X = area.PlotAreaPosition.X; rectangleF.Width = rectSize.X - area.PlotAreaPosition.X; } rectangleF.Y = rectSize.Y - (float)width / 2f; rectangleF.Height = rectSize.Height + (float)width; switch (barValueLabelDrawingStyle) { case BarValueLabelDrawingStyle.Outside: if (!size.IsEmpty) { rectangleF.Width -= Math.Min(rectangleF.Width, size.Width / 2f); if (barStartPosition < barSize) { rectangleF.X += Math.Min(rectangleF.Width, size.Width / 2f); } } break; case BarValueLabelDrawingStyle.Left: rectangleF = rectSize; format.Alignment = StringAlignment.Near; break; case BarValueLabelDrawingStyle.Center: rectangleF = rectSize; format.Alignment = StringAlignment.Center; break; case BarValueLabelDrawingStyle.Right: rectangleF = rectSize; format.Alignment = StringAlignment.Far; if (!size.IsEmpty) { rectangleF.Width -= Math.Min(rectangleF.Width, size.Width / 2f); if (barStartPosition >= barSize) { rectangleF.X += Math.Min(rectangleF.Width, size.Width / 2f); } } break; } if (barStartPosition >= barSize) { if (format.Alignment == StringAlignment.Far) { format.Alignment = StringAlignment.Near; } else if (format.Alignment == StringAlignment.Near) { format.Alignment = StringAlignment.Far; } } flag = true; } SizeF sizeF = graph.MeasureStringRel(text, dataPoint.Font, new SizeF(rectangleF.Width, rectangleF.Height), format); PointF empty = PointF.Empty; if (format.Alignment == StringAlignment.Near) { empty.X = rectangleF.X + sizeF.Width / 2f; } else if (format.Alignment == StringAlignment.Far) { empty.X = rectangleF.Right - sizeF.Width / 2f; } else { empty.X = (rectangleF.Left + rectangleF.Right) / 2f; } if (format.LineAlignment == StringAlignment.Near) { empty.Y = rectangleF.Top + sizeF.Height / 2f; } else if (format.LineAlignment == StringAlignment.Far) { empty.Y = rectangleF.Bottom - sizeF.Height / 2f; } else { empty.Y = (rectangleF.Bottom + rectangleF.Top) / 2f; } format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; int num = dataPoint.FontAngle; Point3D[] array = new Point3D[2] { new Point3D(empty.X, empty.Y, pointEx.zPosition + pointEx.depth), new Point3D(empty.X - 20f, empty.Y, pointEx.zPosition + pointEx.depth) }; area.matrix3D.TransformPoints(array); empty = array[0].PointF; if (num == 0 || num == 180) { array[0].PointF = graph.GetAbsolutePoint(array[0].PointF); array[1].PointF = graph.GetAbsolutePoint(array[1].PointF); float num2 = (float)Math.Atan((array[1].Y - array[0].Y) / (array[1].X - array[0].X)); num2 = (float)Math.Round(num2 * 180f / (float)Math.PI); num += (int)num2; } SizeF labelSize = SizeF.Empty; if (ser.SmartLabels.Enabled) { labelSize = graph.GetRelativeSize(graph.MeasureString(text, dataPoint.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic))); bool markerOverlapping = ser.SmartLabels.MarkerOverlapping; LabelAlignmentTypes movingDirection = ser.SmartLabels.MovingDirection; ser.SmartLabels.MarkerOverlapping = true; if (ser.SmartLabels.MovingDirection == (LabelAlignmentTypes.Top | LabelAlignmentTypes.Bottom | LabelAlignmentTypes.Right | LabelAlignmentTypes.Left | LabelAlignmentTypes.TopLeft | LabelAlignmentTypes.TopRight | LabelAlignmentTypes.BottomLeft | LabelAlignmentTypes.BottomRight)) { ser.SmartLabels.MovingDirection = (LabelAlignmentTypes.Right | LabelAlignmentTypes.Left); } empty = area.smartLabels.AdjustSmartLabelPosition(common, graph, area, ser.SmartLabels, empty, labelSize, ref format, empty, new SizeF(0f, 0f), LabelAlignmentTypes.Center); ser.SmartLabels.MarkerOverlapping = markerOverlapping; ser.SmartLabels.MovingDirection = movingDirection; num = 0; } if (!empty.IsEmpty) { if (labelSize.IsEmpty) { labelSize = graph.GetRelativeSize(graph.MeasureString(text, dataPoint.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic))); } RectangleF empty2 = RectangleF.Empty; SizeF sizeF2 = new SizeF(labelSize.Width, labelSize.Height); sizeF2.Height += labelSize.Height / 8f; sizeF2.Width += sizeF2.Width / (float)text.Length; graph.DrawPointLabelStringRel(backPosition: new RectangleF(empty.X - sizeF2.Width / 2f, empty.Y - sizeF2.Height / 2f - labelSize.Height / 10f, sizeF2.Width, sizeF2.Height), common: common, text: text, font: dataPoint.Font, brush: new SolidBrush(dataPoint.FontColor), position: empty, format: format, angle: num, backColor: dataPoint.LabelBackColor, borderColor: dataPoint.LabelBorderColor, borderWidth: dataPoint.LabelBorderWidth, borderStyle: dataPoint.LabelBorderStyle, series: ser, point: dataPoint, pointIndex: pointIndex); } }
internal override void DrawCallout(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelsStyle smartLabelsStyle, PointF labelPosition, SizeF labelSize, StringFormat format, PointF markerPosition, SizeF markerSize, LabelAlignmentTypes labelAlignment) { }
internal PointF AdjustSmartLabelPosition(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelsStyle smartLabelsStyle, PointF labelPosition, SizeF labelSize, ref StringFormat format, PointF markerPosition, SizeF markerSize, LabelAlignmentTypes labelAlignment) { return(AdjustSmartLabelPosition(common, graph, area, smartLabelsStyle, labelPosition, labelSize, ref format, markerPosition, markerSize, labelAlignment, checkCalloutLineOverlapping: false)); }
internal virtual bool IsSmartLabelCollide(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelsStyle smartLabelsStyle, PointF position, SizeF size, PointF markerPosition, StringFormat format, LabelAlignmentTypes labelAlignment, bool checkCalloutLineOverlapping) { bool flag = false; RectangleF labelPosition = GetLabelPosition(graph, position, size, format, adjustForDrawing: false); if (labelPosition.X < 0f || labelPosition.Y < 0f || labelPosition.Bottom > 100f || labelPosition.Right > 100f) { flag = true; } if (!flag && area != null) { if (area.chartAreaIsCurcular) { using (GraphicsPath graphicsPath = new GraphicsPath()) { graphicsPath.AddEllipse(area.PlotAreaPosition.ToRectangleF()); if (smartLabelsStyle.AllowOutsidePlotArea == LabelOutsidePlotAreaStyle.Partial) { PointF point = new PointF(labelPosition.X + labelPosition.Width / 2f, labelPosition.Y + labelPosition.Height / 2f); if (!graphicsPath.IsVisible(point)) { flag = true; } } else if (smartLabelsStyle.AllowOutsidePlotArea == LabelOutsidePlotAreaStyle.No && (!graphicsPath.IsVisible(labelPosition.Location) || !graphicsPath.IsVisible(new PointF(labelPosition.Right, labelPosition.Y)) || !graphicsPath.IsVisible(new PointF(labelPosition.Right, labelPosition.Bottom)) || !graphicsPath.IsVisible(new PointF(labelPosition.X, labelPosition.Bottom)))) { flag = true; } } } else if (smartLabelsStyle.AllowOutsidePlotArea == LabelOutsidePlotAreaStyle.Partial) { PointF pt = new PointF(labelPosition.X + labelPosition.Width / 2f, labelPosition.Y + labelPosition.Height / 2f); if (!area.PlotAreaPosition.ToRectangleF().Contains(pt)) { flag = true; } } else if (smartLabelsStyle.AllowOutsidePlotArea == LabelOutsidePlotAreaStyle.No && !area.PlotAreaPosition.ToRectangleF().Contains(labelPosition)) { flag = true; } } bool flag2 = (labelAlignment == LabelAlignmentTypes.Center && !smartLabelsStyle.MarkerOverlapping) ? true : false; if (checkAllCollisions) { flag2 = false; } if (!flag && smartLabelsPositions != null) { int num = -1; { foreach (RectangleF smartLabelsPosition in smartLabelsPositions) { num++; bool flag3 = smartLabelsPosition.IntersectsWith(labelPosition); if (!flag3 && checkCalloutLineOverlapping && num >= markersCount && LineIntersectRectangle(point2: new PointF(labelPosition.X + labelPosition.Width / 2f, labelPosition.Y + labelPosition.Height / 2f), rect: smartLabelsPosition, point1: markerPosition)) { flag3 = true; } if (flag3) { if (!flag2) { return(true); } flag2 = false; } } return(flag); } } return(flag); }
internal virtual void DrawCallout(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelsStyle smartLabelsStyle, PointF labelPosition, SizeF labelSize, StringFormat format, PointF markerPosition, SizeF markerSize, LabelAlignmentTypes labelAlignment) { RectangleF absoluteRectangle = graph.GetAbsoluteRectangle(GetLabelPosition(graph, labelPosition, labelSize, format, adjustForDrawing: true)); Pen pen = new Pen(smartLabelsStyle.CalloutLineColor, smartLabelsStyle.CalloutLineWidth); pen.DashStyle = graph.GetPenStyle(smartLabelsStyle.CalloutLineStyle); if (smartLabelsStyle.CalloutStyle == LabelCalloutStyle.Box) { if (smartLabelsStyle.CalloutBackColor != Color.Transparent) { Brush brush = new SolidBrush(smartLabelsStyle.CalloutBackColor); graph.FillRectangle(brush, absoluteRectangle); } graph.DrawRectangle(pen, absoluteRectangle.X, absoluteRectangle.Y, absoluteRectangle.Width, absoluteRectangle.Height); } else if (smartLabelsStyle.CalloutStyle == LabelCalloutStyle.Underlined) { switch (labelAlignment) { case LabelAlignmentTypes.Right: graph.DrawLine(pen, absoluteRectangle.X, absoluteRectangle.Top, absoluteRectangle.X, absoluteRectangle.Bottom); break; case LabelAlignmentTypes.Left: graph.DrawLine(pen, absoluteRectangle.Right, absoluteRectangle.Top, absoluteRectangle.Right, absoluteRectangle.Bottom); break; case LabelAlignmentTypes.Bottom: graph.DrawLine(pen, absoluteRectangle.X, absoluteRectangle.Top, absoluteRectangle.Right, absoluteRectangle.Top); break; default: graph.DrawLine(pen, absoluteRectangle.X, absoluteRectangle.Bottom, absoluteRectangle.Right, absoluteRectangle.Bottom); break; } } PointF absolutePoint = graph.GetAbsolutePoint(labelPosition); switch (labelAlignment) { case LabelAlignmentTypes.Top: absolutePoint.Y = absoluteRectangle.Bottom; break; case LabelAlignmentTypes.Bottom: absolutePoint.Y = absoluteRectangle.Top; break; } if (smartLabelsStyle.CalloutStyle == LabelCalloutStyle.Underlined && (labelAlignment == LabelAlignmentTypes.TopLeft || labelAlignment == LabelAlignmentTypes.TopRight || labelAlignment == LabelAlignmentTypes.BottomLeft || labelAlignment == LabelAlignmentTypes.BottomRight)) { absolutePoint.Y = absoluteRectangle.Bottom; } if (smartLabelsStyle.CalloutLineAnchorCap == LineAnchorCap.Arrow) { pen.StartCap = LineCap.Custom; pen.CustomStartCap = new AdjustableArrowCap(pen.Width + 2f, pen.Width + 3f, isFilled: true); } else if (smartLabelsStyle.CalloutLineAnchorCap == LineAnchorCap.Diamond) { pen.StartCap = LineCap.DiamondAnchor; } else if (smartLabelsStyle.CalloutLineAnchorCap == LineAnchorCap.Round) { pen.StartCap = LineCap.RoundAnchor; } else if (smartLabelsStyle.CalloutLineAnchorCap == LineAnchorCap.Square) { pen.StartCap = LineCap.SquareAnchor; } PointF absolutePoint2 = graph.GetAbsolutePoint(markerPosition); graph.DrawLine(pen, absolutePoint2.X, absolutePoint2.Y, absolutePoint.X, absolutePoint.Y); }
public PointF AdjustSmartLabelPosition(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelsStyle smartLabelsStyle, PointF labelPosition, SizeF labelSize, ref StringFormat format, PointF markerPosition, SizeF markerSize, LabelAlignmentTypes labelAlignment) { return(this.AdjustSmartLabelPosition(common, graph, area, smartLabelsStyle, labelPosition, labelSize, ref format, markerPosition, markerSize, labelAlignment, false)); }
private static float GetLabelXPosition(RectangleF treeMapNodeRelativeRect, float labelRelativeWidth, LabelAlignmentTypes labelAlignment) { float result = 0f; switch (labelAlignment) { case LabelAlignmentTypes.Top: case LabelAlignmentTypes.Bottom: case LabelAlignmentTypes.Center: result = treeMapNodeRelativeRect.X + (treeMapNodeRelativeRect.Width - labelRelativeWidth) / 2f; break; case LabelAlignmentTypes.Left: case LabelAlignmentTypes.TopLeft: case LabelAlignmentTypes.BottomLeft: result = treeMapNodeRelativeRect.X; break; case LabelAlignmentTypes.Right: case LabelAlignmentTypes.TopRight: case LabelAlignmentTypes.BottomRight: result = treeMapNodeRelativeRect.X + treeMapNodeRelativeRect.Width - labelRelativeWidth; break; } return(result); }
private void DrawLabels(ChartArea area, ChartGraphics graph, CommonElements common, PointF markerPosition, int markerSize, DataPoint point, Series ser, int pointIndex) { string label = point.Label; bool showLabelAsValue = point.ShowLabelAsValue; if ((point.Empty || (!ser.ShowLabelAsValue && !showLabelAsValue && label.Length <= 0)) && !showLabelAsValue && label.Length <= 0) { return; } StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Near; stringFormat.LineAlignment = StringAlignment.Center; string text; if (label.Length == 0) { text = ValueConverter.FormatValue(ser.chart, point, point.YValues[(this.labelYValueIndex == -1) ? this.yValueIndex : this.labelYValueIndex], point.LabelFormat, ser.YValueType, ChartElementType.DataPoint); } else { text = point.ReplaceKeywords(label); if (ser.chart != null && ser.chart.LocalizeTextHandler != null) { text = ser.chart.LocalizeTextHandler(point, text, point.ElementId, ChartElementType.DataPoint); } } SizeF relativeSize = graph.GetRelativeSize(new SizeF((float)markerSize, (float)markerSize)); SizeF relativeSize2 = graph.GetRelativeSize(graph.MeasureString(text, point.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic))); SizeF relativeSize3 = graph.GetRelativeSize(graph.MeasureString("W", point.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic))); SizeF size = new SizeF(relativeSize2.Width, relativeSize2.Height); float num = size.Width / (float)text.Length; size.Height += (float)(relativeSize3.Height / 2.0); size.Width += num; string text2 = ((DataPointAttributes)point)["LabelStyle"]; if (text2 == null || text2.Length == 0) { text2 = ((DataPointAttributes)ser)["LabelStyle"]; } this.autoLabelPosition = true; if (text2 != null && text2.Length > 0) { this.autoLabelPosition = false; if (string.Compare(text2, "Auto", StringComparison.OrdinalIgnoreCase) == 0) { this.autoLabelPosition = true; goto IL_0302; } if (string.Compare(text2, "Center", StringComparison.OrdinalIgnoreCase) == 0) { this.labelPosition = LabelAlignmentTypes.Center; goto IL_0302; } if (string.Compare(text2, "Bottom", StringComparison.OrdinalIgnoreCase) == 0) { this.labelPosition = LabelAlignmentTypes.Bottom; goto IL_0302; } if (string.Compare(text2, "TopLeft", StringComparison.OrdinalIgnoreCase) == 0) { this.labelPosition = LabelAlignmentTypes.TopLeft; goto IL_0302; } if (string.Compare(text2, "TopRight", StringComparison.OrdinalIgnoreCase) == 0) { this.labelPosition = LabelAlignmentTypes.TopRight; goto IL_0302; } if (string.Compare(text2, "BottomLeft", StringComparison.OrdinalIgnoreCase) == 0) { this.labelPosition = LabelAlignmentTypes.BottomLeft; goto IL_0302; } if (string.Compare(text2, "BottomRight", StringComparison.OrdinalIgnoreCase) == 0) { this.labelPosition = LabelAlignmentTypes.BottomRight; goto IL_0302; } if (string.Compare(text2, "Left", StringComparison.OrdinalIgnoreCase) == 0) { this.labelPosition = LabelAlignmentTypes.Left; goto IL_0302; } if (string.Compare(text2, "Right", StringComparison.OrdinalIgnoreCase) == 0) { this.labelPosition = LabelAlignmentTypes.Right; goto IL_0302; } if (string.Compare(text2, "Top", StringComparison.OrdinalIgnoreCase) == 0) { this.labelPosition = LabelAlignmentTypes.Top; goto IL_0302; } throw new ArgumentException(SR.ExceptionCustomAttributeValueInvalid(text2, "LabelStyle")); } goto IL_0302; IL_0302: if (this.autoLabelPosition) { this.labelPosition = this.GetAutoLabelPosition(ser, pointIndex); } PointF position = new PointF(markerPosition.X, markerPosition.Y); switch (this.labelPosition) { case LabelAlignmentTypes.Center: stringFormat.Alignment = StringAlignment.Center; break; case LabelAlignmentTypes.Bottom: stringFormat.Alignment = StringAlignment.Center; position.Y += (float)(relativeSize.Height / 1.75); position.Y += (float)(size.Height / 2.0); break; case LabelAlignmentTypes.Top: stringFormat.Alignment = StringAlignment.Center; position.Y -= (float)(relativeSize.Height / 1.75); position.Y -= (float)(size.Height / 2.0); break; case LabelAlignmentTypes.Left: stringFormat.Alignment = StringAlignment.Far; position.X -= (float)(relativeSize.Height / 1.75 + num / 2.0); break; case LabelAlignmentTypes.TopLeft: stringFormat.Alignment = StringAlignment.Far; position.X -= (float)(relativeSize.Height / 1.75 + num / 2.0); position.Y -= (float)(relativeSize.Height / 1.75); position.Y -= (float)(size.Height / 2.0); break; case LabelAlignmentTypes.BottomLeft: stringFormat.Alignment = StringAlignment.Far; position.X -= (float)(relativeSize.Height / 1.75 + num / 2.0); position.Y += (float)(relativeSize.Height / 1.75); position.Y += (float)(size.Height / 2.0); break; case LabelAlignmentTypes.Right: position.X += (float)(relativeSize.Height / 1.75 + num / 2.0); break; case LabelAlignmentTypes.TopRight: position.X += (float)(relativeSize.Height / 1.75 + num / 2.0); position.Y -= (float)(relativeSize.Height / 1.75); position.Y -= (float)(size.Height / 2.0); break; case LabelAlignmentTypes.BottomRight: position.X += (float)(relativeSize.Height / 1.75 + num / 2.0); position.Y += (float)(relativeSize.Height / 1.75); position.Y += (float)(size.Height / 2.0); break; } int num2 = point.FontAngle; if (text.Trim().Length != 0) { if (ser.SmartLabels.Enabled) { position = area.smartLabels.AdjustSmartLabelPosition(common, graph, area, ser.SmartLabels, position, relativeSize2, ref stringFormat, markerPosition, relativeSize, this.labelPosition); num2 = 0; } if (num2 == 90 || num2 == -90) { switch (this.labelPosition) { case LabelAlignmentTypes.Top: stringFormat.Alignment = StringAlignment.Near; position.Y += (float)(size.Height / 2.0); break; case LabelAlignmentTypes.Bottom: stringFormat.Alignment = StringAlignment.Far; position.Y -= (float)(size.Height / 2.0); break; case LabelAlignmentTypes.Right: stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Near; break; case LabelAlignmentTypes.Left: stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; break; case LabelAlignmentTypes.TopLeft: stringFormat.Alignment = StringAlignment.Near; break; case LabelAlignmentTypes.BottomRight: stringFormat.Alignment = StringAlignment.Far; break; } } if (!position.IsEmpty) { RectangleF empty = RectangleF.Empty; size.Height -= (float)(relativeSize2.Height / 2.0); size.Height += (float)(relativeSize2.Height / 8.0); empty = PointChart.GetLabelPosition(graph, position, size, stringFormat, true); switch (this.labelPosition) { case LabelAlignmentTypes.Left: empty.X += (float)(num / 2.0); break; case LabelAlignmentTypes.TopLeft: empty.X += (float)(num / 2.0); break; case LabelAlignmentTypes.BottomLeft: empty.X += (float)(num / 2.0); break; case LabelAlignmentTypes.Right: empty.X -= (float)(num / 2.0); break; case LabelAlignmentTypes.TopRight: empty.X -= (float)(num / 2.0); break; case LabelAlignmentTypes.BottomRight: empty.X -= (float)(num / 2.0); break; } graph.DrawPointLabelStringRel(common, text, point.Font, new SolidBrush(point.FontColor), position, stringFormat, num2, empty, point.LabelBackColor, point.LabelBorderColor, point.LabelBorderWidth, point.LabelBorderStyle, ser, point, pointIndex); } } }
internal void DrawLabels(ChartArea area, ChartGraphics graph, CommonElements common, PointF markerPosition, int markerSize, DataPoint point, Series ser, int pointIndex) { string label = point.Label; bool showLabelAsValue = point.ShowLabelAsValue; if ((point.Empty || (!(ser.ShowLabelAsValue || showLabelAsValue) && label.Length <= 0)) && !showLabelAsValue && label.Length <= 0) { return; } StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Near; format.LineAlignment = StringAlignment.Center; string text; if (label.Length == 0) { text = ValueConverter.FormatValue(ser.chart, point, point.YValues[0], point.LabelFormat, ser.YValueType, ChartElementType.DataPoint); } else { text = point.ReplaceKeywords(label); if (ser.chart != null && ser.chart.LocalizeTextHandler != null) { text = ser.chart.LocalizeTextHandler(point, text, point.ElementId, ChartElementType.DataPoint); } } SizeF size = new SizeF(markerSize, markerSize); SizeF size2 = graph.MeasureString(text, point.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic)); SizeF sizeF = new SizeF(size2.Width, size2.Height); sizeF.Height += sizeF.Height / 2f; sizeF.Width += sizeF.Width / (float)text.Length; autoLabelPosition = true; string text2 = point["LabelStyle"]; if (text2 == null || text2.Length == 0) { text2 = ser["LabelStyle"]; } if (text2 != null && text2.Length > 0) { autoLabelPosition = false; if (string.Compare(text2, "Auto", StringComparison.OrdinalIgnoreCase) == 0) { autoLabelPosition = true; } else if (string.Compare(text2, "Center", StringComparison.OrdinalIgnoreCase) == 0) { labelPosition = LabelAlignmentTypes.Center; } else if (string.Compare(text2, "Bottom", StringComparison.OrdinalIgnoreCase) == 0) { labelPosition = LabelAlignmentTypes.Bottom; } else if (string.Compare(text2, "TopLeft", StringComparison.OrdinalIgnoreCase) == 0) { labelPosition = LabelAlignmentTypes.TopLeft; } else if (string.Compare(text2, "TopRight", StringComparison.OrdinalIgnoreCase) == 0) { labelPosition = LabelAlignmentTypes.TopRight; } else if (string.Compare(text2, "BottomLeft", StringComparison.OrdinalIgnoreCase) == 0) { labelPosition = LabelAlignmentTypes.BottomLeft; } else if (string.Compare(text2, "BottomRight", StringComparison.OrdinalIgnoreCase) == 0) { labelPosition = LabelAlignmentTypes.BottomRight; } else if (string.Compare(text2, "Left", StringComparison.OrdinalIgnoreCase) == 0) { labelPosition = LabelAlignmentTypes.Left; } else if (string.Compare(text2, "Right", StringComparison.OrdinalIgnoreCase) == 0) { labelPosition = LabelAlignmentTypes.Right; } else { if (string.Compare(text2, "Top", StringComparison.OrdinalIgnoreCase) != 0) { throw new ArgumentException(SR.ExceptionCustomAttributeValueInvalid(text2, "LabelStyle")); } labelPosition = LabelAlignmentTypes.Top; } } if (autoLabelPosition) { labelPosition = GetAutoLabelPosition(area, ser, pointIndex); } PointF pointF = new PointF(markerPosition.X, markerPosition.Y); switch (labelPosition) { case LabelAlignmentTypes.Center: format.Alignment = StringAlignment.Center; break; case LabelAlignmentTypes.Bottom: format.Alignment = StringAlignment.Center; pointF.Y += size.Height / 1.75f; pointF.Y += sizeF.Height / 2f; break; case LabelAlignmentTypes.Top: format.Alignment = StringAlignment.Center; pointF.Y -= size.Height / 1.75f; pointF.Y -= sizeF.Height / 2f; break; case LabelAlignmentTypes.Left: format.Alignment = StringAlignment.Far; pointF.X -= size.Height / 1.75f; break; case LabelAlignmentTypes.TopLeft: format.Alignment = StringAlignment.Far; pointF.X -= size.Height / 1.75f; pointF.Y -= size.Height / 1.75f; pointF.Y -= sizeF.Height / 2f; break; case LabelAlignmentTypes.BottomLeft: format.Alignment = StringAlignment.Far; pointF.X -= size.Height / 1.75f; pointF.Y += size.Height / 1.75f; pointF.Y += sizeF.Height / 2f; break; case LabelAlignmentTypes.Right: pointF.X += size.Height / 1.75f; break; case LabelAlignmentTypes.TopRight: pointF.X += size.Height / 1.75f; pointF.Y -= size.Height / 1.75f; pointF.Y -= sizeF.Height / 2f; break; case LabelAlignmentTypes.BottomRight: pointF.X += size.Height / 1.75f; pointF.Y += size.Height / 1.75f; pointF.Y += sizeF.Height / 2f; break; } int angle = point.FontAngle; if (text.Trim().Length == 0) { return; } if (ser.SmartLabels.Enabled) { pointF = graph.GetRelativePoint(pointF); markerPosition = graph.GetRelativePoint(markerPosition); size2 = graph.GetRelativeSize(size2); size = graph.GetRelativeSize(size); pointF = area.smartLabels.AdjustSmartLabelPosition(common, graph, area, ser.SmartLabels, pointF, size2, ref format, markerPosition, size, labelPosition); if (!pointF.IsEmpty) { pointF = graph.GetAbsolutePoint(pointF); } size2 = graph.GetAbsoluteSize(size2); angle = 0; } if (!pointF.IsEmpty) { pointF = graph.GetRelativePoint(pointF); RectangleF empty = RectangleF.Empty; sizeF = graph.GetRelativeSize(size2); sizeF.Height += sizeF.Height / 8f; empty = PointChart.GetLabelPosition(graph, pointF, sizeF, format, adjustForDrawing: true); graph.DrawPointLabelStringRel(common, text, point.Font, new SolidBrush(point.FontColor), pointF, format, angle, empty, point.LabelBackColor, point.LabelBorderColor, point.LabelBorderWidth, point.LabelBorderStyle, ser, point, pointIndex); } }
internal PointF AdjustSmartLabelPosition(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelsStyle smartLabelsStyle, PointF labelPosition, SizeF labelSize, ref StringFormat format, PointF markerPosition, SizeF markerSize, LabelAlignmentTypes labelAlignment, bool checkCalloutLineOverlapping) { if (smartLabelsStyle.Enabled) { bool num = smartLabelsPositions.Count == 0; AddMarkersPosition(common, area); if (num) { markersCount = smartLabelsPositions.Count; } if (IsSmartLabelCollide(common, graph, area, smartLabelsStyle, labelPosition, labelSize, markerPosition, format, labelAlignment, checkCalloutLineOverlapping) && (FindNewPosition(common, graph, area, smartLabelsStyle, ref labelPosition, labelSize, ref format, markerPosition, ref markerSize, ref labelAlignment, checkCalloutLineOverlapping) || labelAlignment == LabelAlignmentTypes.BottomLeft || labelAlignment == LabelAlignmentTypes.BottomRight || labelAlignment == LabelAlignmentTypes.TopLeft || labelAlignment == LabelAlignmentTypes.TopRight) && !labelPosition.IsEmpty) { DrawCallout(common, graph, area, smartLabelsStyle, labelPosition, labelSize, format, markerPosition, markerSize, labelAlignment); } AddSmartLabelPosition(graph, area, labelPosition, labelSize, format); } return(labelPosition); }
private PointF CalculatePosition(LabelAlignmentTypes labelAlignment, PointF markerPosition, SizeF sizeMarker, SizeF sizeFont, ref StringFormat format) { format.Alignment = StringAlignment.Near; format.LineAlignment = StringAlignment.Center; PointF result = new PointF(markerPosition.X, markerPosition.Y); switch (labelAlignment) { case LabelAlignmentTypes.Center: format.Alignment = StringAlignment.Center; break; case LabelAlignmentTypes.Bottom: format.Alignment = StringAlignment.Center; result.Y += sizeMarker.Height / 1.75f; result.Y += sizeFont.Height / 2f; break; case LabelAlignmentTypes.Top: format.Alignment = StringAlignment.Center; result.Y -= sizeMarker.Height / 1.75f; result.Y -= sizeFont.Height / 2f; break; case LabelAlignmentTypes.Left: format.Alignment = StringAlignment.Far; result.X -= sizeMarker.Height / 1.75f; break; case LabelAlignmentTypes.TopLeft: format.Alignment = StringAlignment.Far; result.X -= sizeMarker.Height / 1.75f; result.Y -= sizeMarker.Height / 1.75f; result.Y -= sizeFont.Height / 2f; break; case LabelAlignmentTypes.BottomLeft: format.Alignment = StringAlignment.Far; result.X -= sizeMarker.Height / 1.75f; result.Y += sizeMarker.Height / 1.75f; result.Y += sizeFont.Height / 2f; break; case LabelAlignmentTypes.Right: result.X += sizeMarker.Height / 1.75f; break; case LabelAlignmentTypes.TopRight: result.X += sizeMarker.Height / 1.75f; result.Y -= sizeMarker.Height / 1.75f; result.Y -= sizeFont.Height / 2f; break; case LabelAlignmentTypes.BottomRight: result.X += sizeMarker.Height / 1.75f; result.Y += sizeMarker.Height / 1.75f; result.Y += sizeFont.Height / 2f; break; } return(result); }
internal override bool IsSmartLabelCollide(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelsStyle smartLabelsStyle, PointF position, SizeF size, PointF markerPosition, StringFormat format, LabelAlignmentTypes labelAlignment, bool checkCalloutLineOverlapping) { bool result = false; if (common.Chart != null) { foreach (ChartArea chartArea in common.Chart.ChartAreas) { if (area.Visible) { chartArea.smartLabels.checkAllCollisions = true; if (chartArea.smartLabels.IsSmartLabelCollide(common, graph, area, smartLabelsStyle, position, size, markerPosition, format, labelAlignment, checkCalloutLineOverlapping)) { chartArea.smartLabels.checkAllCollisions = false; return(true); } chartArea.smartLabels.checkAllCollisions = false; } } } RectangleF labelPosition = GetLabelPosition(graph, position, size, format, adjustForDrawing: false); bool flag = (labelAlignment == LabelAlignmentTypes.Center && !smartLabelsStyle.MarkerOverlapping) ? true : false; if (checkAllCollisions) { flag = false; } foreach (RectangleF smartLabelsPosition in smartLabelsPositions) { if (smartLabelsPosition.IntersectsWith(labelPosition)) { if (!flag) { return(true); } flag = false; } } return(result); }
public void DrawLabels(CommonElements common, ChartGraphics graph, ChartArea area, DataPoint point, int pointIndex, Series series, RectangleF rectangle) { StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; Region clip = graph.Clip; graph.Clip = new Region(); if (point.ShowLabelAsValue || point.Label.Length > 0) { double value = GetYValue(common, area, series, point, pointIndex, 0); if (hundredPercentStacked && point.LabelFormat.Length == 0) { value = Math.Round(value, 2); } string text; if (point.Label.Length == 0) { text = ValueConverter.FormatValue(series.chart, point, value, point.LabelFormat, series.YValueType, ChartElementType.DataPoint); } else { text = point.ReplaceKeywords(point.Label); if (series.chart != null && series.chart.LocalizeTextHandler != null) { text = series.chart.LocalizeTextHandler(point, text, point.ElementId, ChartElementType.DataPoint); } } PointF pointF = PointF.Empty; pointF.X = rectangle.X + rectangle.Width / 2f; pointF.Y = rectangle.Y + rectangle.Height / 2f; int angle = point.FontAngle; if (text.Trim().Length != 0) { SizeF relativeSize = graph.GetRelativeSize(graph.MeasureString(text, point.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic))); BarValueLabelDrawingStyle barValueLabelDrawingStyle = BarValueLabelDrawingStyle.Center; string text2 = ""; if (point.IsAttributeSet("BarLabelStyle")) { text2 = point["BarLabelStyle"]; } else if (series.IsAttributeSet("BarLabelStyle")) { text2 = series["BarLabelStyle"]; } if (text2 != null && text2.Length > 0) { if (string.Compare(text2, "Left", StringComparison.OrdinalIgnoreCase) == 0) { barValueLabelDrawingStyle = BarValueLabelDrawingStyle.Left; } else if (string.Compare(text2, "Right", StringComparison.OrdinalIgnoreCase) == 0) { barValueLabelDrawingStyle = BarValueLabelDrawingStyle.Right; } else if (string.Compare(text2, "Center", StringComparison.OrdinalIgnoreCase) == 0) { barValueLabelDrawingStyle = BarValueLabelDrawingStyle.Center; } else if (string.Compare(text2, "Outside", StringComparison.OrdinalIgnoreCase) == 0) { barValueLabelDrawingStyle = BarValueLabelDrawingStyle.Outside; } } switch (barValueLabelDrawingStyle) { case BarValueLabelDrawingStyle.Left: pointF.X = rectangle.X + relativeSize.Width / 2f; break; case BarValueLabelDrawingStyle.Right: pointF.X = rectangle.Right - relativeSize.Width / 2f; break; case BarValueLabelDrawingStyle.Outside: pointF.X = rectangle.Right + relativeSize.Width / 2f; break; } if (series.SmartLabels.Enabled) { bool markerOverlapping = series.SmartLabels.MarkerOverlapping; LabelAlignmentTypes movingDirection = series.SmartLabels.MovingDirection; series.SmartLabels.MarkerOverlapping = true; if (series.SmartLabels.MovingDirection == (LabelAlignmentTypes.Top | LabelAlignmentTypes.Bottom | LabelAlignmentTypes.Right | LabelAlignmentTypes.Left | LabelAlignmentTypes.TopLeft | LabelAlignmentTypes.TopRight | LabelAlignmentTypes.BottomLeft | LabelAlignmentTypes.BottomRight)) { series.SmartLabels.MovingDirection = (LabelAlignmentTypes.Right | LabelAlignmentTypes.Left); } pointF = area.smartLabels.AdjustSmartLabelPosition(common, graph, area, series.SmartLabels, pointF, relativeSize, ref format, pointF, new SizeF(0f, 0f), LabelAlignmentTypes.Center); series.SmartLabels.MarkerOverlapping = markerOverlapping; series.SmartLabels.MovingDirection = movingDirection; angle = 0; } if (!pointF.IsEmpty) { RectangleF empty = RectangleF.Empty; SizeF size = new SizeF(relativeSize.Width, relativeSize.Height); size.Height += relativeSize.Height / 8f; size.Width += size.Width / (float)text.Length; empty = new RectangleF(pointF.X - size.Width / 2f, pointF.Y - size.Height / 2f - relativeSize.Height / 10f, size.Width, size.Height); empty = area.smartLabels.GetLabelPosition(graph, pointF, size, format, adjustForDrawing: true); graph.DrawPointLabelStringRel(common, text, point.Font, new SolidBrush(point.FontColor), pointF, format, angle, empty, point.LabelBackColor, point.LabelBorderColor, point.LabelBorderWidth, point.LabelBorderStyle, series, point, pointIndex); } } } graph.Clip = clip; }