示例#1
0
        protected override void ProcessSinglePoint3D(DataPoint3D pointEx, bool selection, ChartGraphics graph, CommonElements common, ChartArea area, RectangleF columnPosition, int pointIndex)
        {
            DataPoint dataPoint = pointEx.dataPoint;

            if (dataPoint.YValues.Length < YValuesPerPoint)
            {
                throw new InvalidOperationException(SR.ExceptionChartTypeRequiresYValues(Name, YValuesPerPoint.ToString(CultureInfo.InvariantCulture)));
            }
            StringFormat stringFormat = new StringFormat();

            stringFormat.Alignment     = StringAlignment.Center;
            stringFormat.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 yValue = GetYValue(common, area, pointEx.dataPoint.series, dataPoint, pointEx.index - 1, 0);
                    text = ValueConverter.FormatValue(pointEx.dataPoint.series.chart, dataPoint, yValue, dataPoint.LabelFormat, pointEx.dataPoint.series.YValueType, ChartElementType.DataPoint);
                }
                else
                {
                    text = dataPoint.ReplaceKeywords(dataPoint.Label);
                    if (pointEx.dataPoint.series.chart != null && pointEx.dataPoint.series.chart.LocalizeTextHandler != null)
                    {
                        text = pointEx.dataPoint.series.chart.LocalizeTextHandler(dataPoint, text, dataPoint.ElementId, ChartElementType.DataPoint);
                    }
                }
                PointF empty = PointF.Empty;
                empty.X = columnPosition.X + columnPosition.Width / 2f;
                empty.Y = columnPosition.Y + columnPosition.Height / 2f;
                Point3D[] array = new Point3D[1]
                {
                    new Point3D(empty.X, empty.Y, pointEx.zPosition + pointEx.depth)
                };
                area.matrix3D.TransformPoints(array);
                empty.X = array[0].X;
                empty.Y = array[0].Y;
                graph.StartHotRegion(dataPoint, labelRegion: true);
                SizeF      relativeSize = graph.GetRelativeSize(graph.MeasureString(text, dataPoint.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic)));
                RectangleF empty2       = RectangleF.Empty;
                SizeF      size         = new SizeF(relativeSize.Width, relativeSize.Height);
                size.Width  += size.Width / (float)text.Length;
                size.Height += relativeSize.Height / 8f;
                empty2       = PointChart.GetLabelPosition(graph, empty, size, stringFormat, adjustForDrawing: true);
                graph.DrawPointLabelStringRel(common, text, dataPoint.Font, new SolidBrush(dataPoint.FontColor), empty, stringFormat, dataPoint.FontAngle, empty2, dataPoint.LabelBackColor, dataPoint.LabelBorderColor, dataPoint.LabelBorderWidth, dataPoint.LabelBorderStyle, dataPoint.series, dataPoint, pointIndex);
                graph.EndHotRegion();
            }
            graph.Clip = clip;
        }
        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);
            }
        }
示例#3
0
        protected override void DrawLabel(ChartArea area, ChartGraphics graph, CommonElements common, RectangleF columnPosition, DataPoint point, Series series, int pointIndex)
        {
            RectangleF rectangleF = RectangleF.Intersect(columnPosition, area.PlotAreaPosition.ToRectangleF());

            if (rectangleF.Height <= 0f || rectangleF.Width <= 0f)
            {
                return;
            }
            PointF empty = PointF.Empty;

            empty.X           = rectangleF.X + rectangleF.Width / 2f;
            empty.Y           = rectangleF.Y;
            point.positionRel = new PointF(empty.X, empty.Y);
            int         markerSize  = point.MarkerSize;
            string      markerImage = point.MarkerImage;
            MarkerStyle markerStyle = point.MarkerStyle;
            SizeF       markerSize2 = base.GetMarkerSize(graph, common, area, point, markerSize, markerImage);

            if (markerStyle != 0 || markerImage.Length > 0)
            {
                graph.StartHotRegion(point);
                graph.StartAnimation();
                graph.DrawMarkerRel(empty, (markerStyle == MarkerStyle.None) ? MarkerStyle.Circle : markerStyle, (int)markerSize2.Height, (point.MarkerColor == Color.Empty) ? point.Color : point.MarkerColor, (point.MarkerBorderColor == Color.Empty) ? point.BorderColor : point.MarkerBorderColor, GetMarkerBorderSize(point), markerImage, point.MarkerImageTransparentColor, (point.series != null) ? point.series.ShadowOffset : 0, (point.series != null) ? point.series.ShadowColor : Color.Empty, new RectangleF(empty.X, empty.Y, markerSize2.Width, markerSize2.Height));
                graph.StopAnimation();
                graph.EndHotRegion();
                if (common.ProcessModeRegions)
                {
                    SizeF relativeSize = graph.GetRelativeSize(markerSize2);
                    int   insertIndex  = common.HotRegionsList.FindInsertIndex();
                    if (markerStyle == MarkerStyle.Circle)
                    {
                        float[] array = new float[3]
                        {
                            empty.X,
                            empty.Y,
                            relativeSize.Width / 2f
                        };
                        common.HotRegionsList.AddHotRegion(insertIndex, graph, array[0], array[1], array[2], point, series.Name, pointIndex - 1);
                    }
                    else
                    {
                        common.HotRegionsList.AddHotRegion(graph, new RectangleF(empty.X - relativeSize.Width / 2f, empty.Y - relativeSize.Height / 2f, relativeSize.Width, relativeSize.Height), point, series.Name, pointIndex - 1);
                    }
                }
            }
            StringFormat stringFormat = new StringFormat();

            stringFormat.Alignment     = StringAlignment.Center;
            stringFormat.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 yValue = GetYValue(common, area, series, point, pointIndex, 0);
                    text = ValueConverter.FormatValue(series.chart, point, yValue, 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 empty2 = PointF.Empty;
                empty2.X = rectangleF.X + rectangleF.Width / 2f;
                empty2.Y = rectangleF.Y + rectangleF.Height / 2f;
                graph.StartHotRegion(point, labelRegion: true);
                graph.StartAnimation();
                SizeF      relativeSize2 = graph.GetRelativeSize(graph.MeasureString(text, point.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic)));
                RectangleF empty3        = RectangleF.Empty;
                SizeF      size          = new SizeF(relativeSize2.Width, relativeSize2.Height);
                size.Width  += size.Width / (float)text.Length;
                size.Height += relativeSize2.Height / 8f;
                empty3       = PointChart.GetLabelPosition(graph, empty2, size, stringFormat, adjustForDrawing: true);
                graph.DrawPointLabelStringRel(common, text, point.Font, new SolidBrush(point.FontColor), empty2, stringFormat, point.FontAngle, empty3, point.LabelBackColor, point.LabelBorderColor, point.LabelBorderWidth, point.LabelBorderStyle, series, point, pointIndex - 1);
                graph.StopAnimation();
                graph.EndHotRegion();
            }
            graph.Clip = clip;
        }
        protected virtual void DrawLabel(CommonElements common, ChartArea area, ChartGraphics graph, Series ser, DataPoint point, PointF position, int pointIndex)
        {
            if (!ser.ShowLabelAsValue && !point.ShowLabelAsValue && point.Label.Length <= 0)
            {
                return;
            }
            StringFormat format = new StringFormat();

            format.Alignment     = StringAlignment.Near;
            format.LineAlignment = StringAlignment.Center;
            if (point.FontAngle == 0)
            {
                format.Alignment     = StringAlignment.Center;
                format.LineAlignment = StringAlignment.Far;
            }
            string text;

            if (point.Label.Length == 0)
            {
                int    num  = 3;
                string strA = "";
                if (point.IsAttributeSet("LabelValueType"))
                {
                    strA = point["LabelValueType"];
                }
                else if (ser.IsAttributeSet("LabelValueType"))
                {
                    strA = ser["LabelValueType"];
                }
                if (string.Compare(strA, "High", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    num = 0;
                }
                else if (string.Compare(strA, "Low", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    num = 1;
                }
                else if (string.Compare(strA, "Open", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    num = 2;
                }
                text = ValueConverter.FormatValue(ser.chart, point, point.YValues[num], point.LabelFormat, ser.YValueType, ChartElementType.DataPoint);
            }
            else
            {
                text = point.ReplaceKeywords(point.Label);
                if (ser.chart != null && ser.chart.LocalizeTextHandler != null)
                {
                    text = ser.chart.LocalizeTextHandler(point, text, point.ElementId, ChartElementType.DataPoint);
                }
            }
            int angle = point.FontAngle;

            if (text.Trim().Length == 0)
            {
                return;
            }
            SizeF labelSize = SizeF.Empty;

            if (ser.SmartLabels.Enabled)
            {
                SizeF size = SizeF.Empty;
                size.Width  = point.MarkerSize;
                size.Height = point.MarkerSize;
                if (point.MarkerImage.Length > 0)
                {
                    common.ImageLoader.GetAdjustedImageSize(point.MarkerImage, graph.Graphics, ref size);
                }
                size      = graph.GetRelativeSize(size);
                labelSize = graph.GetRelativeSize(graph.MeasureString(text, point.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic)));
                position  = area.smartLabels.AdjustSmartLabelPosition(common, graph, area, ser.SmartLabels, position, labelSize, ref format, position, size, LabelAlignmentTypes.Top);
                angle     = 0;
            }
            if (position.IsEmpty)
            {
                return;
            }
            RectangleF backPosition = RectangleF.Empty;

            if (!point.LabelBackColor.IsEmpty || point.LabelBorderWidth > 0 || !point.LabelBorderColor.IsEmpty)
            {
                if (labelSize.IsEmpty)
                {
                    labelSize = graph.GetRelativeSize(graph.MeasureString(text, point.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic)));
                }
                position.Y -= labelSize.Height / 8f;
                SizeF size2 = new SizeF(labelSize.Width, labelSize.Height);
                size2.Height += labelSize.Height / 8f;
                size2.Width  += size2.Width / (float)text.Length;
                backPosition  = PointChart.GetLabelPosition(graph, position, size2, format, adjustForDrawing: true);
            }
            graph.DrawPointLabelStringRel(common, text, point.Font, new SolidBrush(point.FontColor), position, format, angle, backPosition, point.LabelBackColor, point.LabelBorderColor, point.LabelBorderWidth, point.LabelBorderStyle, ser, point, pointIndex - 1);
        }
示例#5
0
        protected virtual void DrawLabel(CommonElements common, ChartArea area, ChartGraphics graph, Series ser, DataPoint point, PointF position, int pointIndex)
        {
            if (!ser.ShowLabelAsValue && !point.ShowLabelAsValue && point.Label.Length <= 0)
            {
                return;
            }
            StringFormat format = new StringFormat();

            format.Alignment     = StringAlignment.Near;
            format.LineAlignment = StringAlignment.Center;
            if (point.FontAngle == 0)
            {
                format.Alignment     = StringAlignment.Center;
                format.LineAlignment = StringAlignment.Far;
            }
            string text;

            if (point.Label.Length == 0)
            {
                text = ValueConverter.FormatValue(ser.chart, point, point.YValues[0], point.LabelFormat, ser.YValueType, ChartElementType.DataPoint);
            }
            else
            {
                text = point.ReplaceKeywords(point.Label);
                if (ser.chart != null && ser.chart.LocalizeTextHandler != null)
                {
                    text = ser.chart.LocalizeTextHandler(point, text, point.ElementId, ChartElementType.DataPoint);
                }
            }
            SizeF markerSize = new SizeF(0f, 0f);

            if (point.MarkerStyle != 0)
            {
                markerSize  = graph.GetRelativeSize(new SizeF(point.MarkerSize, point.MarkerSize));
                position.Y -= markerSize.Height / 2f;
            }
            int angle = point.FontAngle;

            if (text.Trim().Length == 0)
            {
                return;
            }
            SizeF labelSize = SizeF.Empty;

            if (ser.SmartLabels.Enabled)
            {
                labelSize = graph.GetRelativeSize(graph.MeasureString(text, point.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic)));
                position  = area.smartLabels.AdjustSmartLabelPosition(common, graph, area, ser.SmartLabels, position, labelSize, ref format, position, markerSize, LabelAlignmentTypes.Top);
                angle     = 0;
            }
            if (!position.IsEmpty)
            {
                if (labelSize.IsEmpty)
                {
                    labelSize = graph.GetRelativeSize(graph.MeasureString(text, point.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic)));
                }
                RectangleF empty = RectangleF.Empty;
                SizeF      size  = new SizeF(labelSize.Width, labelSize.Height);
                size.Height += labelSize.Height / 8f;
                size.Width  += size.Width / (float)text.Length;
                empty        = PointChart.GetLabelPosition(graph, position, size, format, adjustForDrawing: true);
                graph.DrawPointLabelStringRel(common, text, point.Font, new SolidBrush(point.FontColor), position, format, angle, empty, point.LabelBackColor, point.LabelBorderColor, point.LabelBorderWidth, point.LabelBorderStyle, ser, point, pointIndex - 1);
            }
        }