Ejemplo n.º 1
0
        private static void RenderNode(CommonElements common, ChartGraphics graph, CategoryNode node, RectangleF rectRelative, int level, double parentValue, ref float startAngle, float parentSweepAngle, float thresholdAngle, float incrementXRelative, float incrementYRelative, PointF centerAbsolute, float centerRadiusAbsolute, float edgeRadiusAbsolute, Series series, DataPointAttributes dataPointAttributes)
        {
            double absoluteValue = node.GetValues(series).AbsoluteValue;

            if (absoluteValue != 0.0)
            {
                CategoryNode dataPointNode = node.GetDataPointNode(series);
                DataPoint    dataPoint;
                int          dataPointIndex;
                if (dataPointNode != null)
                {
                    dataPoint      = dataPointNode.GetDataPoint(series);
                    dataPointIndex = dataPointNode.Index;
                }
                else
                {
                    dataPoint      = null;
                    dataPointIndex = -1;
                }
                DataPointAttributes dataPointAttributes2 = (dataPoint != null) ? dataPoint : dataPointAttributes;
                float num        = (float)(absoluteValue / parentValue * (double)parentSweepAngle);
                float sweepAngle = num - thresholdAngle;
                using (GraphicsPath sliceGraphicsPath = RenderSlice(common, graph, node, dataPoint, dataPointAttributes2, rectRelative, startAngle, sweepAngle, centerAbsolute, edgeRadiusAbsolute, level, dataPointIndex))
                {
                    RenderLabel(common, graph, node, dataPoint, dataPointAttributes2, GetLabelText(node, dataPoint, series, dataPointAttributes2), startAngle, num, centerAbsolute, centerRadiusAbsolute, dataPointIndex, sliceGraphicsPath);
                }
                if (node.Children != null)
                {
                    float startAngle2 = startAngle;
                    RenderNodes(common, graph, node.Children, RectangleF.Inflate(rectRelative, incrementXRelative, incrementYRelative), level + 1, absoluteValue, ref startAngle2, num, incrementXRelative, incrementYRelative, series, dataPointAttributes);
                }
                startAngle += num;
            }
        }
Ejemplo n.º 2
0
 public static bool IsLabelVisible(DataPointAttributes point)
 {
     if (point.IsAttributeSet("LabelsVisible"))
     {
         return(!string.Equals(point.GetAttribute("LabelsVisible"), "false", StringComparison.OrdinalIgnoreCase));
     }
     return(true);
 }
        protected override void GetTopSurfaceVisibility(ChartArea area, DataPoint3D firstPoint, DataPoint3D secondPoint, bool upSideDown, float positionZ, float depth, Matrix3D matrix, ref SurfaceNames visibleSurfaces)
        {
            base.GetTopSurfaceVisibility(area, firstPoint, secondPoint, upSideDown, positionZ, depth, matrix, ref visibleSurfaces);
            if ((visibleSurfaces & SurfaceNames.Top) == SurfaceNames.Top)
            {
                bool flag = false;
                foreach (Series item in area.Common.DataManager.Series)
                {
                    if (string.Compare(item.ChartTypeName, secondPoint.dataPoint.series.ChartTypeName, ignoreCase: true, CultureInfo.CurrentCulture) != 0)
                    {
                        continue;
                    }
                    if (flag)
                    {
                        DataPointAttributes dataPointAttributes = item.Points[secondPoint.index - 1];
                        if (item.Points[secondPoint.index - 1].Empty)
                        {
                            dataPointAttributes = item.EmptyPointStyle;
                        }
                        if (dataPointAttributes.Color.A == byte.MaxValue)
                        {
                            visibleSurfaces ^= SurfaceNames.Top;
                        }
                        break;
                    }
                    if (string.Compare(item.Name, secondPoint.dataPoint.series.Name, StringComparison.Ordinal) == 0)
                    {
                        flag = true;
                    }
                }
            }
            if ((visibleSurfaces & SurfaceNames.Bottom) == SurfaceNames.Bottom)
            {
                return;
            }
            DataPointAttributes dataPointAttributes2 = null;

            foreach (Series item2 in area.Common.DataManager.Series)
            {
                if (string.Compare(item2.ChartTypeName, secondPoint.dataPoint.series.ChartTypeName, StringComparison.OrdinalIgnoreCase) != 0)
                {
                    continue;
                }
                if (dataPointAttributes2 != null && string.Compare(item2.Name, secondPoint.dataPoint.series.Name, StringComparison.Ordinal) == 0)
                {
                    if (dataPointAttributes2.Color.A != byte.MaxValue)
                    {
                        visibleSurfaces |= SurfaceNames.Bottom;
                    }
                    break;
                }
                dataPointAttributes2 = item2.Points[secondPoint.index - 1];
                if (item2.Points[secondPoint.index - 1].Empty)
                {
                    dataPointAttributes2 = item2.EmptyPointStyle;
                }
            }
        }
Ejemplo n.º 4
0
        internal void SetAttributes(DataPointAttributes attrib, bool area3D)
        {
            borderColor            = attrib.BorderColor;
            borderWidth            = attrib.BorderWidth;
            borderStyle            = attrib.BorderStyle;
            markerStyle            = attrib.MarkerStyle;
            markerSize             = attrib.MarkerSize;
            markerImage            = attrib.MarkerImage;
            markerImageTranspColor = attrib.MarkerImageTransparentColor;
            markerColor            = attrib.MarkerColor;
            markerBorderColor      = attrib.MarkerBorderColor;
            markerBorderWidth      = attrib.MarkerBorderWidth;
            float num = 96f;

            if (common != null)
            {
                num = common.graph.Graphics.DpiX;
            }
            int num2 = (int)Math.Round(2f * num / 96f);

            if (markerBorderWidth > num2)
            {
                markerBorderWidth = num2;
            }
            if (attrib.MarkerBorderWidth <= 0)
            {
                markerBorderColor = Color.Transparent;
            }
            if (style == LegendImageStyle.Line && borderWidth <= (int)Math.Round(num / 96f))
            {
                borderWidth = num2;
            }
            if (!area3D)
            {
                backGradientType     = attrib.BackGradientType;
                backGradientEndColor = attrib.BackGradientEndColor;
                backImageTranspColor = attrib.BackImageTransparentColor;
                backImage            = attrib.BackImage;
                backImageMode        = attrib.BackImageMode;
                backImageAlign       = attrib.BackImageAlign;
                backHatchStyle       = attrib.BackHatchStyle;
            }
        }
Ejemplo n.º 5
0
        public void SetAttributes(DataPointAttributes attrib, bool area3D)
        {
            this.borderColor            = attrib.BorderColor;
            this.borderWidth            = attrib.BorderWidth;
            this.borderStyle            = attrib.BorderStyle;
            this.markerStyle            = attrib.MarkerStyle;
            this.markerSize             = attrib.MarkerSize;
            this.markerImage            = attrib.MarkerImage;
            this.markerImageTranspColor = attrib.MarkerImageTransparentColor;
            this.markerColor            = attrib.MarkerColor;
            this.markerBorderColor      = attrib.MarkerBorderColor;
            this.markerBorderWidth      = attrib.MarkerBorderWidth;
            float num = 96f;

            if (this.common != null)
            {
                num = this.common.graph.Graphics.DpiX;
            }
            int num2 = (int)Math.Round(2.0 * num / 96.0);

            if (this.markerBorderWidth > num2)
            {
                this.markerBorderWidth = num2;
            }
            if (attrib.MarkerBorderWidth <= 0)
            {
                this.markerBorderColor = Color.Transparent;
            }
            if (this.style == LegendImageStyle.Line && this.borderWidth <= (int)Math.Round(num / 96.0))
            {
                this.borderWidth = num2;
            }
            if (!area3D)
            {
                this.backGradientType     = attrib.BackGradientType;
                this.backGradientEndColor = attrib.BackGradientEndColor;
                this.backImageTranspColor = attrib.BackImageTransparentColor;
                this.backImage            = attrib.BackImage;
                this.backImageMode        = attrib.BackImageMode;
                this.backImageAlign       = attrib.BackImageAlign;
                this.backHatchStyle       = attrib.BackHatchStyle;
            }
        }
Ejemplo n.º 6
0
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (value is string && context != null && context.Instance != null)
     {
         if (context.Instance is DataPointAttributes)
         {
             ((DataPointAttributes)context.Instance).CustomAttributes = (string)value;
             return(new CustomAttributes((DataPointAttributes)context.Instance));
         }
         if (context.Instance is CustomAttributes)
         {
             return(new CustomAttributes(((CustomAttributes)context.Instance).DataPointAttributes));
         }
         if (context.Instance is IDataPointAttributesProvider)
         {
             return(new CustomAttributes(((IDataPointAttributesProvider)context.Instance).DataPointAttributes));
         }
         if (context.Instance is Array)
         {
             DataPointAttributes dataPointAttributes = null;
             foreach (object item in (Array)context.Instance)
             {
                 if (item is DataPointAttributes)
                 {
                     dataPointAttributes = (DataPointAttributes)item;
                     dataPointAttributes.CustomAttributes = (string)value;
                 }
             }
             if (dataPointAttributes != null)
             {
                 return(new CustomAttributes(dataPointAttributes));
             }
         }
     }
     return(base.ConvertFrom(context, culture, value));
 }
Ejemplo n.º 7
0
 protected virtual int GetMarkerBorderSize(DataPointAttributes point)
 {
     return(point.MarkerBorderWidth);
 }
Ejemplo n.º 8
0
 protected override int GetMarkerBorderSize(DataPointAttributes point)
 {
     return(point.BorderWidth);
 }
 public CustomAttributes(DataPointAttributes attributes)
 {
     this.DataPointAttributes = attributes;
 }
Ejemplo n.º 10
0
        public void CreateHistogram(Microsoft.Reporting.Chart.WebForms.Chart chartControl, string dataSeriesName, string histogramSeriesName, string histogramLegendText)
        {
            if (chartControl == null)
            {
                throw new ArgumentNullException("chartControl");
            }
            int index = chartControl.Series.GetIndex(dataSeriesName);

            if (index < 0)
            {
                throw new ArgumentException("Series with name'" + dataSeriesName + "' was not found.", "dataSeriesName");
            }
            Series series  = chartControl.Series[dataSeriesName];
            Series series2 = null;

            if (chartControl.Series.GetIndex(histogramSeriesName) < 0)
            {
                series2 = new Series(histogramSeriesName);
                chartControl.Series.Insert(index, series2);
                series2.ChartType  = series.ChartType;
                series2.LegendText = histogramLegendText;
                if (series.Points.Count > 0)
                {
                    series2.BorderColor = series.Points[0].BorderColor;
                    series2.BorderWidth = series.Points[0].BorderWidth;
                    series2.BorderStyle = series.Points[0].BorderStyle;
                }
                series2.Color = series.Color;
                series2.BackGradientEndColor = series.BackGradientEndColor;
                series2.BackGradientType     = series.BackGradientType;
                series2.Legend    = series.Legend;
                series2.ChartArea = series.ChartArea;
                DataPointAttributes dataPointAttributes = series;
                for (int i = 0; i < series.Points.Count; i++)
                {
                    if (!series.Points[i].Empty)
                    {
                        dataPointAttributes = series.Points[i];
                        break;
                    }
                }
                series2.LabelBackColor   = dataPointAttributes.LabelBackColor;
                series2.LabelBorderColor = dataPointAttributes.LabelBorderColor;
                series2.LabelBorderWidth = dataPointAttributes.LabelBorderWidth;
                series2.LabelBorderStyle = dataPointAttributes.LabelBorderStyle;
                series2.LabelFormat      = dataPointAttributes.LabelFormat;
                series2.ShowLabelAsValue = dataPointAttributes.ShowLabelAsValue;
                series2.Font             = dataPointAttributes.Font;
                series2.FontColor        = dataPointAttributes.FontColor;
                series2.FontAngle        = dataPointAttributes.FontAngle;
            }
            double num  = double.MaxValue;
            double num2 = double.MinValue;
            int    num3 = 0;

            foreach (DataPoint point in series.Points)
            {
                if (!point.Empty)
                {
                    if (point.YValues[0] > num2)
                    {
                        num2 = point.YValues[0];
                    }
                    if (point.YValues[0] < num)
                    {
                        num = point.YValues[0];
                    }
                    num3++;
                }
            }
            if (SegmentIntervalWidth == 0.0)
            {
                SegmentIntervalWidth = (num2 - num) / (double)SegmentIntervalNumber;
                SegmentIntervalWidth = RoundInterval(SegmentIntervalWidth);
            }
            num  = Math.Floor(num / SegmentIntervalWidth) * SegmentIntervalWidth;
            num2 = Math.Ceiling(num2 / SegmentIntervalWidth) * SegmentIntervalWidth;
            double num4 = num;

            for (num4 = num; num4 <= num2; num4 += SegmentIntervalWidth)
            {
                int num5 = 0;
                foreach (DataPoint point2 in series.Points)
                {
                    if (!point2.Empty)
                    {
                        double num6 = num4 + SegmentIntervalWidth;
                        if (point2.YValues[0] >= num4 && point2.YValues[0] < num6)
                        {
                            num5++;
                        }
                        else if (num6 >= num2 && point2.YValues[0] >= num4 && point2.YValues[0] <= num6)
                        {
                            num5++;
                        }
                    }
                }
                series2.Points.AddXY(num4 + SegmentIntervalWidth / 2.0, num5);
            }
            series2["PointWidth"] = "1";
            ChartArea chartArea = chartControl.ChartAreas[series2.ChartArea];

            chartArea.AxisY.Title   = "Frequency";
            chartArea.AxisX.Minimum = num;
            chartArea.AxisX.Maximum = num2;
            double num7 = SegmentIntervalWidth;
            bool   flag = false;

            while ((num2 - num) / num7 > 10.0)
            {
                num7 *= 2.0;
                flag  = true;
            }
            chartArea.AxisX.Interval = num7;
            if (chartArea.AxisX.LabelStyle.ShowEndLabels && flag)
            {
                chartArea.AxisX.Maximum = num + Math.Ceiling((num2 - num) / num7) * num7;
            }
            chartControl.Series.Remove(series);
            chartArea.AxisY2.Enabled = AxisEnabled.Auto;
            if (ShowPercentOnSecondaryYAxis)
            {
                chartArea.Recalculate();
                chartArea.AxisY2.Enabled           = AxisEnabled.True;
                chartArea.AxisY2.LabelStyle.Format = "P0";
                chartArea.AxisY2.MajorGrid.Enabled = false;
                chartArea.AxisY2.Title             = "Percent of Total";
                chartArea.AxisY2.Minimum           = chartArea.AxisY.Minimum / (double)num3;
                chartArea.AxisY2.Maximum           = chartArea.AxisY.Maximum / (double)num3;
                double num8 = (chartArea.AxisY2.Maximum > 0.2) ? 0.05 : 0.01;
                chartArea.AxisY2.Interval = Math.Ceiling(chartArea.AxisY2.Maximum / 5.0 / num8) * num8;
            }
        }
Ejemplo n.º 11
0
        private static GraphicsPath RenderSlice(CommonElements common, ChartGraphics graph, CategoryNode node, DataPoint dataPoint, DataPointAttributes dataPointAttributes, RectangleF rectRelative, float startAngle, float sweepAngle, PointF centerAbsolute, float radiusAbsolute, int level, int dataPointIndex)
        {
            float        doughnutRadius      = 1f / (float)(level + 1) * 100f;
            GraphicsPath controlGraphicsPath = null;

            graph.DrawPieRel(rectRelative, startAngle, sweepAngle, dataPointAttributes.Color, dataPointAttributes.BackHatchStyle, dataPointAttributes.BackImage, dataPointAttributes.BackImageMode, dataPointAttributes.BackImageTransparentColor, dataPointAttributes.BackImageAlign, dataPointAttributes.BackGradientType, dataPointAttributes.BackGradientEndColor, dataPointAttributes.BorderColor, dataPointAttributes.BorderWidth, dataPointAttributes.BorderStyle, PenAlignment.Inset, shadow: false, 0.0, doughnut: true, doughnutRadius, explodedShadow: false, PieDrawingStyle.Default, out controlGraphicsPath);
            if (dataPoint != null)
            {
                PieChart.Map(common, dataPoint, startAngle, sweepAngle, rectRelative, doughnut: true, doughnutRadius, graph, dataPointIndex);
                dataPoint.positionRel = GetSliceCenterRelative(graph, GetSliceCenterAngle(startAngle, sweepAngle), centerAbsolute, radiusAbsolute);
            }
            else
            {
                MapCategoryNode(common, node, startAngle, sweepAngle, rectRelative, doughnutRadius, graph);
            }
            return(controlGraphicsPath);
        }
Ejemplo n.º 12
0
 private static string GetCategoryNodeLabelText(CategoryNode categoryNode, Series series, DataPointAttributes dataPointAttributes)
 {
     if (dataPointAttributes.ShowLabelAsValue)
     {
         return(ValueConverter.FormatValue(series.chart, null, categoryNode.GetValues(series).Value, dataPointAttributes.LabelFormat, series.YValueType, ChartElementType.DataPoint));
     }
     return(categoryNode.Label);
 }
Ejemplo n.º 13
0
 private static string GetLabelText(CategoryNode categoryNode, DataPoint dataPoint, Series series, DataPointAttributes dataPointAttributes)
 {
     if (dataPoint != null)
     {
         if (TreeMapChart.IsLabelVisible(dataPoint))
         {
             string labelText = PieChart.GetLabelText(dataPoint);
             if (!string.IsNullOrEmpty(labelText))
             {
                 return(labelText);
             }
             return(GetCategoryNodeLabelText(categoryNode, series, dataPoint));
         }
     }
     else if (TreeMapChart.IsLabelVisible(dataPointAttributes))
     {
         return(GetCategoryNodeLabelText(categoryNode, series, dataPointAttributes));
     }
     return(string.Empty);
 }
Ejemplo n.º 14
0
        private static void RenderNodes(CommonElements common, ChartGraphics graph, CategoryNodeCollection nodes, RectangleF rectRelative, int level, double parentValue, ref float startAngle, float parentSweepAngle, float incrementXRelative, float incrementYRelative, Series series, DataPointAttributes dataPointAttributes)
        {
            if (nodes.AreAllNodesEmpty(series))
            {
                return;
            }
            nodes.SortByAbsoluteValue(series);
            RectangleF absoluteRectangle    = graph.GetAbsoluteRectangle(rectRelative);
            float      thresholdAngle       = (float)(360.0 / (Math.PI * 2.0 * (double)absoluteRectangle.Width));
            PointF     centerAbsolute       = new PointF(absoluteRectangle.X + absoluteRectangle.Width / 2f, absoluteRectangle.Y + absoluteRectangle.Height / 2f);
            float      centerRadiusAbsolute = graph.GetAbsoluteWidth(rectRelative.Width - incrementXRelative) / 2f;
            float      absoluteWidth        = graph.GetAbsoluteWidth(rectRelative.Width / 2f);

            foreach (CategoryNode node in nodes)
            {
                RenderNode(common, graph, node, rectRelative, level, parentValue, ref startAngle, parentSweepAngle, thresholdAngle, incrementXRelative, incrementYRelative, centerAbsolute, centerRadiusAbsolute, absoluteWidth, series, dataPointAttributes);
            }
        }
Ejemplo n.º 15
0
        protected virtual void ProcessChartType(bool selection, ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw)
        {
            foreach (Series item in common.DataManager.Series)
            {
                if (item.ChartArea != area.Name || !item.IsVisible())
                {
                    continue;
                }
                if (string.Compare(item.ChartTypeName, Name, ignoreCase: true, CultureInfo.CurrentCulture) != 0)
                {
                    throw new InvalidOperationException(SR.ExceptionChartTypeCanNotCombine(item.ChartTypeName, Name));
                }
                if (!selection)
                {
                    common.EventsManager.OnBackPaint(item, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition));
                }
                Axis     axis           = area.GetAxis(AxisName.Y, AxisType.Primary, item.YSubAxisName);
                double   viewMinimum    = axis.GetViewMinimum();
                double   viewMaximum    = axis.GetViewMaximum();
                PointF[] pointsPosition = GetPointsPosition(graph, area, item);
                int      num            = 0;
                if (item.ShadowOffset != 0 && !selection)
                {
                    graph.shadowDrawingMode = true;
                    foreach (DataPoint point in item.Points)
                    {
                        int num2 = num + 1;
                        if (num2 >= item.Points.Count)
                        {
                            num2 = 0;
                        }
                        DataPointAttributes dataPointAttributes = point;
                        if (item.Points[num2].Empty)
                        {
                            dataPointAttributes = item.Points[num2];
                        }
                        Color left = dataPointAttributes.Color;
                        _ = dataPointAttributes.BorderColor;
                        int               borderWidth  = dataPointAttributes.BorderWidth;
                        ChartDashStyle    borderStyle  = dataPointAttributes.BorderStyle;
                        RadarDrawingStyle drawingStyle = GetDrawingStyle(item, point);
                        if (axis.GetLogValue(point.YValues[0]) > viewMaximum || axis.GetLogValue(point.YValues[0]) < viewMinimum || axis.GetLogValue(item.Points[num2].YValues[0]) > viewMaximum || axis.GetLogValue(item.Points[num2].YValues[0]) < viewMinimum)
                        {
                            num++;
                            continue;
                        }
                        switch (drawingStyle)
                        {
                        case RadarDrawingStyle.Line:
                            _           = dataPointAttributes.Color;
                            borderWidth = ((borderWidth < 1) ? 1 : borderWidth);
                            borderStyle = ((borderStyle == ChartDashStyle.NotSet) ? ChartDashStyle.Solid : borderStyle);
                            left        = Color.Transparent;
                            break;

                        case RadarDrawingStyle.Marker:
                            left = Color.Transparent;
                            break;
                        }
                        if (num2 == 0 && !RequireClosedFigure() && drawingStyle != 0)
                        {
                            break;
                        }
                        if (left != Color.Transparent && left != Color.Empty && item.ShadowOffset != 0)
                        {
                            GraphicsPath graphicsPath = new GraphicsPath();
                            graphicsPath.AddLine(graph.GetAbsolutePoint(area.circularCenter), pointsPosition[num]);
                            graphicsPath.AddLine(pointsPosition[num], pointsPosition[num2]);
                            graphicsPath.AddLine(pointsPosition[num2], graph.GetAbsolutePoint(area.circularCenter));
                            Matrix matrix = new Matrix();
                            matrix.Translate(item.ShadowOffset, item.ShadowOffset);
                            graphicsPath.Transform(matrix);
                            graph.FillPath(new SolidBrush(item.ShadowColor), graphicsPath);
                        }
                        num++;
                    }
                    graph.shadowDrawingMode = false;
                }
                num = 0;
                foreach (DataPoint point2 in item.Points)
                {
                    point2.positionRel = graph.GetRelativePoint(pointsPosition[num]);
                    int num3 = num + 1;
                    if (num3 >= item.Points.Count)
                    {
                        num3 = 0;
                    }
                    DataPointAttributes dataPointAttributes2 = point2;
                    if (item.Points[num3].Empty)
                    {
                        dataPointAttributes2 = item.Points[num3];
                    }
                    Color             color          = dataPointAttributes2.Color;
                    Color             color2         = dataPointAttributes2.BorderColor;
                    int               num4           = dataPointAttributes2.BorderWidth;
                    ChartDashStyle    chartDashStyle = dataPointAttributes2.BorderStyle;
                    RadarDrawingStyle drawingStyle2  = GetDrawingStyle(item, point2);
                    if (axis.GetLogValue(point2.YValues[0]) > viewMaximum || axis.GetLogValue(point2.YValues[0]) < viewMinimum || axis.GetLogValue(item.Points[num3].YValues[0]) > viewMaximum || axis.GetLogValue(item.Points[num3].YValues[0]) < viewMinimum)
                    {
                        num++;
                        continue;
                    }
                    switch (drawingStyle2)
                    {
                    case RadarDrawingStyle.Line:
                        color2         = dataPointAttributes2.Color;
                        num4           = ((num4 < 1) ? 1 : num4);
                        chartDashStyle = ((chartDashStyle == ChartDashStyle.NotSet) ? ChartDashStyle.Solid : chartDashStyle);
                        color          = Color.Transparent;
                        break;

                    case RadarDrawingStyle.Marker:
                        color = Color.Transparent;
                        break;
                    }
                    GraphicsPath graphicsPath2 = new GraphicsPath();
                    if (num3 == 0 && !RequireClosedFigure() && drawingStyle2 != 0)
                    {
                        if (common.ProcessModeRegions)
                        {
                            AddSelectionPath(area, graphicsPath2, pointsPosition, num, num3, graph.GetAbsolutePoint(area.circularCenter), 0);
                            int insertIndex = common.HotRegionsList.FindInsertIndex();
                            common.HotRegionsList.AddHotRegion(insertIndex, graphicsPath2, relativePath: false, graph, point2, item.Name, num);
                        }
                        break;
                    }
                    if (color != Color.Transparent && color != Color.Empty)
                    {
                        GraphicsPath graphicsPath3 = new GraphicsPath();
                        graphicsPath3.AddLine(graph.GetAbsolutePoint(area.circularCenter), pointsPosition[num]);
                        graphicsPath3.AddLine(pointsPosition[num], pointsPosition[num3]);
                        graphicsPath3.AddLine(pointsPosition[num3], graph.GetAbsolutePoint(area.circularCenter));
                        if (common.ProcessModePaint)
                        {
                            Brush brush = graph.CreateBrush(graphicsPath3.GetBounds(), color, dataPointAttributes2.BackHatchStyle, dataPointAttributes2.BackImage, dataPointAttributes2.BackImageMode, dataPointAttributes2.BackImageTransparentColor, dataPointAttributes2.BackImageAlign, dataPointAttributes2.BackGradientType, dataPointAttributes2.BackGradientEndColor);
                            graph.StartHotRegion(point2);
                            graph.StartAnimation();
                            graph.FillPath(brush, graphicsPath3);
                            graph.StopAnimation();
                            graph.EndHotRegion();
                        }
                        if (common.ProcessModeRegions)
                        {
                            AddSelectionPath(area, graphicsPath2, pointsPosition, num, num3, graph.GetAbsolutePoint(area.circularCenter), 0);
                        }
                    }
                    if (color2 != Color.Empty && num4 > 0 && chartDashStyle != 0 && num3 < item.Points.Count)
                    {
                        if (common.ProcessModePaint)
                        {
                            graph.StartHotRegion(point2);
                            graph.StartAnimation();
                            graph.DrawLineAbs(color2, num4, chartDashStyle, pointsPosition[num], pointsPosition[num3], item.ShadowColor, (color == Color.Transparent || color == Color.Empty) ? item.ShadowOffset : 0);
                            graph.StopAnimation();
                            graph.EndHotRegion();
                        }
                        if (common.ProcessModeRegions)
                        {
                            AddSelectionPath(area, graphicsPath2, pointsPosition, num, num3, PointF.Empty, num4);
                        }
                    }
                    if (common.ProcessModeRegions)
                    {
                        int insertIndex2 = common.HotRegionsList.FindInsertIndex();
                        common.HotRegionsList.AddHotRegion(insertIndex2, graphicsPath2, relativePath: false, graph, point2, item.Name, num);
                    }
                    num++;
                }
                int num5 = 0;
                num = 0;
                foreach (DataPoint point3 in item.Points)
                {
                    Color             markerColor   = point3.MarkerColor;
                    MarkerStyle       markerStyle   = point3.MarkerStyle;
                    RadarDrawingStyle drawingStyle3 = GetDrawingStyle(item, point3);
                    if (axis.GetLogValue(point3.YValues[0]) > viewMaximum || axis.GetLogValue(point3.YValues[0]) < viewMinimum)
                    {
                        num++;
                        continue;
                    }
                    if (drawingStyle3 == RadarDrawingStyle.Marker && markerColor.IsEmpty)
                    {
                        markerColor = point3.Color;
                    }
                    SizeF markerSize = GetMarkerSize(graph, common, area, point3, point3.MarkerSize, point3.MarkerImage);
                    if (common.ProcessModePaint)
                    {
                        if (markerStyle != 0 || point3.MarkerImage.Length > 0)
                        {
                            if (markerColor.IsEmpty)
                            {
                                markerColor = point3.Color;
                            }
                            if (num5 == 0)
                            {
                                graph.StartHotRegion(point3);
                                graph.StartAnimation();
                                graph.DrawMarkerAbs(pointsPosition[num], markerStyle, (int)markerSize.Height, markerColor, point3.MarkerBorderColor, point3.MarkerBorderWidth, point3.MarkerImage, point3.MarkerImageTransparentColor, (point3.series != null) ? point3.series.ShadowOffset : 0, (point3.series != null) ? point3.series.ShadowColor : Color.Empty, new RectangleF(pointsPosition[num].X, pointsPosition[num].Y, markerSize.Width, markerSize.Height), forceAntiAlias: false);
                                graph.StopAnimation();
                                graph.EndHotRegion();
                            }
                            num5++;
                            if (item.MarkerStep == num5)
                            {
                                num5 = 0;
                            }
                        }
                        graph.StartAnimation();
                        DrawLabels(area, graph, common, pointsPosition[num], (int)markerSize.Height, point3, item, num);
                        graph.StopAnimation();
                    }
                    if (common.ProcessModeRegions)
                    {
                        SizeF  relativeSize  = graph.GetRelativeSize(markerSize);
                        PointF relativePoint = graph.GetRelativePoint(pointsPosition[num]);
                        int    insertIndex3  = common.HotRegionsList.FindInsertIndex();
                        if (point3.MarkerStyle == MarkerStyle.Circle)
                        {
                            float[] array = new float[3]
                            {
                                relativePoint.X,
                                relativePoint.Y,
                                relativeSize.Width / 2f
                            };
                            common.HotRegionsList.AddHotRegion(insertIndex3, graph, array[0], array[1], array[2], point3, item.Name, num);
                        }
                        else
                        {
                            common.HotRegionsList.AddHotRegion(insertIndex3, graph, new RectangleF(relativePoint.X - relativeSize.Width / 2f, relativePoint.Y - relativeSize.Height / 2f, relativeSize.Width, relativeSize.Height), point3, item.Name, num);
                        }
                    }
                    num++;
                }
                if (!selection)
                {
                    common.EventsManager.OnPaint(item, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition));
                }
            }
        }
Ejemplo n.º 16
0
        private static void RenderLabel(CommonElements common, ChartGraphics graph, CategoryNode node, DataPoint dataPoint, DataPointAttributes dataPointAttributes, string text, float startAngle, float sweepAngle, PointF centerAbsolute, float radiusAbsolute, int dataPointIndex, GraphicsPath sliceGraphicsPath)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }
            SizeF      size                = graph.MeasureString(text.Replace("\\n", "\n"), dataPointAttributes.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic));
            SizeF      relativeSize        = graph.GetRelativeSize(size);
            float      num                 = relativeSize.Width / (float)text.Length;
            float      num2                = relativeSize.Width + num;
            float      num3                = relativeSize.Height + relativeSize.Height / 8f;
            float      sliceCenterAngle    = GetSliceCenterAngle(startAngle, sweepAngle);
            float      labelAngle          = GetLabelAngle(sliceCenterAngle);
            PointF     sliceCenterRelative = GetSliceCenterRelative(graph, sliceCenterAngle, centerAbsolute, radiusAbsolute);
            RectangleF resizedRect         = new RectangleF(sliceCenterRelative.X - num2 / 2f, sliceCenterRelative.Y - num3 / 2f, num2, num3);

            if (resizedRect.IsEmpty)
            {
                return;
            }
            int num4 = (int)labelAngle + dataPointAttributes.FontAngle;

            if (graph.CanLabelFitInSlice(sliceGraphicsPath, resizedRect, num4) || CanFitInResizedArea(text, dataPointAttributes.Font, relativeSize, sliceCenterRelative, graph, sliceGraphicsPath, resizedRect, num4, radiusAbsolute, out resizedRect))
            {
                if (dataPoint != null)
                {
                    graph.DrawPointLabelStringRel(common, text, dataPoint.Font, new SolidBrush(dataPoint.FontColor), resizedRect, format, (int)labelAngle + dataPoint.FontAngle, resizedRect, dataPoint.LabelBackColor, dataPoint.LabelBorderColor, dataPoint.LabelBorderWidth, dataPoint.LabelBorderStyle, dataPoint.series, dataPoint, dataPointIndex);
                    return;
                }
                graph.DrawLabelBackground(num4, sliceCenterRelative, resizedRect, dataPointAttributes.LabelBackColor, dataPointAttributes.LabelBorderColor, dataPointAttributes.LabelBorderWidth, dataPointAttributes.LabelBorderStyle);
                graph.MapCategoryNodeLabel(common, node, resizedRect);
                graph.DrawStringRel(text, dataPointAttributes.Font, new SolidBrush(dataPointAttributes.FontColor), resizedRect, format, num4);
            }
        }
Ejemplo n.º 17
0
        public void CreateHistogram(AspNetCore.Reporting.Chart.WebForms.Chart chartControl, string dataSeriesName, string histogramSeriesName, string histogramLegendText)
        {
            if (chartControl == null)
            {
                throw new ArgumentNullException("chartControl");
            }
            int index = chartControl.Series.GetIndex(dataSeriesName);

            if (index < 0)
            {
                throw new ArgumentException("Series with name'" + dataSeriesName + "' was not found.", "dataSeriesName");
            }
            Series series  = chartControl.Series[dataSeriesName];
            Series series2 = null;

            if (chartControl.Series.GetIndex(histogramSeriesName) < 0)
            {
                series2 = new Series(histogramSeriesName);
                chartControl.Series.Insert(index, series2);
                series2.ChartType  = series.ChartType;
                series2.LegendText = histogramLegendText;
                if (series.Points.Count > 0)
                {
                    series2.BorderColor = series.Points[0].BorderColor;
                    series2.BorderWidth = series.Points[0].BorderWidth;
                    series2.BorderStyle = series.Points[0].BorderStyle;
                }
                series2.Color = series.Color;
                series2.BackGradientEndColor = series.BackGradientEndColor;
                series2.BackGradientType     = series.BackGradientType;
                series2.Legend    = series.Legend;
                series2.ChartArea = series.ChartArea;
                DataPointAttributes dataPointAttributes = series;
                int num = 0;
                while (num < series.Points.Count)
                {
                    if (series.Points[num].Empty)
                    {
                        num++;
                        continue;
                    }
                    dataPointAttributes = series.Points[num];
                    break;
                }
                series2.LabelBackColor   = dataPointAttributes.LabelBackColor;
                series2.LabelBorderColor = dataPointAttributes.LabelBorderColor;
                series2.LabelBorderWidth = dataPointAttributes.LabelBorderWidth;
                series2.LabelBorderStyle = dataPointAttributes.LabelBorderStyle;
                series2.LabelFormat      = dataPointAttributes.LabelFormat;
                series2.ShowLabelAsValue = dataPointAttributes.ShowLabelAsValue;
                series2.Font             = dataPointAttributes.Font;
                series2.FontColor        = dataPointAttributes.FontColor;
                series2.FontAngle        = dataPointAttributes.FontAngle;
            }
            double num2 = 1.7976931348623157E+308;
            double num3 = -1.7976931348623157E+308;
            int    num4 = 0;

            foreach (DataPoint point in series.Points)
            {
                if (!point.Empty)
                {
                    if (point.YValues[0] > num3)
                    {
                        num3 = point.YValues[0];
                    }
                    if (point.YValues[0] < num2)
                    {
                        num2 = point.YValues[0];
                    }
                    num4++;
                }
            }
            if (this.SegmentIntervalWidth == 0.0)
            {
                this.SegmentIntervalWidth = (num3 - num2) / (double)this.SegmentIntervalNumber;
                this.SegmentIntervalWidth = this.RoundInterval(this.SegmentIntervalWidth);
            }
            num2 = Math.Floor(num2 / this.SegmentIntervalWidth) * this.SegmentIntervalWidth;
            num3 = Math.Ceiling(num3 / this.SegmentIntervalWidth) * this.SegmentIntervalWidth;
            double num5 = num2;

            for (num5 = num2; num5 <= num3; num5 += this.SegmentIntervalWidth)
            {
                int num6 = 0;
                foreach (DataPoint point2 in series.Points)
                {
                    if (!point2.Empty)
                    {
                        double num7 = num5 + this.SegmentIntervalWidth;
                        if (point2.YValues[0] >= num5 && point2.YValues[0] < num7)
                        {
                            num6++;
                        }
                        else if (num7 >= num3 && point2.YValues[0] >= num5 && point2.YValues[0] <= num7)
                        {
                            num6++;
                        }
                    }
                }
                series2.Points.AddXY(num5 + this.SegmentIntervalWidth / 2.0, (double)num6);
            }
            ((DataPointAttributes)series2)["PointWidth"] = "1";
            ChartArea chartArea = chartControl.ChartAreas[series2.ChartArea];

            chartArea.AxisY.Title   = "Frequency";
            chartArea.AxisX.Minimum = num2;
            chartArea.AxisX.Maximum = num3;
            double num8 = this.SegmentIntervalWidth;
            bool   flag = false;

            while ((num3 - num2) / num8 > 10.0)
            {
                num8 *= 2.0;
                flag  = true;
            }
            chartArea.AxisX.Interval = num8;
            if (chartArea.AxisX.LabelStyle.ShowEndLabels && flag)
            {
                chartArea.AxisX.Maximum = num2 + Math.Ceiling((num3 - num2) / num8) * num8;
            }
            chartControl.Series.Remove(series);
            chartArea.AxisY2.Enabled = AxisEnabled.Auto;
            if (this.ShowPercentOnSecondaryYAxis)
            {
                chartArea.Recalculate();
                chartArea.AxisY2.Enabled           = AxisEnabled.True;
                chartArea.AxisY2.LabelStyle.Format = "P0";
                chartArea.AxisY2.MajorGrid.Enabled = false;
                chartArea.AxisY2.Title             = "Percent of Total";
                chartArea.AxisY2.Minimum           = chartArea.AxisY.Minimum / (double)num4;
                chartArea.AxisY2.Maximum           = chartArea.AxisY.Maximum / (double)num4;
                double num9 = (chartArea.AxisY2.Maximum > 0.2) ? 0.05 : 0.01;
                chartArea.AxisY2.Interval = Math.Ceiling(chartArea.AxisY2.Maximum / 5.0 / num9) * num9;
            }
        }