public virtual void Paint(ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw) { this.common = common; this.graph = graph; bool flag = false; if (area.Area3DStyle.Enable3D) { chartArea3DEnabled = true; matrix3D = area.matrix3D; } else { chartArea3DEnabled = false; } foreach (Series item in common.DataManager.Series) { if (string.Compare(item.ChartTypeName, Name, ignoreCase: true, CultureInfo.CurrentCulture) != 0 || item.ChartArea != area.Name || !item.IsVisible()) { continue; } if (chartArea3DEnabled) { area.GetSeriesZPositionAndDepth(item, out float depth, out seriesZCoordinate); seriesZCoordinate += depth / 2f; } Axis axis = area.GetAxis(AxisName.X, item.XAxisType, area.Area3DStyle.Enable3D ? string.Empty : item.XSubAxisName); Axis axis2 = area.GetAxis(AxisName.Y, item.YAxisType, area.Area3DStyle.Enable3D ? string.Empty : item.YSubAxisName); double viewMinimum = axis.GetViewMinimum(); double viewMaximum = axis.GetViewMaximum(); double viewMinimum2 = axis2.GetViewMinimum(); double viewMaximum2 = axis2.GetViewMaximum(); float num = 1f; if (item.IsAttributeSet("PixelPointGapDepth")) { string s = item["PixelPointGapDepth"]; try { num = float.Parse(s, CultureInfo.CurrentCulture); } catch { throw new InvalidOperationException(SR.ExceptionCustomAttributeValueInvalid2("PermittedPixelError")); } if (num < 0f || num > 1f) { throw new InvalidOperationException(SR.ExceptionCustomAttributeIsNotInRange0to1("PermittedPixelError")); } } SizeF relativeSize = graph.GetRelativeSize(new SizeF(num, num)); SizeF relativeSize2 = graph.GetRelativeSize(new SizeF((float)viewMinimum, (float)viewMinimum2)); double num2 = Math.Abs(axis.PositionToValue(relativeSize2.Width + relativeSize.Width, validateInput: false) - axis.PositionToValue(relativeSize2.Width, validateInput: false)); Math.Abs(axis2.PositionToValue(relativeSize2.Height + relativeSize.Height, validateInput: false) - axis2.PositionToValue(relativeSize2.Height, validateInput: false)); Pen pen = new Pen(item.Color, item.BorderWidth); pen.DashStyle = graph.GetPenStyle(item.BorderStyle); pen.StartCap = LineCap.Round; pen.EndCap = LineCap.Round; Pen pen2 = new Pen(item.EmptyPointStyle.Color, item.EmptyPointStyle.BorderWidth); pen2.DashStyle = graph.GetPenStyle(item.EmptyPointStyle.BorderStyle); pen2.StartCap = LineCap.Round; pen2.EndCap = LineCap.Round; bool flag2 = area.IndexedSeries(item.Name); int num3 = 0; double num4 = double.NaN; double num5 = double.NaN; DataPoint pointMin = null; DataPoint pointMax = null; double num6 = 0.0; double num7 = 0.0; double num8 = 0.0; double num9 = 0.0; DataPoint dataPoint = null; PointF empty = PointF.Empty; PointF pointF = PointF.Empty; PointF empty2 = PointF.Empty; bool flag3 = false; bool flag4 = false; bool flag5 = false; bool flag6 = false; bool flag7 = false; double num10 = ((double)graph.common.ChartPicture.Width - 1.0) / 100.0; double num11 = ((double)graph.common.ChartPicture.Height - 1.0) / 100.0; foreach (DataPoint point in item.Points) { num6 = (flag2 ? ((double)(num3 + 1)) : point.XValue); num6 = axis.GetLogValue(num6); num7 = axis2.GetLogValue(point.YValues[0]); flag6 = point.Empty; if (flag5 && !flag6 && !flag7) { flag7 = true; flag6 = true; } else { flag7 = false; } if (!flag4 && ((num6 < viewMinimum && num8 < viewMinimum) || (num6 > viewMaximum && num8 > viewMaximum) || (num7 < viewMinimum2 && num9 < viewMinimum2) || (num7 > viewMaximum2 && num9 > viewMaximum2))) { num8 = num6; num9 = num7; flag3 = true; num3++; continue; } if (!flag && (num8 < viewMinimum || num8 > viewMaximum || num6 > viewMaximum || num6 < viewMinimum || num9 < viewMinimum2 || num9 > viewMaximum2 || num7 < viewMinimum2 || num7 > viewMaximum2)) { graph.SetClip(area.PlotAreaPosition.ToRectangleF()); flag = true; } if (num3 > 0 && flag6 == flag5 && Math.Abs(num6 - num8) < num2) { if (!flag4) { flag4 = true; if (num7 > num9) { num5 = num7; num4 = num9; pointMax = point; pointMin = dataPoint; } else { num5 = num9; num4 = num7; pointMax = dataPoint; pointMin = point; } } else if (num7 > num5) { num5 = num7; pointMax = point; } else if (num7 < num4) { num4 = num7; pointMin = point; } dataPoint = point; empty.Y = (float)num7; num3++; continue; } empty2.X = (float)(axis.GetLinearPosition(num6) * num10); empty2.Y = (float)(axis2.GetLinearPosition(num7) * num11); if (flag3) { pointF.X = (float)(axis.GetLinearPosition(num8) * num10); pointF.Y = (float)(axis2.GetLinearPosition(num9) * num11); } if (flag4) { num4 = axis2.GetLinearPosition(num4) * num11; num5 = axis2.GetLinearPosition(num5) * num11; DrawLine(item, dataPoint, pointMin, pointMax, num3, flag5 ? pen2 : pen, pointF.X, (float)num4, pointF.X, (float)num5); flag4 = false; pointF.Y = (float)(axis2.GetLinearPosition(empty.Y) * num11); } if (num3 > 0) { DrawLine(item, point, pointMin, pointMax, num3, flag6 ? pen2 : pen, pointF.X, pointF.Y, empty2.X, empty2.Y); } num8 = num6; num9 = num7; dataPoint = point; pointF = empty2; flag3 = false; flag5 = flag6; num3++; } if (flag4) { if (flag3) { pointF.X = (float)(axis.GetLinearPosition(num8) * num10); pointF.Y = (float)(axis2.GetLinearPosition(num9) * num11); } num4 = axis2.GetLinearPosition(num4) * num11; num5 = axis2.GetLinearPosition(num5) * num11; DrawLine(item, dataPoint, pointMin, pointMax, num3 - 1, flag5 ? pen2 : pen, pointF.X, (float)num4, pointF.X, (float)num5); flag4 = false; num4 = double.NaN; num5 = double.NaN; pointMin = null; pointMax = null; } } if (flag) { graph.ResetClip(); } }
public override double GetYValue(CommonElements common, ChartArea area, Series series, DataPoint point, int pointIndex, int yValueIndex) { if (this.totalPerPoint == null) { int num = 0; foreach (Series item in common.DataManager.Series) { if (string.Compare(item.ChartTypeName, this.Name, true, CultureInfo.CurrentCulture) == 0 && item.ChartArea == area.Name && item.IsVisible()) { num++; } } Series[] array = new Series[num]; int num2 = 0; foreach (Series item2 in common.DataManager.Series) { if (string.Compare(item2.ChartTypeName, this.Name, true, CultureInfo.CurrentCulture) == 0 && item2.ChartArea == area.Name && item2.IsVisible()) { array[num2++] = item2; } } common.DataManipulator.CheckXValuesAlignment(array); this.totalPerPoint = new double[series.Points.Count]; for (int i = 0; i < series.Points.Count; i++) { this.totalPerPoint[i] = 0.0; Series[] array2 = array; foreach (Series series4 in array2) { this.totalPerPoint[i] += Math.Abs(series4.Points[i].YValues[0]); } } } if (!area.Area3DStyle.Enable3D) { if (this.totalPerPoint[pointIndex] == 0.0) { int num4 = 0; foreach (Series item3 in common.DataManager.Series) { if (string.Compare(item3.ChartTypeName, this.Name, true, CultureInfo.CurrentCulture) == 0 && item3.ChartArea == area.Name && item3.IsVisible()) { num4++; } } return(100.0 / (double)num4); } return(point.YValues[0] / this.totalPerPoint[pointIndex] * 100.0); } double num5 = double.NaN; if (yValueIndex == -1) { Axis axis = area.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName); double num6 = axis.Crossing; num5 = this.GetYValue(common, area, series, point, pointIndex, 0); if (area.Area3DStyle.Enable3D && num5 < 0.0) { num5 = 0.0 - num5; } if (num5 >= 0.0) { if (!double.IsNaN(base.prevPosY)) { num6 = base.prevPosY; } } else if (!double.IsNaN(base.prevNegY)) { num6 = base.prevNegY; } return(num5 - num6); } base.prevPosY = double.NaN; base.prevNegY = double.NaN; base.prevPositionX = double.NaN; foreach (Series item4 in common.DataManager.Series) { if (string.Compare(series.ChartArea, item4.ChartArea, true, CultureInfo.CurrentCulture) == 0 && string.Compare(series.ChartTypeName, item4.ChartTypeName, true, CultureInfo.CurrentCulture) == 0 && series.IsVisible()) { num5 = item4.Points[pointIndex].YValues[0] / this.totalPerPoint[pointIndex] * 100.0; if (!double.IsNaN(num5) && area.Area3DStyle.Enable3D && num5 < 0.0) { num5 = 0.0 - num5; } if (num5 >= 0.0 && !double.IsNaN(base.prevPosY)) { num5 += base.prevPosY; } if (num5 < 0.0 && !double.IsNaN(base.prevNegY)) { num5 += base.prevNegY; } if (string.Compare(series.Name, item4.Name, StringComparison.Ordinal) == 0) { break; } if (num5 >= 0.0) { base.prevPosY = num5; } else { base.prevNegY = num5; } base.prevPositionX = item4.Points[pointIndex].XValue; if (base.prevPositionX == 0.0 && ChartElement.IndexedSeries(series)) { base.prevPositionX = (double)(pointIndex + 1); } } } if (num5 > 100.0) { return(100.0); } return(num5); }
protected virtual void ProcessChartType(bool selection, ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw) { if (area.Area3DStyle.Enable3D) { ProcessChartType3D(selection, graph, common, area, seriesToDraw); return; } if (ShiftedSerName.Length == 0) { indexedSeries = area.IndexedSeries((string[])area.GetSeriesFromChartType(Name).ToArray(typeof(string))); } else { indexedSeries = ChartElement.IndexedSeries(common.DataManager.Series[ShiftedSerName]); } foreach (Series item in common.DataManager.Series) { bool flag = false; if (ShiftedSerName.Length > 0) { if (ShiftedSerName != item.Name) { continue; } flag = true; } if (string.Compare(item.ChartTypeName, Name, ignoreCase: true, CultureInfo.CurrentCulture) != 0 || item.ChartArea != area.Name || !item.IsVisible() || (seriesToDraw != null && seriesToDraw.Name != item.Name)) { continue; } hAxis = area.GetAxis(AxisName.X, item.XAxisType, item.XSubAxisName); vAxis = area.GetAxis(AxisName.Y, item.YAxisType, item.YSubAxisName); double viewMaximum = hAxis.GetViewMaximum(); double viewMinimum = hAxis.GetViewMinimum(); double viewMaximum2 = vAxis.GetViewMaximum(); double viewMinimum2 = vAxis.GetViewMinimum(); if (!selection) { common.EventsManager.OnBackPaint(item, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition)); } int num = 0; int num2 = 1; foreach (DataPoint point in item.Points) { point.positionRel = new PointF(float.NaN, float.NaN); double yValue = indexedSeries ? ((double)num2) : point.XValue; yValue = hAxis.GetLogValue(yValue); if (yValue > viewMaximum || yValue < viewMinimum) { num2++; continue; } double yValue2 = GetYValue(common, area, item, point, num2 - 1, yValueIndex); yValue2 = vAxis.GetLogValue(yValue2); if (yValue2 > viewMaximum2 || yValue2 < viewMinimum2) { num2++; continue; } bool flag2 = false; if (!ShouldDrawMarkerOnViewEdgeX()) { if (yValue == viewMaximum && ShiftedX >= 0.0) { flag2 = true; } if (yValue == viewMinimum && ShiftedX <= 0.0) { flag2 = true; } } int markerSize = point.MarkerSize; string markerImage = point.MarkerImage; MarkerStyle markerStyle = point.MarkerStyle; PointF empty = PointF.Empty; empty.Y = (float)vAxis.GetLinearPosition(yValue2); if (indexedSeries) { empty.X = (float)hAxis.GetPosition(num2); } else { empty.X = (float)hAxis.GetPosition(point.XValue); } empty.X += (float)ShiftedX; point.positionRel = new PointF(empty.X, empty.Y); SizeF markerSize2 = GetMarkerSize(graph, common, area, point, markerSize, markerImage); if (flag2) { num2++; continue; } if (alwaysDrawMarkers || markerStyle != 0 || markerImage.Length > 0) { if (common.ProcessModePaint) { if (num == 0) { graph.StartHotRegion(point); graph.StartAnimation(); DrawPointMarker(graph, point.series, point, 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) { SetHotRegions(common, graph, point, markerSize2, point.series.Name, num2 - 1, markerStyle, empty); } } num++; if (item.MarkerStep == num) { num = 0; } } graph.StartHotRegion(point, labelRegion: true); graph.StartAnimation(); DrawLabels(area, graph, common, empty, (int)markerSize2.Height, point, item, num2 - 1); graph.StopAnimation(); graph.EndHotRegion(); num2++; } if (!selection) { common.EventsManager.OnPaint(item, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition)); } if (flag) { break; } } }
/// <summary> /// Prepares PointAndFigure chart type for rendering. We hide original series /// during rendering and only using the data for calculations. New RangeColumn /// type series is added wich displayes the columns of Os or Xs. /// All the changes in this method are reversed back in the UnPrepareData method. /// </summary> /// <param name="series">Series to be prepared.</param> internal static void PrepareData(Series series) { // Check series chart type if (String.Compare(series.ChartTypeName, ChartTypeNames.PointAndFigure, StringComparison.OrdinalIgnoreCase) != 0 || !series.IsVisible()) { return; } // Get reference to the chart control ChartService chart = series.Chart; if (chart == null) { throw (new InvalidOperationException(SR.ExceptionPointAndFigureNullReference)); } // PointAndFigure chart may not be combined with any other chart types ChartArea area = chart.ChartAreas[series.ChartArea]; foreach (Series currentSeries in chart.Series) { if (currentSeries.IsVisible() && currentSeries != series && area == chart.ChartAreas[currentSeries.ChartArea]) { throw (new InvalidOperationException(SR.ExceptionPointAndFigureCanNotCombine)); } } // Subscribe for customize event if (!_customizeSubscribed) { _customizeSubscribed = true; chart.Customize += new EventHandler(OnCustomize); } // Create a temp series which will hold original series data points string tempSeriesName = "POINTANDFIGURE_ORIGINAL_DATA_" + series.Name; if (chart.Series.IndexOf(tempSeriesName) != -1) { return; // the temp series has already been added } Series seriesOriginalData = new(tempSeriesName, series.YValuesPerPoint); seriesOriginalData.Enabled = false; seriesOriginalData.IsVisibleInLegend = false; seriesOriginalData.YValuesPerPoint = series.YValuesPerPoint; chart.Series.Add(seriesOriginalData); foreach (DataPoint dp in series.Points) { seriesOriginalData.Points.Add(dp); } series.Points.Clear(); if (series.IsCustomPropertySet("TempDesignData")) { seriesOriginalData["TempDesignData"] = "true"; } // Remember prev. series parameters series["OldXValueIndexed"] = series.IsXValueIndexed.ToString(CultureInfo.InvariantCulture); series["OldYValuesPerPoint"] = series.YValuesPerPoint.ToString(CultureInfo.InvariantCulture); series.IsXValueIndexed = true; // Calculate date-time interval for indexed series if (series.ChartArea.Length > 0 && series.IsXValueDateTime()) { // Get X axis connected to the series Axis xAxis = area.GetAxis(AxisName.X, series.XAxisType, Series.XSubAxisName); // Change interval for auto-calculated interval only if (xAxis.Interval == 0 && xAxis.IntervalType == DateTimeIntervalType.Auto) { // Check if original data has X values set to date-time values and // calculate min/max X values. bool nonZeroXValues = false; double minX = double.MaxValue; double maxX = double.MinValue; foreach (DataPoint dp in seriesOriginalData.Points) { if (!dp.IsEmpty) { if (dp.XValue != 0.0) { nonZeroXValues = true; } if (dp.XValue > maxX) { maxX = dp.XValue; } if (dp.XValue < minX) { minX = dp.XValue; } } } if (nonZeroXValues) { // Save flag that axis interval is automatic series["OldAutomaticXAxisInterval"] = "true"; // Calculate and set axis date-time interval DateTimeIntervalType intervalType = DateTimeIntervalType.Auto; xAxis.interval = xAxis.CalcInterval(minX, maxX, true, out intervalType, series.XValueType); xAxis.intervalType = intervalType; } } } // Calculate PointAndFigure bricks data points values FillPointAndFigureData(series, seriesOriginalData); }
private void ProcessChartType3D(bool selection, ChartGraphics graph, CommonElements common, ChartArea area, bool labels, Series seriesToDraw) { if (labels && !selection) { return; } ArrayList arrayList = null; arrayList = area.GetClusterSeriesNames(seriesToDraw.Name); common.DataManager.GetNumberOfPoints((string[])arrayList.ToArray(typeof(string))); ArrayList dataPointDrawingOrder = area.GetDataPointDrawingOrder(arrayList, this, selection, COPCoordinates.X | COPCoordinates.Y, null, 0, sideBySide: false); bool flag = false; foreach (DataPoint3D item in dataPointDrawingOrder) { DataPoint dataPoint = item.dataPoint; Series series = dataPoint.series; currentStackGroup = GetSeriesStackGroupName(series); dataPoint.positionRel = new PointF(float.NaN, float.NaN); Axis axis = area.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName); Axis axis2 = area.GetAxis(AxisName.X, series.XAxisType, series.XSubAxisName); BarDrawingStyle barDrawingStyle = ChartGraphics.GetBarDrawingStyle(dataPoint); float num = 0.5f; float num2 = 0.5f; bool flag2 = true; bool flag3 = false; for (int i = 0; i < arrayList.Count; i++) { Series series2 = common.DataManager.Series[i]; if (flag2 && item.index <= series2.Points.Count && series2.Points[item.index - 1].YValues[0] != 0.0) { flag2 = false; if (series2.Name == series.Name) { num2 = 0f; } } if (series2.Name == series.Name) { flag3 = true; } else if (item.index <= series2.Points.Count && series2.Points[item.index - 1].YValues[0] != 0.0) { flag3 = false; } } if (flag3) { num = 0f; } if (area.stackGroupNames != null && area.stackGroupNames.Count > 1 && area.Area3DStyle.Clustered) { string seriesStackGroupName = GetSeriesStackGroupName(series); bool flag4 = true; bool flag5 = false; foreach (string item2 in arrayList) { Series series3 = common.DataManager.Series[item2]; if (!(GetSeriesStackGroupName(series3) == seriesStackGroupName)) { continue; } if (flag4 && item.index < series3.Points.Count && series3.Points[item.index - 1].YValues[0] != 0.0) { flag4 = false; if (item2 == series.Name) { num2 = 0f; } } if (item2 == series.Name) { flag5 = true; } else if (item.index < series3.Points.Count && series3.Points[item.index - 1].YValues[0] != 0.0) { flag5 = false; } } if (flag5) { num = 0f; } } double yValue = GetYValue(common, area, series, item.dataPoint, item.index - 1, 0); double yValue2 = yValue - GetYValue(common, area, series, item.dataPoint, item.index - 1, -1); yValue = axis.GetLogValue(yValue); yValue2 = axis.GetLogValue(yValue2); if (yValue2 > axis.GetViewMaximum()) { num = 0.5f; yValue2 = axis.GetViewMaximum(); } else if (yValue2 < axis.GetViewMinimum()) { num2 = 0.5f; yValue2 = axis.GetViewMinimum(); } if (yValue > axis.GetViewMaximum()) { num = 0.5f; yValue = axis.GetViewMaximum(); } else if (yValue < axis.GetViewMinimum()) { num2 = 0.5f; yValue = axis.GetViewMinimum(); } double linearPosition = axis.GetLinearPosition(yValue); double linearPosition2 = axis.GetLinearPosition(yValue2); RectangleF empty = RectangleF.Empty; try { empty.X = (float)(item.xPosition - item.width / 2.0); empty.Width = (float)item.width; if (linearPosition2 < linearPosition) { float num3 = num2; num2 = num; num = num3; empty.Y = (float)linearPosition2; empty.Height = (float)linearPosition - empty.Y; } else { empty.Y = (float)linearPosition; empty.Height = (float)linearPosition2 - empty.Y; } } catch (Exception) { continue; } dataPoint.positionRel = new PointF((float)item.xPosition, empty.Top); if (dataPoint.Empty) { continue; } double yValue3 = item.indexedSeries ? ((double)item.index) : dataPoint.XValue; yValue3 = axis2.GetLogValue(yValue3); if (yValue3 < axis2.GetViewMinimum() || yValue3 > axis2.GetViewMaximum() || (yValue < axis.GetViewMinimum() && yValue2 < axis.GetViewMinimum()) || (yValue > axis.GetViewMaximum() && yValue2 > axis.GetViewMaximum())) { continue; } bool flag6 = false; if (empty.Right <= area.PlotAreaPosition.X || empty.X >= area.PlotAreaPosition.Right()) { continue; } if (empty.X < area.PlotAreaPosition.X) { empty.Width -= area.PlotAreaPosition.X - empty.X; empty.X = area.PlotAreaPosition.X; } if (empty.Right > area.PlotAreaPosition.Right()) { empty.Width -= empty.Right - area.PlotAreaPosition.Right(); } if (empty.Width < 0f) { empty.Width = 0f; } if (empty.Height != 0f && empty.Width != 0f) { DrawingOperationTypes drawingOperationTypes = DrawingOperationTypes.DrawElement; if (common.ProcessModeRegions) { drawingOperationTypes |= DrawingOperationTypes.CalcElementPath; } graph.StartHotRegion(dataPoint); GraphicsPath path = graph.Fill3DRectangle(empty, item.zPosition, item.depth, area.matrix3D, area.Area3DStyle.Light, dataPoint.Color, num, num2, dataPoint.BackHatchStyle, dataPoint.BackImage, dataPoint.BackImageMode, dataPoint.BackImageTransparentColor, dataPoint.BackImageAlign, dataPoint.BackGradientType, dataPoint.BackGradientEndColor, dataPoint.BorderColor, dataPoint.BorderWidth, dataPoint.BorderStyle, PenAlignment.Inset, barDrawingStyle, veticalOrientation: true, drawingOperationTypes); graph.StopAnimation(); graph.EndHotRegion(); if (flag6) { graph.ResetClip(); } if (common.ProcessModeRegions && !labels) { common.HotRegionsList.AddHotRegion(path, relativePath: false, graph, dataPoint, series.Name, item.index - 1); } if (dataPoint.ShowLabelAsValue || dataPoint.Label.Length > 0) { flag = true; } } } if (!flag) { return; } foreach (DataPoint3D item3 in dataPointDrawingOrder) { DataPoint dataPoint2 = item3.dataPoint; Series series4 = dataPoint2.series; Axis axis3 = area.GetAxis(AxisName.Y, series4.YAxisType, series4.YSubAxisName); Axis axis4 = area.GetAxis(AxisName.X, series4.XAxisType, series4.XSubAxisName); double num4 = GetYValue(common, area, series4, item3.dataPoint, item3.index - 1, 0); if (num4 > axis3.GetViewMaximum()) { num4 = axis3.GetViewMaximum(); } if (num4 < axis3.GetViewMinimum()) { num4 = axis3.GetViewMinimum(); } num4 = axis3.GetLogValue(num4); double yPosition = item3.yPosition; double num5 = num4 - axis3.GetLogValue(GetYValue(common, area, series4, item3.dataPoint, item3.index - 1, -1)); double height = item3.height; RectangleF empty2 = RectangleF.Empty; try { empty2.X = (float)(item3.xPosition - item3.width / 2.0); empty2.Width = (float)item3.width; if (height < yPosition) { empty2.Y = (float)height; empty2.Height = (float)yPosition - empty2.Y; } else { empty2.Y = (float)yPosition; empty2.Height = (float)height - empty2.Y; } } catch (Exception) { continue; } if (!dataPoint2.Empty && !selection) { double yValue4 = item3.indexedSeries ? ((double)item3.index) : dataPoint2.XValue; yValue4 = axis4.GetLogValue(yValue4); if (!(yValue4 < axis4.GetViewMinimum()) && !(yValue4 > axis4.GetViewMaximum()) && (!(num4 < axis3.GetViewMinimum()) || !(num5 < axis3.GetViewMinimum())) && (!(num4 > axis3.GetViewMaximum()) || !(num5 > axis3.GetViewMaximum()))) { graph.StartAnimation(); DrawLabels3D(common, graph, area, item3, item3.index - 1, series4, empty2); graph.StopAnimation(); } } } }
/// <summary> /// Paint FastPoint Chart. /// </summary> /// <param name="graph">The Chart Graphics object.</param> /// <param name="common">The Common elements object.</param> /// <param name="area">Chart area for this chart.</param> /// <param name="seriesToDraw">Chart series to draw.</param> virtual public void Paint( ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw ) { this.Common = common; this.Graph = graph; if(area.Area3DStyle.Enable3D) { // Initialize variables this.chartArea3DEnabled = true; matrix3D = area.matrix3D; } else { this.chartArea3DEnabled = false; } //************************************************************ //** Loop through all series //************************************************************ foreach( Series series in common.DataManager.Series ) { // Process non empty series of the area with FastPoint chart type if( String.Compare( series.ChartTypeName, this.Name, true, System.Globalization.CultureInfo.CurrentCulture ) != 0 || series.ChartArea != area.Name || !series.IsVisible()) { continue; } // Get 3D series depth and Z position if(this.chartArea3DEnabled) { float seriesDepth; area.GetSeriesZPositionAndDepth(series, out seriesDepth, out this.seriesZCoordinate); this.seriesZCoordinate += seriesDepth/2.0f; } // Set active horizontal/vertical axis Axis hAxis = area.GetAxis(AxisName.X, series.XAxisType, (area.Area3DStyle.Enable3D) ? string.Empty : series.XSubAxisName); Axis vAxis = area.GetAxis(AxisName.Y, series.YAxisType, (area.Area3DStyle.Enable3D) ? string.Empty : series.YSubAxisName); double hAxisMin = hAxis.ViewMinimum; double hAxisMax = hAxis.ViewMaximum; double vAxisMin = vAxis.ViewMinimum; double vAxisMax = vAxis.ViewMaximum; // Get "PermittedPixelError" attribute. // By default use 1/3 of the marker size. float permittedPixelError = series.MarkerSize / 3f; if (series.IsCustomPropertySet(CustomPropertyName.PermittedPixelError)) { string attrValue = series[CustomPropertyName.PermittedPixelError]; float pixelError; bool parseSucceed = float.TryParse(attrValue, NumberStyles.Any, CultureInfo.CurrentCulture, out pixelError); if (parseSucceed) { permittedPixelError = pixelError; } else { throw (new InvalidOperationException(SR.ExceptionCustomAttributeValueInvalid2("PermittedPixelError"))); } // "PermittedPixelError" attribute value should be in range from zero to 1 if (permittedPixelError < 0f || permittedPixelError > 1f) { throw (new InvalidOperationException(SR.ExceptionCustomAttributeIsNotInRange0to1("PermittedPixelError"))); } } // Get pixel size in axes coordinates SizeF pixelSize = graph.GetRelativeSize(new SizeF(permittedPixelError, permittedPixelError)); SizeF axesMin = graph.GetRelativeSize(new SizeF((float)hAxisMin, (float)vAxisMin)); double axesValuesPixelSizeX = Math.Abs(hAxis.PositionToValue(axesMin.Width + pixelSize.Width, false) - hAxis.PositionToValue(axesMin.Width, false)); double axesValuesPixelSizeY = Math.Abs(vAxis.PositionToValue(axesMin.Height + pixelSize.Height, false) - vAxis.PositionToValue(axesMin.Height, false)); // Create point marker brush SolidBrush markerBrush = new SolidBrush( ((series.MarkerColor.IsEmpty) ? series.Color : series.MarkerColor) ); SolidBrush emptyMarkerBrush = new SolidBrush( ((series.EmptyPointStyle.MarkerColor.IsEmpty) ? series.EmptyPointStyle.Color : series.EmptyPointStyle.MarkerColor) ); // Create point marker border pen Pen borderPen = null; Pen emptyBorderPen = null; if(!series.MarkerBorderColor.IsEmpty && series.MarkerBorderWidth > 0) { borderPen = new Pen(series.MarkerBorderColor, series.MarkerBorderWidth); } if(!series.EmptyPointStyle.MarkerBorderColor.IsEmpty && series.EmptyPointStyle.MarkerBorderWidth > 0) { emptyBorderPen = new Pen(series.EmptyPointStyle.MarkerBorderColor, series.EmptyPointStyle.MarkerBorderWidth); } // Check if series is indexed bool indexedSeries = ChartHelper.IndexedSeries(this.Common, series.Name ); // Get marker size taking in consideration current DPIs int markerSize = series.MarkerSize; if (graph != null && graph.Graphics != null) { // Marker size is in pixels and we do the mapping for higher DPIs markerSize = (int)Math.Max(markerSize * graph.Graphics.DpiX / 96, markerSize * graph.Graphics.DpiY / 96); } // Loop through all ponts in the series int index = 0; double xValue = 0.0; double yValue = 0.0; double xValuePrev = 0.0; double yValuePrev = 0.0; PointF currentPoint = PointF.Empty; bool currentPointIsEmpty = false; double xPixelConverter = (graph.Common.ChartPicture.Width - 1.0) / 100.0; double yPixelConverter = (graph.Common.ChartPicture.Height - 1.0) / 100.0; MarkerStyle markerStyle = series.MarkerStyle; MarkerStyle emptyMarkerStyle = series.EmptyPointStyle.MarkerStyle; foreach( DataPoint point in series.Points ) { // Get point X and Y values xValue = (indexedSeries) ? index + 1 : point.XValue; xValue = hAxis.GetLogValue(xValue); yValue = vAxis.GetLogValue(point.YValues[0]); currentPointIsEmpty = point.IsEmpty; // Check if point is completly out of the data scaleView if( xValue < hAxisMin || xValue > hAxisMax || yValue < vAxisMin || yValue > vAxisMax ) { xValuePrev = xValue; yValuePrev = yValue; ++index; continue; } // Check if point may be skipped if(index > 0) { // Check if current point location is in the specified distance from the // preious data location. if(Math.Abs(xValue - xValuePrev) < axesValuesPixelSizeX && Math.Abs(yValue - yValuePrev) < axesValuesPixelSizeY) { // Increase counter and proceed to the next data point ++index; continue; } } // Get point pixel position currentPoint.X = (float) (hAxis.GetLinearPosition( xValue ) * xPixelConverter); currentPoint.Y = (float) (vAxis.GetLinearPosition( yValue ) * yPixelConverter); // Draw point marker MarkerStyle currentMarkerStyle = (currentPointIsEmpty) ? emptyMarkerStyle : markerStyle; if(currentMarkerStyle != MarkerStyle.None) { this.DrawMarker( graph, point, index, currentPoint, currentMarkerStyle, markerSize, (currentPointIsEmpty) ? emptyMarkerBrush : markerBrush, (currentPointIsEmpty) ? emptyBorderPen : borderPen); } // Remember last point coordinates xValuePrev = xValue; yValuePrev = yValue; ++index; } // Dispose used brushes and pens markerBrush.Dispose(); emptyMarkerBrush.Dispose(); if(borderPen != null) { borderPen.Dispose(); } if(emptyBorderPen != null) { emptyBorderPen.Dispose(); } } }
/// <summary> /// Prepares renko chart type for rendering. /// </summary> /// <param name="series">Series to be prepared.</param> internal static void PrepareData(Series series) { // Check series chart type if (String.Compare(series.ChartTypeName, ChartTypeNames.Renko, StringComparison.OrdinalIgnoreCase) != 0 || !series.IsVisible()) { return; } // Get reference to the chart control Chart chart = series.Chart; if (chart == null) { throw (new InvalidOperationException(SR.ExceptionRenkoNullReference)); } // Renko chart may not be combined with any other chart types ChartArea area = chart.ChartAreas[series.ChartArea]; foreach (Series currentSeries in chart.Series) { if (currentSeries.IsVisible() && currentSeries != series && area == chart.ChartAreas[currentSeries.ChartArea]) { throw (new InvalidOperationException(SR.ExceptionRenkoCanNotCobine)); } } // Create a temp series which will hold original series data points Series seriesOriginalData = new Series("RENKO_ORIGINAL_DATA_" + series.Name, series.YValuesPerPoint); seriesOriginalData.Enabled = false; seriesOriginalData.IsVisibleInLegend = false; chart.Series.Add(seriesOriginalData); foreach (DataPoint dp in series.Points) { seriesOriginalData.Points.Add(dp); } series.Points.Clear(); if (series.IsCustomPropertySet("TempDesignData")) { seriesOriginalData["TempDesignData"] = "true"; } // Change renko series type to range column series["OldXValueIndexed"] = series.IsXValueIndexed.ToString(CultureInfo.InvariantCulture); series["OldYValuesPerPoint"] = series.YValuesPerPoint.ToString(CultureInfo.InvariantCulture); series.ChartType = SeriesChartType.RangeColumn; series.IsXValueIndexed = true; series.YValuesPerPoint = 2; // Calculate date-time interval for indexed series if (series.ChartArea.Length > 0 && series.IsXValueDateTime()) { // Get X axis connected to the series Axis xAxis = area.GetAxis(AxisName.X, series.XAxisType, series.XSubAxisName); // Change interval for auto-calculated interval only if (xAxis.Interval == 0 && xAxis.IntervalType == DateTimeIntervalType.Auto) { // Check if original data has X values set to date-time values and // calculate min/max X values. bool nonZeroXValues = false; double minX = double.MaxValue; double maxX = double.MinValue; foreach (DataPoint dp in seriesOriginalData.Points) { if (!dp.IsEmpty) { if (dp.XValue != 0.0) { nonZeroXValues = true; } if (dp.XValue > maxX) { maxX = dp.XValue; } if (dp.XValue < minX) { minX = dp.XValue; } } } if (nonZeroXValues) { // Save flag that axis interval is automatic series["OldAutomaticXAxisInterval"] = "true"; // Calculate and set axis date-time interval DateTimeIntervalType intervalType = DateTimeIntervalType.Auto; xAxis.interval = xAxis.CalcInterval(minX, maxX, true, out intervalType, series.XValueType); xAxis.intervalType = intervalType; } } } // Calculate renko bricks data points values FillRenkoData(series, seriesOriginalData); }
protected virtual void ProcessChartType(bool selection, ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw) { if (area.Area3DStyle.Enable3D) { ProcessChartType3D(selection, graph, common, area, seriesToDraw); return; } ArrayList seriesFromChartType = area.GetSeriesFromChartType(Name); bool flag = area.IndexedSeries((string[])seriesFromChartType.ToArray(typeof(string))); foreach (Series item in common.DataManager.Series) { if (string.Compare(item.ChartTypeName, Name, StringComparison.OrdinalIgnoreCase) != 0 || item.ChartArea != area.Name || !item.IsVisible()) { continue; } if (item.YValuesPerPoint < 4) { throw new ArgumentException(SR.ExceptionChartTypeRequiresYValues("StockChart", "4")); } hAxis = area.GetAxis(AxisName.X, item.XAxisType, item.XSubAxisName); vAxis = area.GetAxis(AxisName.Y, item.YAxisType, item.YSubAxisName); double interval = flag ? 1.0 : area.GetPointsInterval(hAxis.Logarithmic, hAxis.logarithmBase); float num = (float)item.GetPointWidth(graph, hAxis, interval, 0.8); if (!selection) { common.EventsManager.OnBackPaint(item, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition)); } int num2 = 1; foreach (DataPoint point in item.Points) { point.positionRel = new PointF(float.NaN, float.NaN); double num3 = point.XValue; if (flag) { num3 = num2; } float num4 = (float)hAxis.GetPosition(num3); double logValue = vAxis.GetLogValue(point.YValues[0]); double logValue2 = vAxis.GetLogValue(point.YValues[1]); num3 = hAxis.GetLogValue(num3); if (num3 < hAxis.GetViewMinimum() || num3 > hAxis.GetViewMaximum() || (logValue < vAxis.GetViewMinimum() && logValue2 < vAxis.GetViewMinimum()) || (logValue > vAxis.GetViewMaximum() && logValue2 > vAxis.GetViewMaximum())) { num2++; continue; } double num5 = vAxis.GetLogValue(point.YValues[0]); double num6 = vAxis.GetLogValue(point.YValues[1]); if (num5 > vAxis.GetViewMaximum()) { num5 = vAxis.GetViewMaximum(); } if (num5 < vAxis.GetViewMinimum()) { num5 = vAxis.GetViewMinimum(); } num5 = (float)vAxis.GetLinearPosition(num5); if (num6 > vAxis.GetViewMaximum()) { num6 = vAxis.GetViewMaximum(); } if (num6 < vAxis.GetViewMinimum()) { num6 = vAxis.GetViewMinimum(); } num6 = vAxis.GetLinearPosition(num6); point.positionRel = new PointF(num4, (float)num5); if (common.ProcessModePaint) { bool flag2 = false; if (num3 == hAxis.GetViewMinimum() || num3 == hAxis.GetViewMaximum()) { graph.SetClip(area.PlotAreaPosition.ToRectangleF()); flag2 = true; } graph.StartHotRegion(point); graph.StartAnimation(); graph.DrawLineRel(point.Color, point.BorderWidth, point.BorderStyle, new PointF(num4, (float)num5), new PointF(num4, (float)num6), item.ShadowColor, item.ShadowOffset); DrawOpenCloseMarks(graph, area, item, point, num4, num); graph.StopAnimation(); graph.EndHotRegion(); if (flag2) { graph.ResetClip(); } } if (common.ProcessModeRegions) { RectangleF empty = RectangleF.Empty; empty.X = num4 - num / 2f; empty.Y = (float)Math.Min(num5, num6); empty.Width = num; empty.Height = (float)Math.Max(num5, num6) - empty.Y; common.HotRegionsList.AddHotRegion(graph, empty, point, item.Name, num2 - 1); } num2++; } int num7 = 0; num2 = 1; foreach (DataPoint point2 in item.Points) { double num8 = point2.XValue; if (flag) { num8 = num2; } float x = (float)hAxis.GetPosition(num8); double logValue3 = vAxis.GetLogValue(point2.YValues[0]); double logValue4 = vAxis.GetLogValue(point2.YValues[1]); num8 = hAxis.GetLogValue(num8); if (num8 < hAxis.GetViewMinimum() || num8 > hAxis.GetViewMaximum() || (logValue3 < vAxis.GetViewMinimum() && logValue4 < vAxis.GetViewMinimum()) || (logValue3 > vAxis.GetViewMaximum() && logValue4 > vAxis.GetViewMaximum())) { num2++; continue; } double num9 = vAxis.GetLogValue(point2.YValues[0]); double num10 = vAxis.GetLogValue(point2.YValues[1]); if (num9 > vAxis.GetViewMaximum()) { num9 = vAxis.GetViewMaximum(); } if (num9 < vAxis.GetViewMinimum()) { num9 = vAxis.GetViewMinimum(); } num9 = (float)vAxis.GetLinearPosition(num9); if (num10 > vAxis.GetViewMaximum()) { num10 = vAxis.GetViewMaximum(); } if (num10 < vAxis.GetViewMinimum()) { num10 = vAxis.GetViewMinimum(); } num10 = vAxis.GetLinearPosition(num10); if (point2.MarkerStyle != 0 || point2.MarkerImage.Length > 0) { SizeF size = SizeF.Empty; size.Width = point2.MarkerSize; size.Height = point2.MarkerSize; if (point2.MarkerImage.Length > 0) { common.ImageLoader.GetAdjustedImageSize(point2.MarkerImage, graph.Graphics, ref size); } PointF empty2 = PointF.Empty; empty2.X = x; empty2.Y = (float)num9 - graph.GetRelativeSize(size).Height / 2f; if (num7 == 0) { graph.StartAnimation(); graph.DrawMarkerRel(empty2, point2.MarkerStyle, (int)size.Height, (point2.MarkerColor == Color.Empty) ? point2.Color : point2.MarkerColor, (point2.MarkerBorderColor == Color.Empty) ? point2.BorderColor : point2.MarkerBorderColor, point2.MarkerBorderWidth, point2.MarkerImage, point2.MarkerImageTransparentColor, (point2.series != null) ? point2.series.ShadowOffset : 0, (point2.series != null) ? point2.series.ShadowColor : Color.Empty, new RectangleF(empty2.X, empty2.Y, size.Width, size.Height)); graph.StopAnimation(); if (common.ProcessModeRegions) { SizeF relativeSize = graph.GetRelativeSize(size); int insertIndex = common.HotRegionsList.FindInsertIndex(); common.HotRegionsList.FindInsertIndex(); if (point2.MarkerStyle == MarkerStyle.Circle) { float[] array = new float[3] { empty2.X, empty2.Y, relativeSize.Width / 2f }; common.HotRegionsList.AddHotRegion(insertIndex, graph, array[0], array[1], array[2], point2, item.Name, num2 - 1); } else { common.HotRegionsList.AddHotRegion(graph, new RectangleF(empty2.X - relativeSize.Width / 2f, empty2.Y - relativeSize.Height / 2f, relativeSize.Width, relativeSize.Height), point2, item.Name, num2 - 1); } } } num7++; if (item.MarkerStep == num7) { num7 = 0; } } graph.StartAnimation(); DrawLabel(common, area, graph, item, point2, new PointF(x, (float)Math.Min(num9, num10)), num2); graph.StopAnimation(); num2++; } if (!selection) { common.EventsManager.OnPaint(item, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition)); } } }
public void AddSmartLabelMarkerPositions(CommonElements common, ChartArea area, Series series, ArrayList list) { bool flag = area.IndexedSeries((string[])area.GetSeriesFromChartType(Name).ToArray(typeof(string))); Axis axis = area.GetAxis(AxisName.X, series.XAxisType, series.XSubAxisName); Axis axis2 = area.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName); int num = 0; int num2 = 1; foreach (DataPoint point in series.Points) { double yValue = GetYValue(common, area, series, point, num2 - 1, 0); yValue = axis2.GetLogValue(yValue); if (yValue > axis2.GetViewMaximum() || yValue < axis2.GetViewMinimum()) { num2++; continue; } double yValue2 = flag ? ((double)num2) : point.XValue; yValue2 = axis.GetLogValue(yValue2); if (yValue2 > axis.GetViewMaximum() || yValue2 < axis.GetViewMinimum()) { num2++; continue; } PointF pointF = PointF.Empty; pointF.Y = (float)axis2.GetLinearPosition(yValue); if (flag) { pointF.X = (float)axis.GetPosition(num2); } else { pointF.X = (float)axis.GetPosition(point.XValue); } _ = point.MarkerSize; string markerImage = point.MarkerImage; MarkerStyle markerStyle = point.MarkerStyle; SizeF size = SizeF.Empty; size.Width = point.MarkerSize; size.Height = point.MarkerSize; if (point.MarkerImage.Length > 0 && common.graph != null) { common.ImageLoader.GetAdjustedImageSize(point.MarkerImage, common.graph.Graphics, ref size); } if (area.Area3DStyle.Enable3D) { area.GetSeriesZPositionAndDepth(series, out float depth, out float positionZ); Point3D[] array = new Point3D[1] { new Point3D(pointF.X, pointF.Y, positionZ + depth / 2f) }; area.matrix3D.TransformPoints(array); pointF = array[0].PointF; } if (markerStyle != 0 || markerImage.Length > 0) { if (num == 0) { size = common.graph.GetRelativeSize(size); RectangleF rectangleF = new RectangleF(pointF.X - size.Width / 2f, pointF.Y - size.Height, size.Width, size.Height); list.Add(rectangleF); } num++; if (series.MarkerStep == num) { num = 0; } } num2++; } }
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()) { if (string.Compare(item.ChartTypeName, this.Name, true, CultureInfo.CurrentCulture) != 0) { throw new InvalidOperationException(SR.ExceptionChartTypeCanNotCombine(item.ChartTypeName, this.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 = this.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; Color borderColor = dataPointAttributes.BorderColor; int borderWidth = dataPointAttributes.BorderWidth; ChartDashStyle borderStyle = dataPointAttributes.BorderStyle; RadarDrawingStyle drawingStyle = this.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)) { switch (drawingStyle) { case RadarDrawingStyle.Line: { Color color3 = 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 && !this.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((float)item.ShadowOffset, (float)item.ShadowOffset); graphicsPath.Transform(matrix); graph.FillPath(new SolidBrush(item.ShadowColor), graphicsPath); } num++; } else { 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 = this.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)) { 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 && !this.RequireClosedFigure() && drawingStyle2 != 0) { if (common.ProcessModeRegions) { this.AddSelectionPath(area, graphicsPath2, pointsPosition, num, num3, graph.GetAbsolutePoint(area.circularCenter), 0); int insertIndex = common.HotRegionsList.FindInsertIndex(); common.HotRegionsList.AddHotRegion(insertIndex, graphicsPath2, 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) { this.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) { this.AddSelectionPath(area, graphicsPath2, pointsPosition, num, num3, PointF.Empty, num4); } } if (common.ProcessModeRegions) { int insertIndex2 = common.HotRegionsList.FindInsertIndex(); common.HotRegionsList.AddHotRegion(insertIndex2, graphicsPath2, false, graph, point2, item.Name, num); } num++; } else { num++; } } int num5 = 0; num = 0; foreach (DataPoint point3 in item.Points) { Color markerColor = point3.MarkerColor; MarkerStyle markerStyle = point3.MarkerStyle; RadarDrawingStyle drawingStyle3 = this.GetDrawingStyle(item, point3); if (axis.GetLogValue(point3.YValues[0]) > viewMaximum || axis.GetLogValue(point3.YValues[0]) < viewMinimum) { num++; } else { if (drawingStyle3 == RadarDrawingStyle.Marker && markerColor.IsEmpty) { markerColor = point3.Color; } SizeF markerSize = this.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), false); graph.StopAnimation(); graph.EndHotRegion(); } num5++; if (item.MarkerStep == num5) { num5 = 0; } } graph.StartAnimation(); this.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, (float)(relativeSize.Width / 2.0) }; common.HotRegionsList.AddHotRegion(insertIndex3, graph, array[0], array[1], array[2], point3, item.Name, num); } else { common.HotRegionsList.AddHotRegion(insertIndex3, graph, new RectangleF((float)(relativePoint.X - relativeSize.Width / 2.0), (float)(relativePoint.Y - relativeSize.Height / 2.0), relativeSize.Width, relativeSize.Height), point3, item.Name, num); } } num++; } } if (!selection) { common.EventsManager.OnPaint(item, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition)); } } } }
protected virtual void ProcessChartType(bool selection, ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw) { if (area.Area3DStyle.Enable3D) { ProcessChartType3D(selection, graph, common, area, seriesToDraw); return; } ArrayList seriesFromChartType = area.GetSeriesFromChartType(Name); bool flag = area.IndexedSeries((string[])seriesFromChartType.ToArray(typeof(string))); int num = 0; foreach (Series item in common.DataManager.Series) { if (string.Compare(item.ChartTypeName, Name, StringComparison.OrdinalIgnoreCase) != 0 || item.ChartArea != area.Name || !item.IsVisible()) { continue; } hAxis = area.GetAxis(AxisName.X, item.XAxisType, item.XSubAxisName); vAxis = area.GetAxis(AxisName.Y, item.YAxisType, item.YSubAxisName); double interval = flag ? 1.0 : area.GetPointsInterval(hAxis.Logarithmic, hAxis.logarithmBase); bool flag2 = showSideBySide; if (item.IsAttributeSet("DrawSideBySide")) { string strA = item["DrawSideBySide"]; if (string.Compare(strA, "False", StringComparison.OrdinalIgnoreCase) == 0) { flag2 = false; } else if (string.Compare(strA, "True", StringComparison.OrdinalIgnoreCase) == 0) { flag2 = true; } else if (string.Compare(strA, "Auto", StringComparison.OrdinalIgnoreCase) != 0) { throw new InvalidOperationException(SR.ExceptionAttributeDrawSideBySideInvalid); } } double num2 = seriesFromChartType.Count; if (!flag2) { num2 = 1.0; } float num3 = (float)(item.GetPointWidth(graph, hAxis, interval, 0.8) / num2); if (!selection) { common.EventsManager.OnBackPaint(item, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition)); } int num4 = 1; foreach (DataPoint point in item.Points) { if (point.YValues.Length < YValuesPerPoint) { throw new InvalidOperationException(SR.ExceptionChartTypeRequiresYValues(Name, YValuesPerPoint.ToString(CultureInfo.InvariantCulture))); } point.positionRel = new PointF(float.NaN, float.NaN); float num5 = 0f; double num6 = point.XValue; if (!flag) { num5 = ((!flag2) ? ((float)hAxis.GetPosition(num6)) : ((float)(hAxis.GetPosition(num6) - (double)num3 * num2 / 2.0 + (double)(num3 / 2f) + (double)((float)num * num3)))); } else { num6 = num4; num5 = (float)(hAxis.GetPosition(num4) - (double)num3 * num2 / 2.0 + (double)(num3 / 2f) + (double)((float)num * num3)); } double logValue = vAxis.GetLogValue(point.YValues[0]); double logValue2 = vAxis.GetLogValue(point.YValues[1]); num6 = hAxis.GetLogValue(num6); if (num6 < hAxis.GetViewMinimum() || num6 > hAxis.GetViewMaximum() || (logValue < vAxis.GetViewMinimum() && logValue2 < vAxis.GetViewMinimum()) || (logValue > vAxis.GetViewMaximum() && logValue2 > vAxis.GetViewMaximum())) { num4++; continue; } double num7 = vAxis.GetLogValue(point.YValues[0]); double num8 = vAxis.GetLogValue(point.YValues[1]); if (num8 > vAxis.GetViewMaximum()) { num8 = vAxis.GetViewMaximum(); } if (num8 < vAxis.GetViewMinimum()) { num8 = vAxis.GetViewMinimum(); } num8 = (float)vAxis.GetLinearPosition(num8); if (num7 > vAxis.GetViewMaximum()) { num7 = vAxis.GetViewMaximum(); } if (num7 < vAxis.GetViewMinimum()) { num7 = vAxis.GetViewMinimum(); } num7 = vAxis.GetLinearPosition(num7); point.positionRel = new PointF(num5, (float)Math.Min(num8, num7)); if (common.ProcessModePaint) { bool flag3 = false; if (num6 == hAxis.GetViewMinimum() || num6 == hAxis.GetViewMaximum()) { graph.SetClip(area.PlotAreaPosition.ToRectangleF()); flag3 = true; } Color color = point.BorderColor; if (color == Color.Empty) { color = point.Color; } graph.StartHotRegion(point); graph.StartAnimation(); graph.DrawLineRel(color, point.BorderWidth, point.BorderStyle, new PointF(num5, (float)num7), new PointF(num5, (float)vAxis.GetPosition(point.YValues[2])), item.ShadowColor, item.ShadowOffset); graph.DrawLineRel(color, point.BorderWidth, point.BorderStyle, new PointF(num5, (float)num8), new PointF(num5, (float)vAxis.GetPosition(point.YValues[3])), item.ShadowColor, item.ShadowOffset); RectangleF empty = RectangleF.Empty; empty.X = num5 - num3 / 2f; empty.Width = num3; empty.Y = (float)vAxis.GetPosition(point.YValues[3]); empty.Height = (float)Math.Abs((double)empty.Y - vAxis.GetPosition(point.YValues[2])); graph.FillRectangleRel(empty, point.Color, point.BackHatchStyle, point.BackImage, point.BackImageMode, point.BackImageTransparentColor, point.BackImageAlign, point.BackGradientType, point.BackGradientEndColor, point.BorderColor, point.BorderWidth, point.BorderStyle, item.ShadowColor, item.ShadowOffset, PenAlignment.Inset); bool flag4 = true; if (point.IsAttributeSet("BoxPlotShowAverage") || item.IsAttributeSet("BoxPlotShowAverage")) { string strA2 = item["BoxPlotShowAverage"]; if (point.IsAttributeSet("BoxPlotShowAverage")) { strA2 = point["BoxPlotShowAverage"]; } if (string.Compare(strA2, "True", StringComparison.OrdinalIgnoreCase) != 0) { if (string.Compare(strA2, "False", StringComparison.OrdinalIgnoreCase) != 0) { throw new InvalidOperationException(SR.ExceptionCustomAttributeValueInvalid(point["BoxPlotShowAverage"], "BoxPlotShowAverage")); } flag4 = false; } } SizeF relativeSize = graph.GetRelativeSize(new SizeF(point.BorderWidth, point.BorderWidth)); if (point.BorderColor == Color.Empty) { relativeSize.Height = 0f; relativeSize.Width = 0f; } Color color2 = color; if (color2 == point.Color) { color2 = ((!(Math.Sqrt(point.Color.R * point.Color.R + point.Color.G * point.Color.G + point.Color.B * point.Color.B) > 220.0)) ? ChartGraphics.GetGradientColor(point.Color, Color.White, 0.4) : ChartGraphics.GetGradientColor(point.Color, Color.Black, 0.4)); } if (!double.IsNaN(point.YValues[4]) && flag4) { graph.DrawLineRel(color2, 1, ChartDashStyle.Solid, new PointF(empty.Left + relativeSize.Width, (float)vAxis.GetPosition(point.YValues[4])), new PointF(empty.Right - relativeSize.Width, (float)vAxis.GetPosition(point.YValues[4])), Color.Empty, 0); } bool flag5 = true; if (point.IsAttributeSet("BoxPlotShowMedian") || item.IsAttributeSet("BoxPlotShowMedian")) { string strA3 = item["BoxPlotShowMedian"]; if (point.IsAttributeSet("BoxPlotShowMedian")) { strA3 = point["BoxPlotShowMedian"]; } if (string.Compare(strA3, "True", StringComparison.OrdinalIgnoreCase) != 0) { if (string.Compare(strA3, "False", StringComparison.OrdinalIgnoreCase) != 0) { throw new InvalidOperationException(SR.ExceptionCustomAttributeValueInvalid(point["BoxPlotShowMedian"], "BoxPlotShowMedian")); } flag5 = false; } } if (!double.IsNaN(point.YValues[5]) && flag5) { float y = (float)vAxis.GetPosition(point.YValues[5]); float val = (empty.Width - relativeSize.Width * 2f) / 9f; val = Math.Max(val, graph.GetRelativeSize(new SizeF(2f, 2f)).Width); for (float num9 = empty.Left + relativeSize.Width; num9 < empty.Right - relativeSize.Width; num9 += val * 2f) { graph.DrawLineRel(color2, 1, ChartDashStyle.Solid, new PointF(num9, y), new PointF(Math.Min(empty.Right, num9 + val), y), Color.Empty, 0); } } DrawBoxPlotMarks(graph, area, item, point, num5, num3); graph.StopAnimation(); graph.EndHotRegion(); if (flag3) { graph.ResetClip(); } } if (common.ProcessModeRegions) { RectangleF empty2 = RectangleF.Empty; empty2.X = num5 - num3 / 2f; empty2.Y = (float)Math.Min(num8, num7); empty2.Width = num3; empty2.Height = (float)Math.Max(num8, num7) - empty2.Y; common.HotRegionsList.AddHotRegion(graph, empty2, point, item.Name, num4 - 1); } num4++; } if (!selection) { num4 = 1; foreach (DataPoint point2 in item.Points) { float num10 = 0f; double num11 = point2.XValue; if (!flag) { num10 = ((!flag2) ? ((float)hAxis.GetPosition(num11)) : ((float)(hAxis.GetPosition(num11) - (double)num3 * num2 / 2.0 + (double)(num3 / 2f) + (double)((float)num * num3)))); } else { num11 = num4; num10 = (float)(hAxis.GetPosition(num4) - (double)num3 * num2 / 2.0 + (double)(num3 / 2f) + (double)((float)num * num3)); } double logValue3 = vAxis.GetLogValue(point2.YValues[0]); double logValue4 = vAxis.GetLogValue(point2.YValues[1]); num11 = hAxis.GetLogValue(num11); if (num11 < hAxis.GetViewMinimum() || num11 > hAxis.GetViewMaximum() || (logValue3 < vAxis.GetViewMinimum() && logValue4 < vAxis.GetViewMinimum()) || (logValue3 > vAxis.GetViewMaximum() && logValue4 > vAxis.GetViewMaximum())) { num4++; continue; } double num12 = double.MaxValue; for (int i = 0; i < point2.YValues.Length; i++) { if (!double.IsNaN(point2.YValues[i])) { double num13 = vAxis.GetLogValue(point2.YValues[i]); if (num13 > vAxis.GetViewMaximum()) { num13 = vAxis.GetViewMaximum(); } if (num13 < vAxis.GetViewMinimum()) { num13 = vAxis.GetViewMinimum(); } num13 = (float)vAxis.GetLinearPosition(num13); num12 = Math.Min(num12, num13); } } num12 -= (double)(graph.GetRelativeSize(new SizeF(point2.MarkerSize, point2.MarkerSize)).Height / 2f); graph.StartHotRegion(point2, labelRegion: true); graph.StartAnimation(); DrawLabel(common, area, graph, item, point2, new PointF(num10, (float)num12), num4); graph.StopAnimation(); graph.EndHotRegion(); num4++; } } if (!selection) { common.EventsManager.OnPaint(item, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition)); } if (flag2) { num++; } } }
internal void DrawMarkers(ChartGraphics graph, ChartPicture chart, FinancialMarkerType markerName, Series series, int firstPoint, int firstYValue, int secondPoint, int secondYValue, Color lineColor, int lineWidth, ChartDashStyle lineStyle, Color textColor, Font textFont) { this.lineStyle = lineStyle; if (textColor == Color.Empty) { drawText = false; } else { this.textColor = textColor; drawText = true; } if (lineColor == Color.Empty) { this.lineColor = Color.Gray; } else { this.lineColor = lineColor; } if (lineWidth == 0) { this.lineWidth = 1; } else { this.lineWidth = lineWidth; } if (textFont == null) { this.textFont = new Font(ChartPicture.GetDefaultFontFamilyName(), 8f); } else { this.textFont = textFont; } ChartArea chartArea = chart.ChartAreas[series.ChartArea]; if (chartArea.Area3DStyle.Enable3D || chartArea.chartAreaIsCurcular || !chartArea.requireAxes) { return; } Axis axis = chartArea.GetAxis(AxisName.X, series.XAxisType, series.XSubAxisName); Axis axis2 = chartArea.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName); double position; double position2; double position3; double position4; try { if (chartArea.Common.ChartTypeRegistry.GetChartType(series.ChartTypeName).SwitchValueAxes) { axesSwitched = true; Axis axis3 = axis2; axis2 = axis; axis = axis3; position = axis.GetPosition(series.Points[firstPoint].YValues[firstYValue]); position2 = axis2.GetPosition(series.Points[firstPoint].XValue); position3 = axis.GetPosition(series.Points[secondPoint].YValues[secondYValue]); position4 = axis2.GetPosition(series.Points[secondPoint].XValue); } else { axesSwitched = false; position = axis.GetPosition(series.Points[firstPoint].XValue); position2 = axis2.GetPosition(series.Points[firstPoint].YValues[firstYValue]); position3 = axis.GetPosition(series.Points[secondPoint].XValue); position4 = axis2.GetPosition(series.Points[secondPoint].YValues[secondYValue]); } } catch (Exception) { throw new InvalidOperationException(SR.ExceptionFinancialMarkersSeriesPointYValueIndexInvalid); } PointF relative = new PointF((float)position, (float)position2); PointF relative2 = new PointF((float)position3, (float)position4); relative = graph.GetAbsolutePoint(relative); relative2 = graph.GetAbsolutePoint(relative2); bool flag = false; foreach (DataPoint point in series.Points) { flag = true; if (point.XValue != 0.0) { flag = false; break; } } if (flag) { throw new InvalidOperationException(SR.ExceptionFormulaDataZeroIndexedXValuesUnsupported); } graph.SetClip(chartArea.PlotAreaPosition.ToRectangleF()); SmoothingMode smoothingMode = graph.SmoothingMode; if ((graph.AntiAliasing & AntiAliasingTypes.Graphics) == AntiAliasingTypes.Graphics) { graph.SmoothingMode = SmoothingMode.AntiAlias; } switch (markerName) { case FinancialMarkerType.FibonacciArcs: FibonacciArcs(graph, relative, relative2); break; case FinancialMarkerType.TrendLine: TrendLine(graph, relative, relative2); break; case FinancialMarkerType.FibonacciFans: FibonacciFans(graph, relative, relative2, chartArea); break; case FinancialMarkerType.FibonacciRetracements: FibonacciRetracements(graph, relative, relative2, chartArea); break; case FinancialMarkerType.SpeedResistanceLines: SpeedResistanceLines(graph, relative, relative2, chartArea); break; case FinancialMarkerType.QuadrantLines: QuadrantLines(graph, relative, relative2, chartArea); break; default: throw new InvalidOperationException(SR.ExceptionFinancialMarkersFormulaNotFound); } graph.ResetClip(); graph.SmoothingMode = smoothingMode; }
public virtual void Paint(ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw) { this.common = common; this.graph = graph; if (area.Area3DStyle.Enable3D) { chartArea3DEnabled = true; matrix3D = area.matrix3D; } else { chartArea3DEnabled = false; } foreach (Series item in common.DataManager.Series) { if (string.Compare(item.ChartTypeName, Name, ignoreCase: true, CultureInfo.CurrentCulture) != 0 || item.ChartArea != area.Name || !item.IsVisible()) { continue; } if (chartArea3DEnabled) { area.GetSeriesZPositionAndDepth(item, out float depth, out seriesZCoordinate); seriesZCoordinate += depth / 2f; } Axis axis = area.GetAxis(AxisName.X, item.XAxisType, area.Area3DStyle.Enable3D ? string.Empty : item.XSubAxisName); Axis axis2 = area.GetAxis(AxisName.Y, item.YAxisType, area.Area3DStyle.Enable3D ? string.Empty : item.YSubAxisName); double viewMinimum = axis.GetViewMinimum(); double viewMaximum = axis.GetViewMaximum(); double viewMinimum2 = axis2.GetViewMinimum(); double viewMaximum2 = axis2.GetViewMaximum(); float num = (float)item.MarkerSize / 3f; if (item.IsAttributeSet("PixelPointGapDepth")) { string s = item["PixelPointGapDepth"]; try { num = float.Parse(s, CultureInfo.CurrentCulture); } catch { throw new InvalidOperationException(SR.ExceptionCustomAttributeValueInvalid2("PermittedPixelError")); } if (num < 0f || num > 50f) { throw new InvalidOperationException(SR.ExceptionCustomAttributeIsNotInRange0to50("PermittedPixelError")); } } SizeF relativeSize = graph.GetRelativeSize(new SizeF(num, num)); SizeF relativeSize2 = graph.GetRelativeSize(new SizeF((float)viewMinimum, (float)viewMinimum2)); double num2 = Math.Abs(axis.PositionToValue(relativeSize2.Width + relativeSize.Width, validateInput: false) - axis.PositionToValue(relativeSize2.Width, validateInput: false)); double num3 = Math.Abs(axis2.PositionToValue(relativeSize2.Height + relativeSize.Height, validateInput: false) - axis2.PositionToValue(relativeSize2.Height, validateInput: false)); SolidBrush solidBrush = new SolidBrush(item.MarkerColor.IsEmpty ? item.Color : item.MarkerColor); SolidBrush solidBrush2 = new SolidBrush(item.EmptyPointStyle.MarkerColor.IsEmpty ? item.EmptyPointStyle.Color : item.EmptyPointStyle.MarkerColor); Pen pen = null; Pen pen2 = null; if (!item.MarkerBorderColor.IsEmpty && item.MarkerBorderWidth > 0) { pen = new Pen(item.MarkerBorderColor, item.MarkerBorderWidth); } if (!item.EmptyPointStyle.MarkerBorderColor.IsEmpty && item.EmptyPointStyle.MarkerBorderWidth > 0) { pen2 = new Pen(item.EmptyPointStyle.MarkerBorderColor, item.EmptyPointStyle.MarkerBorderWidth); } bool flag = area.IndexedSeries(item.Name); int num4 = 0; double num5 = 0.0; double num6 = 0.0; double num7 = 0.0; double num8 = 0.0; PointF empty = PointF.Empty; bool flag2 = false; double num9 = ((double)graph.common.ChartPicture.Width - 1.0) / 100.0; double num10 = ((double)graph.common.ChartPicture.Height - 1.0) / 100.0; int markerSize = item.MarkerSize; MarkerStyle markerStyle = item.MarkerStyle; MarkerStyle markerStyle2 = item.EmptyPointStyle.MarkerStyle; foreach (DataPoint point in item.Points) { num5 = (flag ? ((double)(num4 + 1)) : point.XValue); num5 = axis.GetLogValue(num5); num6 = axis2.GetLogValue(point.YValues[0]); flag2 = point.Empty; if (num5 < viewMinimum || num5 > viewMaximum || num6 < viewMinimum2 || num6 > viewMaximum2) { num7 = num5; num8 = num6; num4++; continue; } if (num4 > 0 && Math.Abs(num5 - num7) < num2 && Math.Abs(num6 - num8) < num3) { num4++; continue; } empty.X = (float)(axis.GetLinearPosition(num5) * num9); empty.Y = (float)(axis2.GetLinearPosition(num6) * num10); DrawMarker(graph, point, num4, empty, flag2 ? markerStyle2 : markerStyle, markerSize, flag2 ? solidBrush2 : solidBrush, flag2 ? pen2 : pen); num7 = num5; num8 = num6; num4++; } solidBrush.Dispose(); solidBrush2.Dispose(); pen?.Dispose(); pen2?.Dispose(); } }
public override double GetYValue(CommonElements common, ChartArea area, Series series, DataPoint point, int pointIndex, int yValueIndex) { double[] array = null; string seriesStackGroupName = StackedColumnChart.GetSeriesStackGroupName(series); if (this.stackedGroupsTotalPerPoint == null) { this.stackedGroupsTotalPerPoint = new Hashtable(); foreach (string stackGroupName in base.stackGroupNames) { Series[] seriesByStackedGroupName = StackedColumnChart.GetSeriesByStackedGroupName(common, stackGroupName, series.ChartTypeName, series.ChartArea); common.DataManipulator.CheckXValuesAlignment(seriesByStackedGroupName); double[] array2 = new double[series.Points.Count]; for (int i = 0; i < series.Points.Count; i++) { array2[i] = 0.0; Series[] array3 = seriesByStackedGroupName; foreach (Series series2 in array3) { array2[i] += Math.Abs(series2.Points[i].YValues[0]); } } this.stackedGroupsTotalPerPoint.Add(stackGroupName, array2); } } array = (double[])this.stackedGroupsTotalPerPoint[seriesStackGroupName]; if (!area.Area3DStyle.Enable3D && (point.YValues[0] == 0.0 || point.Empty)) { return(0.0); } if (area.Area3DStyle.Enable3D && yValueIndex != -2) { double num = double.NaN; if (yValueIndex == -1) { Axis axis = area.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName); double num2 = axis.Crossing; num = this.GetYValue(common, area, series, point, pointIndex, 0); if (num >= 0.0) { if (!double.IsNaN(base.prevPosY)) { num2 = base.prevPosY; } } else if (!double.IsNaN(base.prevNegY)) { num2 = base.prevNegY; } return(num - num2); } base.prevPosY = double.NaN; base.prevNegY = double.NaN; foreach (Series item in common.DataManager.Series) { if (string.Compare(series.ChartArea, item.ChartArea, StringComparison.Ordinal) == 0 && string.Compare(series.ChartTypeName, item.ChartTypeName, StringComparison.OrdinalIgnoreCase) == 0 && item.IsVisible() && !(seriesStackGroupName != StackedColumnChart.GetSeriesStackGroupName(item))) { if (double.IsNaN(num)) { num = ((array[pointIndex] != 0.0) ? (item.Points[pointIndex].YValues[0] / array[pointIndex] * 100.0) : 0.0); } else { num = ((array[pointIndex] != 0.0) ? (item.Points[pointIndex].YValues[0] / array[pointIndex] * 100.0) : 0.0); if (num >= 0.0 && !double.IsNaN(base.prevPosY)) { num += base.prevPosY; } if (num < 0.0 && !double.IsNaN(base.prevNegY)) { num += base.prevNegY; } } if (string.Compare(series.Name, item.Name, StringComparison.Ordinal) == 0) { break; } if (num >= 0.0) { base.prevPosY = num; } else { base.prevNegY = num; } } } if (!(num > 100.0)) { return(num); } return(100.0); } if (array[pointIndex] == 0.0) { return(0.0); } return(point.YValues[0] / array[pointIndex] * 100.0); }
private void ProcessChartType3D(bool labels, bool selection, ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw) { if (labels && !selection) { return; } SizeF relativeSize = graph.GetRelativeSize(new SizeF(1.1f, 1.1f)); ArrayList arrayList = null; bool flag = drawSeriesSideBySide; if ((area.Area3DStyle.Clustered && SideBySideSeries) || Stacked) { arrayList = area.GetSeriesFromChartType(Name); foreach (string item in arrayList) { if (common.DataManager.Series[item].IsAttributeSet("DrawSideBySide")) { string strA = common.DataManager.Series[item]["DrawSideBySide"]; if (string.Compare(strA, "False", StringComparison.OrdinalIgnoreCase) == 0) { flag = false; } else if (string.Compare(strA, "True", StringComparison.OrdinalIgnoreCase) == 0) { flag = true; } else if (string.Compare(strA, "Auto", StringComparison.OrdinalIgnoreCase) != 0) { throw new InvalidOperationException(SR.ExceptionAttributeDrawSideBySideInvalid); } } } } else { arrayList = new ArrayList(); arrayList.Add(seriesToDraw.Name); } foreach (DataPoint3D item2 in area.GetDataPointDrawingOrder(arrayList, this, selection, coordinates, null, yValueIndex, flag)) { DataPoint dataPoint = item2.dataPoint; Series series = dataPoint.series; BarDrawingStyle barDrawingStyle = ChartGraphics.GetBarDrawingStyle(dataPoint); Axis axis = area.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName); Axis axis2 = area.GetAxis(AxisName.X, series.XAxisType, series.XSubAxisName); float num = 0f; float num2 = 0f; double yValue = GetYValue(common, area, series, item2.dataPoint, item2.index - 1, useTwoValues ? 1 : 0); yValue = axis.GetLogValue(yValue); if (yValue > axis.GetViewMaximum()) { num = 0.5f; yValue = axis.GetViewMaximum(); } if (yValue < axis.GetViewMinimum()) { num = 0.5f; yValue = axis.GetViewMinimum(); } double num3 = axis.GetLinearPosition(yValue); double num4 = 0.0; if (useTwoValues) { double num5 = axis.GetLogValue(GetYValue(common, area, series, dataPoint, item2.index - 1, 0)); if (num5 > axis.GetViewMaximum()) { num2 = 0.5f; num5 = axis.GetViewMaximum(); } else if (num5 < axis.GetViewMinimum()) { num2 = 0.5f; num5 = axis.GetViewMinimum(); } num4 = axis.GetLinearPosition(num5); } else { num4 = axis.GetPosition(axis.Crossing); } if (!flag) { item2.xPosition = item2.xCenterVal; } ShiftedX = item2.xPosition - item2.xCenterVal; if (num3 < num4 && num4 - num3 < (double)relativeSize.Height) { num3 = num4 - (double)relativeSize.Height; } if (num3 > num4 && num3 - num4 < (double)relativeSize.Height) { num3 = num4 + (double)relativeSize.Height; } RectangleF empty = RectangleF.Empty; try { empty.X = (float)(item2.xPosition - item2.width / 2.0); empty.Width = (float)item2.width; if (num4 < num3) { float num6 = num2; num2 = num; num = num6; empty.Y = (float)num4; empty.Height = (float)num3 - empty.Y; } else { empty.Y = (float)num3; empty.Height = (float)num4 - empty.Y; } } catch (Exception) { continue; } GraphicsPath graphicsPath = null; double yValue2 = item2.indexedSeries ? ((double)item2.index) : dataPoint.XValue; yValue2 = axis2.GetLogValue(yValue2); if (yValue2 < axis2.GetViewMinimum() || yValue2 > axis2.GetViewMaximum()) { continue; } bool flag2 = false; if (empty.Right <= area.PlotAreaPosition.X || empty.X >= area.PlotAreaPosition.Right()) { continue; } if (empty.X < area.PlotAreaPosition.X) { empty.Width -= area.PlotAreaPosition.X - empty.X; empty.X = area.PlotAreaPosition.X; } if (empty.Right > area.PlotAreaPosition.Right()) { empty.Width -= empty.Right - area.PlotAreaPosition.Right(); } if (empty.Width < 0f) { empty.Width = 0f; } DrawingOperationTypes drawingOperationTypes = DrawingOperationTypes.DrawElement; if (common.ProcessModeRegions) { drawingOperationTypes |= DrawingOperationTypes.CalcElementPath; } if (!dataPoint.Empty && empty.Height > 0f && empty.Width > 0f) { graph.StartHotRegion(dataPoint); Init3DAnimation(common, empty, item2.zPosition, item2.depth, area.matrix3D, graph, yValue < axis2.Crossing, dataPoint); graph.StartAnimation(); graphicsPath = graph.Fill3DRectangle(empty, item2.zPosition, item2.depth, area.matrix3D, area.Area3DStyle.Light, dataPoint.Color, num, num2, dataPoint.BackHatchStyle, dataPoint.BackImage, dataPoint.BackImageMode, dataPoint.BackImageTransparentColor, dataPoint.BackImageAlign, dataPoint.BackGradientType, dataPoint.BackGradientEndColor, dataPoint.BorderColor, dataPoint.BorderWidth, dataPoint.BorderStyle, PenAlignment.Inset, barDrawingStyle, veticalOrientation: true, drawingOperationTypes); graph.StopAnimation(); graph.EndHotRegion(); if (common.ProcessModeRegions && !labels) { common.HotRegionsList.AddHotRegion(graphicsPath, relativePath: false, graph, dataPoint, series.Name, item2.index - 1); } } if (flag2) { graph.ResetClip(); } ProcessSinglePoint3D(item2, selection, graph, common, area, empty, item2.index - 1); } DrawAccumulated3DLabels(graph, common, area); }
public static void PrepareData(Series series, IServiceContainer serviceContainer) { if (string.Compare(series.ChartTypeName, "PointAndFigure", StringComparison.OrdinalIgnoreCase) == 0 && series.IsVisible()) { Chart chart = (Chart)serviceContainer.GetService(typeof(Chart)); if (chart == null) { throw new InvalidOperationException(SR.ExceptionPointAndFigureNullReference); } ChartArea chartArea = chart.ChartAreas[series.ChartArea]; foreach (Series item in chart.Series) { if (item.IsVisible() && item != series && chartArea == chart.ChartAreas[item.ChartArea]) { throw new InvalidOperationException(SR.ExceptionPointAndFigureCanNotCombine); } } if (!PointAndFigureChart.customizeSubscribed) { PointAndFigureChart.customizeSubscribed = true; chart.Customize += PointAndFigureChart.OnCustomize; } string name = "POINTANDFIGURE_ORIGINAL_DATA_" + series.Name; if (chart.Series.GetIndex(name) == -1) { Series series3 = new Series(name, series.YValuesPerPoint); series3.Enabled = false; series3.ShowInLegend = false; series3.YValuesPerPoint = series.YValuesPerPoint; chart.Series.Add(series3); foreach (DataPoint point in series.Points) { series3.Points.Add(point); } series.Points.Clear(); if (series.IsAttributeSet("TempDesignData")) { ((DataPointAttributes)series3)["TempDesignData"] = "true"; } ((DataPointAttributes)series)["OldXValueIndexed"] = series.XValueIndexed.ToString(CultureInfo.InvariantCulture); ((DataPointAttributes)series)["OldYValuesPerPoint"] = series.YValuesPerPoint.ToString(CultureInfo.InvariantCulture); series.XValueIndexed = true; if (series.ChartArea.Length > 0 && series.IsXValueDateTime()) { Axis axis = chartArea.GetAxis(AxisName.X, series.XAxisType, series.XSubAxisName); if (axis.Interval == 0.0 && axis.IntervalType == DateTimeIntervalType.Auto) { bool flag = false; double num = 1.7976931348623157E+308; double num2 = -1.7976931348623157E+308; foreach (DataPoint point2 in series3.Points) { if (!point2.Empty) { if (point2.XValue != 0.0) { flag = true; } if (point2.XValue > num2) { num2 = point2.XValue; } if (point2.XValue < num) { num = point2.XValue; } } } if (flag) { ((DataPointAttributes)series)["OldAutomaticXAxisInterval"] = "true"; DateTimeIntervalType intervalType = DateTimeIntervalType.Auto; axis.interval = ((AxisScale)axis).CalcInterval(num, num2, true, out intervalType, series.XValueType); axis.intervalType = intervalType; } } } PointAndFigureChart.FillPointAndFigureData(series, series3); } } }
private void ProcessChartType(bool labels, bool selection, ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw) { if (area.Area3DStyle.Enable3D) { ProcessChartType3D(labels, selection, graph, common, area, seriesToDraw); return; } SizeF relativeSize = graph.GetRelativeSize(new SizeF(1.1f, 1.1f)); ArrayList seriesFromChartType = area.GetSeriesFromChartType(Name); bool flag = drawSeriesSideBySide; foreach (string item in seriesFromChartType) { if (common.DataManager.Series[item].IsAttributeSet("DrawSideBySide")) { string strA = common.DataManager.Series[item]["DrawSideBySide"]; if (string.Compare(strA, "False", StringComparison.OrdinalIgnoreCase) == 0) { flag = false; } else if (string.Compare(strA, "True", StringComparison.OrdinalIgnoreCase) == 0) { flag = true; } else if (string.Compare(strA, "Auto", StringComparison.OrdinalIgnoreCase) != 0) { throw new InvalidOperationException(SR.ExceptionAttributeDrawSideBySideInvalid); } } } double num = seriesFromChartType.Count; if (!flag) { num = 1.0; } bool flag2 = area.IndexedSeries((string[])area.GetSeriesFromChartType(Name).ToArray(typeof(string))); int num2 = 0; foreach (Series item2 in common.DataManager.Series) { if (string.Compare(item2.ChartTypeName, Name, ignoreCase: true, CultureInfo.CurrentCulture) != 0 || item2.ChartArea != area.Name || item2.Points.Count == 0 || !item2.IsVisible()) { continue; } ShiftedSerName = item2.Name; Axis axis = area.GetAxis(AxisName.Y, item2.YAxisType, item2.YSubAxisName); Axis axis2 = area.GetAxis(AxisName.X, item2.XAxisType, item2.XSubAxisName); double viewMaximum = axis2.GetViewMaximum(); double viewMinimum = axis2.GetViewMinimum(); double viewMaximum2 = axis.GetViewMaximum(); double viewMinimum2 = axis.GetViewMinimum(); double position = axis.GetPosition(axis.Crossing); bool sameInterval = false; double interval = 1.0; if (!flag2) { if (item2.Points.Count == 1 && (item2.XValueType == ChartValueTypes.Date || item2.XValueType == ChartValueTypes.DateTime || item2.XValueType == ChartValueTypes.Time || item2.XValueType == ChartValueTypes.DateTimeOffset)) { area.GetPointsInterval(seriesFromChartType, axis2.Logarithmic, axis2.logarithmBase, checkSameInterval: true, out sameInterval); interval = ((double.IsNaN(axis2.majorGrid.Interval) || axis2.majorGrid.IntervalType == DateTimeIntervalType.NotSet) ? axis2.GetIntervalSize(axis2.minimum, axis2.Interval, axis2.IntervalType) : axis2.GetIntervalSize(axis2.minimum, axis2.majorGrid.Interval, axis2.majorGrid.IntervalType)); } else { interval = area.GetPointsInterval(seriesFromChartType, axis2.Logarithmic, axis2.logarithmBase, checkSameInterval: true, out sameInterval); } } double num3 = item2.GetPointWidth(graph, axis2, interval, 0.8) / num; if (!selection) { common.EventsManager.OnBackPaint(item2, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition)); } int num4 = 0; foreach (DataPoint point in item2.Points) { double num5 = axis.GetLogValue(GetYValue(common, area, item2, point, num4, useTwoValues ? 1 : 0)); if (num5 > viewMaximum2) { num5 = viewMaximum2; } if (num5 < viewMinimum2) { num5 = viewMinimum2; } double num6 = axis.GetLinearPosition(num5); double num7 = 0.0; if (useTwoValues) { double num8 = axis.GetLogValue(GetYValue(common, area, item2, point, num4, 0)); if (num8 > viewMaximum2) { num8 = viewMaximum2; } else if (num8 < viewMinimum2) { num8 = viewMinimum2; } num7 = axis.GetLinearPosition(num8); } else { num7 = position; } num4++; double num9; double position2; if (flag2) { num9 = axis2.GetPosition(num4) - num3 * num / 2.0 + num3 / 2.0 + (double)num2 * num3; position2 = axis2.GetPosition(num4); } else if (sameInterval) { num9 = axis2.GetPosition(point.XValue) - num3 * num / 2.0 + num3 / 2.0 + (double)num2 * num3; position2 = axis2.GetPosition(point.XValue); } else { num9 = axis2.GetPosition(point.XValue); position2 = axis2.GetPosition(point.XValue); } ShiftedX = num9 - position2; if (num6 < num7 && num7 - num6 < (double)relativeSize.Height) { num6 = num7 - (double)relativeSize.Height; } if (num6 > num7 && num6 - num7 < (double)relativeSize.Height) { num6 = num7 + (double)relativeSize.Height; } RectangleF empty = RectangleF.Empty; try { empty.X = (float)(num9 - num3 / 2.0); empty.Width = (float)num3; if (num7 < num6) { empty.Y = (float)num7; empty.Height = (float)num6 - empty.Y; } else { empty.Y = (float)num6; empty.Height = (float)num7 - empty.Y; } } catch (Exception) { continue; } if (point.Empty) { continue; } if (common.ProcessModePaint) { if (!labels) { double yValue = flag2 ? ((double)num4) : point.XValue; yValue = axis2.GetLogValue(yValue); if (yValue < viewMinimum || yValue > viewMaximum) { continue; } bool flag3 = false; if (empty.X < area.PlotAreaPosition.X || empty.Right > area.PlotAreaPosition.Right()) { graph.SetClip(area.PlotAreaPosition.ToRectangleF()); flag3 = true; } graph.StartHotRegion(point); graph.StartAnimation(); DrawColumn2D(graph, axis, empty, point, item2); graph.StopAnimation(); graph.EndHotRegion(); if (flag3) { graph.ResetClip(); } } else if (useTwoValues) { DrawLabel(area, graph, common, empty, point, item2, num4); } } if (common.ProcessModeRegions && !labels) { common.HotRegionsList.AddHotRegion(graph, empty, point, item2.Name, num4 - 1); } } if (!selection) { common.EventsManager.OnPaint(item2, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition)); } if (flag) { num2++; } if (labels && !useTwoValues) { base.ProcessChartType(selection: false, graph, common, area, seriesToDraw); } } }
internal static void PrepareData(Series series, IServiceContainer serviceContainer) { if (string.Compare(series.ChartTypeName, "ThreeLineBreak", StringComparison.OrdinalIgnoreCase) != 0 || !series.IsVisible()) { return; } Chart chart = (Chart)serviceContainer.GetService(typeof(Chart)); if (chart == null) { throw new InvalidOperationException(SR.ExceptionThreeLineBreakNullReference); } ChartArea chartArea = chart.ChartAreas[series.ChartArea]; foreach (Series item in chart.Series) { if (item.IsVisible() && item != series && chartArea == chart.ChartAreas[item.ChartArea]) { throw new InvalidOperationException(SR.ExceptionThreeLineBreakCanNotCobine); } } Series series3 = new Series("THREELINEBREAK_ORIGINAL_DATA_" + series.Name, series.YValuesPerPoint); series3.Enabled = false; series3.ShowInLegend = false; chart.Series.Add(series3); foreach (DataPoint point in series.Points) { series3.Points.Add(point); } series.Points.Clear(); if (series.IsAttributeSet("TempDesignData")) { series3["TempDesignData"] = "true"; } series["OldXValueIndexed"] = series.XValueIndexed.ToString(CultureInfo.InvariantCulture); series["OldYValuesPerPoint"] = series.YValuesPerPoint.ToString(CultureInfo.InvariantCulture); series.ChartType = SeriesChartType.RangeColumn; series.XValueIndexed = true; series.YValuesPerPoint = 2; if (series.ChartArea.Length > 0 && series.IsXValueDateTime()) { Axis axis = chartArea.GetAxis(AxisName.X, series.XAxisType, series.XSubAxisName); if (axis.Interval == 0.0 && axis.IntervalType == DateTimeIntervalType.Auto) { bool flag = false; double num = double.MaxValue; double num2 = double.MinValue; foreach (DataPoint point2 in series3.Points) { if (!point2.Empty) { if (point2.XValue != 0.0) { flag = true; } if (point2.XValue > num2) { num2 = point2.XValue; } if (point2.XValue < num) { num = point2.XValue; } } } if (flag) { series["OldAutomaticXAxisInterval"] = "true"; DateTimeIntervalType type = DateTimeIntervalType.Auto; axis.interval = axis.CalcInterval(num, num2, date: true, out type, series.XValueType); axis.intervalType = type; } } } FillThreeLineBreakData(series, series3); }
/// <summary> /// Remove any changes done while preparing renko chart type for rendering. /// </summary> /// <param name="series">Series to be un-prepared.</param> /// <returns>True if series was removed from collection.</returns> internal static bool UnPrepareData(Series series) { if (series.Name.StartsWith("RENKO_ORIGINAL_DATA_", StringComparison.Ordinal)) { // Get reference to the chart control Chart chart = series.Chart; if (chart == null) { throw (new InvalidOperationException(SR.ExceptionRenkoNullReference)); } // Get original Renko series Series renkoSeries = chart.Series[series.Name.Substring(20)]; Series.MovePositionMarkers(renkoSeries, series); // Copy data back to original Renko series renkoSeries.Points.Clear(); if (!series.IsCustomPropertySet("TempDesignData")) { foreach (DataPoint dp in series.Points) { renkoSeries.Points.Add(dp); } } // Restore renko series properties renkoSeries.ChartType = SeriesChartType.Renko; bool isXValIndexed; bool parseSucceed = bool.TryParse(renkoSeries["OldXValueIndexed"], out isXValIndexed); renkoSeries.IsXValueIndexed = parseSucceed && isXValIndexed; int yValsPerPoint; parseSucceed = int.TryParse(renkoSeries["OldYValuesPerPoint"], NumberStyles.Any, CultureInfo.InvariantCulture, out yValsPerPoint); if (parseSucceed) { renkoSeries.YValuesPerPoint = yValsPerPoint; } renkoSeries.DeleteCustomProperty("OldXValueIndexed"); renkoSeries.DeleteCustomProperty("OldYValuesPerPoint"); series["OldAutomaticXAxisInterval"] = "true"; if (renkoSeries.IsCustomPropertySet("OldAutomaticXAxisInterval")) { renkoSeries.DeleteCustomProperty("OldAutomaticXAxisInterval"); // Reset automatic interval for X axis if (renkoSeries.ChartArea.Length > 0) { // Get X axis connected to the series ChartArea area = chart.ChartAreas[renkoSeries.ChartArea]; Axis xAxis = area.GetAxis(AxisName.X, renkoSeries.XAxisType, renkoSeries.XSubAxisName); xAxis.interval = 0.0; xAxis.intervalType = DateTimeIntervalType.Auto; } } // Remove series from the collection chart.Series.Remove(series); return(true); } // Remove current box size attribute if (series.IsCustomPropertySet("CurrentBoxSize")) { series.DeleteCustomProperty("CurrentBoxSize"); } return(false); }
protected override void GetBottomPointsPosition(CommonElements common, ChartArea area, float axisPosition, ref DataPoint3D firstPoint, ref DataPoint3D secondPoint, PointF thirdPointPosition, PointF fourthPointPosition, out PointF thirdPoint, out PointF fourthPoint) { Axis axis = area.GetAxis(AxisName.Y, firstPoint.dataPoint.series.YAxisType, firstPoint.dataPoint.series.YSubAxisName); Axis axis2 = area.GetAxis(AxisName.X, firstPoint.dataPoint.series.XAxisType, firstPoint.dataPoint.series.XSubAxisName); double yValue = this.GetYValue(area.Common, area, firstPoint.dataPoint.series, firstPoint.dataPoint, firstPoint.index - 1, 0); double num = (double)(float)firstPoint.xPosition; if (yValue >= 0.0) { if (double.IsNaN(this.prevPosY)) { yValue = (double)axisPosition; } else { yValue = axis.GetPosition(this.prevPosY); num = axis2.GetPosition(this.prevPositionX); } } else if (double.IsNaN(this.prevNegY)) { yValue = (double)axisPosition; } else { yValue = axis.GetPosition(this.prevNegY); num = axis2.GetPosition(this.prevPositionX); } thirdPoint = new PointF((float)num, (float)yValue); yValue = this.GetYValue(area.Common, area, secondPoint.dataPoint.series, secondPoint.dataPoint, secondPoint.index - 1, 0); num = (double)(float)secondPoint.xPosition; if (yValue >= 0.0) { if (double.IsNaN(this.prevPosY)) { yValue = (double)axisPosition; } else { yValue = axis.GetPosition(this.prevPosY); num = axis2.GetPosition(this.prevPositionX); } } else if (double.IsNaN(this.prevNegY)) { yValue = (double)axisPosition; } else { yValue = axis.GetPosition(this.prevNegY); num = axis2.GetPosition(this.prevPositionX); } fourthPoint = new PointF((float)num, (float)yValue); if (!float.IsNaN(thirdPointPosition.X)) { thirdPoint.X = (float)((firstPoint.xCenterVal == 0.0) ? firstPoint.xPosition : firstPoint.xCenterVal); thirdPoint.Y = (thirdPointPosition.X - fourthPoint.X) / (thirdPoint.X - fourthPoint.X) * (thirdPoint.Y - fourthPoint.Y) + fourthPoint.Y; thirdPoint.X = thirdPointPosition.X; } if (!float.IsNaN(thirdPointPosition.Y)) { thirdPoint.Y = thirdPointPosition.Y; } if (!float.IsNaN(fourthPointPosition.X)) { fourthPoint.X = (float)((secondPoint.xCenterVal == 0.0) ? secondPoint.xPosition : secondPoint.xCenterVal); fourthPoint.Y = (fourthPointPosition.X - fourthPoint.X) / (thirdPoint.X - fourthPoint.X) * (thirdPoint.Y - fourthPoint.Y) + fourthPoint.Y; fourthPoint.X = fourthPointPosition.X; } if (!float.IsNaN(fourthPointPosition.Y)) { fourthPoint.Y = fourthPointPosition.Y; } }
/// <summary> /// Paint FastLine Chart. /// </summary> /// <param name="graph">The Chart Graphics object.</param> /// <param name="common">The Common elements object.</param> /// <param name="area">Chart area for this chart.</param> /// <param name="seriesToDraw">Chart series to draw.</param> virtual public void Paint( ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw) { this.Common = common; this.Graph = graph; bool clipRegionSet = false; if (area.Area3DStyle.Enable3D) { // Initialize variables this.chartArea3DEnabled = true; matrix3D = area.matrix3D; } else { this.chartArea3DEnabled = false; } //************************************************************ //** Loop through all series //************************************************************ foreach (Series series in common.DataManager.Series) { // Process non empty series of the area with FastLine chart type if (String.Compare(series.ChartTypeName, this.Name, true, System.Globalization.CultureInfo.CurrentCulture) != 0 || series.ChartArea != area.Name || !series.IsVisible()) { continue; } // Get 3D series depth and Z position if (this.chartArea3DEnabled) { float seriesDepth; area.GetSeriesZPositionAndDepth(series, out seriesDepth, out seriesZCoordinate); this.seriesZCoordinate += seriesDepth / 2.0f; } // Set active horizontal/vertical axis Axis hAxis = area.GetAxis(AxisName.X, series.XAxisType, (area.Area3DStyle.Enable3D) ? string.Empty : series.XSubAxisName); Axis vAxis = area.GetAxis(AxisName.Y, series.YAxisType, (area.Area3DStyle.Enable3D) ? string.Empty : series.YSubAxisName); double hAxisMin = hAxis.ViewMinimum; double hAxisMax = hAxis.ViewMaximum; double vAxisMin = vAxis.ViewMinimum; double vAxisMax = vAxis.ViewMaximum; // Get "PermittedPixelError" attribute float permittedPixelError = 1.0f; if (series.IsCustomPropertySet(CustomPropertyName.PermittedPixelError)) { string attrValue = series[CustomPropertyName.PermittedPixelError]; float pixelError; bool parseSucceed = float.TryParse(attrValue, NumberStyles.Any, CultureInfo.CurrentCulture, out pixelError); if (parseSucceed) { permittedPixelError = pixelError; } else { throw (new InvalidOperationException(SR.ExceptionCustomAttributeValueInvalid2("PermittedPixelError"))); } // "PermittedPixelError" attribute value should be in range from zero to 1 if (permittedPixelError < 0f || permittedPixelError > 1f) { throw (new InvalidOperationException(SR.ExceptionCustomAttributeIsNotInRange0to1("PermittedPixelError"))); } } // Get pixel size in axes coordinates SizeF pixelSize = graph.GetRelativeSize(new SizeF(permittedPixelError, permittedPixelError)); SizeF axesMin = graph.GetRelativeSize(new SizeF((float)hAxisMin, (float)vAxisMin)); double axesValuesPixelSizeX = Math.Abs(hAxis.PositionToValue(axesMin.Width + pixelSize.Width, false) - hAxis.PositionToValue(axesMin.Width, false)); // Create line pen Pen linePen = new Pen(series.Color, series.BorderWidth); linePen.DashStyle = graph.GetPenStyle(series.BorderDashStyle); linePen.StartCap = LineCap.Round; linePen.EndCap = LineCap.Round; // Create empty line pen Pen emptyLinePen = new Pen(series.EmptyPointStyle.Color, series.EmptyPointStyle.BorderWidth); emptyLinePen.DashStyle = graph.GetPenStyle(series.EmptyPointStyle.BorderDashStyle); emptyLinePen.StartCap = LineCap.Round; emptyLinePen.EndCap = LineCap.Round; // Check if series is indexed bool indexedSeries = ChartHelper.IndexedSeries(this.Common, series.Name); // Loop through all ponts in the series int index = 0; double yValueRangeMin = double.NaN; double yValueRangeMax = double.NaN; DataPoint pointRangeMin = null; DataPoint pointRangeMax = null; double xValue = 0; double yValue = 0; double xValuePrev = 0; double yValuePrev = 0; DataPoint prevDataPoint = null; PointF lastVerticalSegmentPoint = PointF.Empty; PointF prevPoint = PointF.Empty; PointF currentPoint = PointF.Empty; bool prevPointInAxesCoordinates = false; bool verticalLineDetected = false; bool prevPointIsEmpty = false; bool currentPointIsEmpty = false; bool firstNonEmptyPoint = false; double xPixelConverter = (graph.Common.ChartPicture.Width - 1.0) / 100.0; double yPixelConverter = (graph.Common.ChartPicture.Height - 1.0) / 100.0; foreach (DataPoint point in series.Points) { // Get point X and Y values xValue = (indexedSeries) ? index + 1 : point.XValue; xValue = hAxis.GetLogValue(xValue); yValue = vAxis.GetLogValue(point.YValues[0]); currentPointIsEmpty = point.IsEmpty; // NOTE: Fixes issue #7094 // If current point is non-empty but the previous one was, // use empty point style properties to draw it. if (prevPointIsEmpty && !currentPointIsEmpty && !firstNonEmptyPoint) { firstNonEmptyPoint = true; currentPointIsEmpty = true; } else { firstNonEmptyPoint = false; } // Check if line is completly out of the data scaleView if (!verticalLineDetected && ((xValue < hAxisMin && xValuePrev < hAxisMin) || (xValue > hAxisMax && xValuePrev > hAxisMax) || (yValue < vAxisMin && yValuePrev < vAxisMin) || (yValue > vAxisMax && yValuePrev > vAxisMax))) { xValuePrev = xValue; yValuePrev = yValue; prevPointInAxesCoordinates = true; ++index; continue; } else if (!clipRegionSet) { // Check if line is partialy in the data scaleView if (xValuePrev < hAxisMin || xValuePrev > hAxisMax || xValue > hAxisMax || xValue < hAxisMin || yValuePrev < vAxisMin || yValuePrev > vAxisMax || yValue < vAxisMin || yValue > vAxisMax) { // Set clipping region for line drawing graph.SetClip(area.PlotAreaPosition.ToRectangleF()); clipRegionSet = true; } } // Check if point may be skipped if (index > 0 && currentPointIsEmpty == prevPointIsEmpty) { // Check if points X value in acceptable error boundary if (Math.Abs(xValue - xValuePrev) < axesValuesPixelSizeX) { if (!verticalLineDetected) { verticalLineDetected = true; if (yValue > yValuePrev) { yValueRangeMax = yValue; yValueRangeMin = yValuePrev; pointRangeMax = point; pointRangeMin = prevDataPoint; } else { yValueRangeMax = yValuePrev; yValueRangeMin = yValue; pointRangeMax = prevDataPoint; pointRangeMin = point; } // NOTE: Prev. version code - A.G. // yValueRangeMin = Math.Min(yValue, yValuePrev); // yValueRangeMax = Math.Max(yValue, yValuePrev); } else { if (yValue > yValueRangeMax) { yValueRangeMax = yValue; pointRangeMax = point; } else if (yValue < yValueRangeMin) { yValueRangeMin = yValue; pointRangeMin = point; } // NOTE: Prev. version code - A.G. // yValueRangeMin = Math.Min(yValue, yValueRangeMin); // yValueRangeMax = Math.Max(yValue, yValueRangeMax); } // Remember last point prevDataPoint = point; // Remember last vertical range point // Note! Point is in axes coordinate. lastVerticalSegmentPoint.Y = (float)yValue; // Increase counter and proceed to next data point ++index; continue; } } // Get point pixel position currentPoint.X = (float) (hAxis.GetLinearPosition(xValue) * xPixelConverter); currentPoint.Y = (float) (vAxis.GetLinearPosition(yValue) * yPixelConverter); // Check if previous point must be converted from axes values to pixels if (prevPointInAxesCoordinates) { prevPoint.X = (float) (hAxis.GetLinearPosition(xValuePrev) * xPixelConverter); prevPoint.Y = (float) (vAxis.GetLinearPosition(yValuePrev) * yPixelConverter); } // Draw accumulated vertical line (with minimal X values differences) if (verticalLineDetected) { // Convert Y coordinates to pixels yValueRangeMin = (vAxis.GetLinearPosition(yValueRangeMin) * yPixelConverter); yValueRangeMax = (vAxis.GetLinearPosition(yValueRangeMax) * yPixelConverter); // Draw accumulated vertical line DrawLine( series, prevDataPoint, pointRangeMin, pointRangeMax, index, (prevPointIsEmpty) ? emptyLinePen : linePen, prevPoint.X, (float)yValueRangeMin, prevPoint.X, (float)yValueRangeMax); // Reset vertical line detected flag verticalLineDetected = false; // Convert last point of the vertical line segment to pixel coordinates prevPoint.Y = (float) (vAxis.GetLinearPosition(lastVerticalSegmentPoint.Y) * yPixelConverter); } // Draw line from previous to current point if (index > 0) { DrawLine( series, point, pointRangeMin, pointRangeMax, index, (currentPointIsEmpty) ? emptyLinePen : linePen, prevPoint.X, prevPoint.Y, currentPoint.X, currentPoint.Y); } // Remember last point coordinates xValuePrev = xValue; yValuePrev = yValue; prevDataPoint = point; prevPoint = currentPoint; prevPointInAxesCoordinates = false; prevPointIsEmpty = currentPointIsEmpty; ++index; } // Draw last accumulated line segment if (verticalLineDetected) { // Check if previous point must be converted from axes values to pixels if (prevPointInAxesCoordinates) { prevPoint.X = (float) (hAxis.GetLinearPosition(xValuePrev) * xPixelConverter); prevPoint.Y = (float) (vAxis.GetLinearPosition(yValuePrev) * yPixelConverter); } // Convert Y coordinates to pixels yValueRangeMin = (vAxis.GetLinearPosition(yValueRangeMin) * yPixelConverter); yValueRangeMax = (vAxis.GetLinearPosition(yValueRangeMax) * yPixelConverter); // Draw accumulated vertical line DrawLine( series, prevDataPoint, pointRangeMin, pointRangeMax, index - 1, (prevPointIsEmpty) ? emptyLinePen : linePen, prevPoint.X, (float)yValueRangeMin, prevPoint.X, (float)yValueRangeMax); verticalLineDetected = false; yValueRangeMin = double.NaN; yValueRangeMax = double.NaN; pointRangeMin = null; pointRangeMax = null; } } // Reset Clip Region if (clipRegionSet) { graph.ResetClip(); } }
protected override void ProcessChartType(bool selection, ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw) { ArrayList arrayList = null; ArrayList arrayList2 = null; if (area.Area3DStyle.Enable3D) { base.ProcessChartType(selection, graph, common, area, seriesToDraw); } else { bool flag = area.IndexedSeries((string[])area.GetSeriesFromChartType(this.Name).ToArray(typeof(string))); bool flag2 = false; bool flag3 = false; int num = -1; PointF absolutePoint; foreach (Series item in common.DataManager.Series) { if (string.Compare(item.ChartTypeName, this.Name, StringComparison.OrdinalIgnoreCase) == 0 && !(item.ChartArea != area.Name) && item.IsVisible()) { if (base.areaPath != null) { base.areaPath.Dispose(); base.areaPath = null; } this.areaBottomPath.Reset(); if (num == -1) { num = item.Points.Count; } else if (num != item.Points.Count) { throw new ArgumentException(SR.ExceptionStackedAreaChartSeriesDataPointsNumberMismatch); } base.hAxis = area.GetAxis(AxisName.X, item.XAxisType, item.XSubAxisName); base.vAxis = area.GetAxis(AxisName.Y, item.YAxisType, item.YSubAxisName); base.hAxisMin = base.hAxis.GetViewMinimum(); base.hAxisMax = base.hAxis.GetViewMaximum(); base.vAxisMin = base.vAxis.GetViewMinimum(); base.vAxisMax = base.vAxis.GetViewMaximum(); base.axisPos.X = (float)base.vAxis.GetPosition(base.vAxis.Crossing); base.axisPos.Y = (float)base.vAxis.GetPosition(base.vAxis.Crossing); base.axisPos = graph.GetAbsolutePoint(base.axisPos); if (arrayList2 == null) { arrayList2 = new ArrayList(item.Points.Count); } else { arrayList = arrayList2; arrayList2 = new ArrayList(item.Points.Count); } if (!selection) { common.EventsManager.OnBackPaint(item, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition)); } int num2 = 0; float num3 = base.axisPos.Y; float y = base.axisPos.Y; PointF pointF = PointF.Empty; PointF pointF2 = PointF.Empty; foreach (DataPoint point in item.Points) { point.positionRel = new PointF(float.NaN, float.NaN); double num4 = point.Empty ? 0.0 : this.GetYValue(common, area, item, point, num2, 0); double num5 = flag ? ((double)num2 + 1.0) : point.XValue; if (arrayList != null && num2 < arrayList.Count) { num4 += (double)arrayList[num2]; } arrayList2.Insert(num2, num4); float y2 = (float)base.vAxis.GetPosition(num4); float x = (float)base.hAxis.GetPosition(num5); point.positionRel = new PointF(x, y2); num4 = base.vAxis.GetLogValue(num4); num5 = base.hAxis.GetLogValue(num5); if (pointF == PointF.Empty) { pointF.X = x; pointF.Y = y2; if (arrayList != null && num2 < arrayList.Count) { num3 = (float)base.vAxis.GetPosition((double)arrayList[num2]); absolutePoint = graph.GetAbsolutePoint(new PointF(num3, num3)); num3 = absolutePoint.Y; } pointF = graph.GetAbsolutePoint(pointF); num2++; } else { pointF2.X = x; pointF2.Y = y2; if (arrayList != null && num2 < arrayList.Count) { y = (float)base.vAxis.GetPosition((double)arrayList[num2]); absolutePoint = graph.GetAbsolutePoint(new PointF(y, y)); y = absolutePoint.Y; } pointF2 = graph.GetAbsolutePoint(pointF2); pointF.X = (float)Math.Round((double)pointF.X); pointF2.X = (float)Math.Round((double)pointF2.X); GraphicsPath graphicsPath = new GraphicsPath(); graphicsPath.AddLine(pointF.X, pointF.Y, pointF2.X, pointF2.Y); graphicsPath.AddLine(pointF2.X, pointF2.Y, pointF2.X, y); graphicsPath.AddLine(pointF2.X, y, pointF.X, num3); graphicsPath.AddLine(pointF.X, num3, pointF.X, pointF.Y); if (common.ProcessModePaint) { if (!point.Empty) { this.GetYValue(common, area, item, item.Points[num2 - 1], num2 - 1, 0); } double num6 = flag ? ((double)num2) : item.Points[num2 - 1].XValue; if (num5 <= base.hAxisMin && num6 <= base.hAxisMin) { goto IL_053b; } if (num5 >= base.hAxisMax && num6 >= base.hAxisMax) { goto IL_053b; } Brush brush = null; if (point.BackHatchStyle != 0) { brush = graph.GetHatchBrush(point.BackHatchStyle, point.Color, point.BackGradientEndColor); } else if (point.BackGradientType != 0) { base.gradientFill = true; base.series = point.series; } else { brush = ((point.BackImage.Length <= 0 || point.BackImageMode == ChartImageWrapMode.Unscaled || point.BackImageMode == ChartImageWrapMode.Scaled) ? ((!point.Empty || !(point.Color == Color.Empty)) ? new SolidBrush(point.Color) : new SolidBrush(item.Color)) : graph.GetTextureBrush(point.BackImage, point.BackImageTransparentColor, point.BackImageMode, point.Color)); } if (point.BorderColor != Color.Empty && point.BorderWidth > 0) { flag2 = true; } if (point.Label.Length > 0 || point.ShowLabelAsValue) { flag3 = true; } if (!base.gradientFill) { graph.StartAnimation(); graph.StartHotRegion(point); SmoothingMode smoothingMode = graph.SmoothingMode; graph.SmoothingMode = SmoothingMode.None; graph.FillPath(brush, graphicsPath); graph.SmoothingMode = smoothingMode; Pen pen = new Pen(brush, 1f); if (pointF.X != pointF2.X && pointF.Y != pointF2.Y) { graph.DrawLine(pen, pointF.X, pointF.Y, pointF2.X, pointF2.Y); } if (pointF.X != pointF2.X && y != num3) { graph.DrawLine(pen, pointF2.X, y, pointF.X, num3); } graph.EndHotRegion(); graph.StopAnimation(); } if (base.areaPath == null) { base.areaPath = new GraphicsPath(); } base.areaPath.AddLine(pointF.X, pointF.Y, pointF2.X, pointF2.Y); this.areaBottomPath.AddLine(pointF.X, num3, pointF2.X, y); } if (common.ProcessModeRegions) { PointF pointF3 = PointF.Empty; float[] array = new float[graphicsPath.PointCount * 2]; PointF[] pathPoints = graphicsPath.PathPoints; for (int i = 0; i < graphicsPath.PointCount; i++) { pointF3 = graph.GetRelativePoint(pathPoints[i]); array[2 * i] = pointF3.X; array[2 * i + 1] = pointF3.Y; } common.HotRegionsList.AddHotRegion(graph, graphicsPath, false, array, point, item.Name, num2); if (point.BorderWidth > 1 && point.BorderStyle != 0 && point.BorderColor != Color.Empty) { GraphicsPath graphicsPath2 = new GraphicsPath(); graphicsPath2.AddLine(pointF.X, pointF.Y, pointF2.X, pointF2.Y); ChartGraphics.Widen(graphicsPath2, new Pen(point.Color, (float)(point.BorderWidth + 2))); pointF3 = PointF.Empty; array = new float[graphicsPath2.PointCount * 2]; for (int j = 0; j < graphicsPath2.PointCount; j++) { pointF3 = graph.GetRelativePoint(graphicsPath2.PathPoints[j]); array[2 * j] = pointF3.X; array[2 * j + 1] = pointF3.Y; } common.HotRegionsList.AddHotRegion(graph, graphicsPath2, false, array, point, item.Name, num2); } } pointF = pointF2; num3 = y; num2++; } continue; IL_053b: pointF = pointF2; num3 = y; num2++; } if (base.gradientFill && base.areaPath != null) { GraphicsPath graphicsPath3 = new GraphicsPath(); graphicsPath3.AddPath(base.areaPath, true); this.areaBottomPath.Reverse(); graphicsPath3.AddPath(this.areaBottomPath, true); Brush gradientBrush = graph.GetGradientBrush(graphicsPath3.GetBounds(), base.series.Color, base.series.BackGradientEndColor, base.series.BackGradientType); graph.FillPath(gradientBrush, graphicsPath3); base.areaPath.Dispose(); base.areaPath = null; base.gradientFill = false; } this.areaBottomPath.Reset(); if (!selection) { common.EventsManager.OnPaint(item, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition)); } } } if (flag2) { arrayList = null; arrayList2 = null; foreach (Series item2 in common.DataManager.Series) { if (string.Compare(item2.ChartTypeName, this.Name, StringComparison.OrdinalIgnoreCase) == 0 && !(item2.ChartArea != area.Name) && item2.IsVisible()) { base.hAxis = area.GetAxis(AxisName.X, item2.XAxisType, item2.XSubAxisName); base.vAxis = area.GetAxis(AxisName.Y, item2.YAxisType, item2.YSubAxisName); base.axisPos.X = (float)base.vAxis.GetPosition(base.vAxis.Crossing); base.axisPos.Y = (float)base.vAxis.GetPosition(base.vAxis.Crossing); base.axisPos = graph.GetAbsolutePoint(base.axisPos); if (arrayList2 == null) { arrayList2 = new ArrayList(item2.Points.Count); } else { arrayList = arrayList2; arrayList2 = new ArrayList(item2.Points.Count); } int num7 = 0; float num8 = base.axisPos.Y; float num9 = base.axisPos.Y; PointF pointF4 = PointF.Empty; PointF pointF5 = PointF.Empty; foreach (DataPoint point2 in item2.Points) { double num10 = point2.Empty ? 0.0 : this.GetYValue(common, area, item2, point2, num7, 0); double axisValue = flag ? ((double)num7 + 1.0) : point2.XValue; if (arrayList != null && num7 < arrayList.Count) { num10 += (double)arrayList[num7]; } arrayList2.Insert(num7, num10); float y3 = (float)base.vAxis.GetPosition(num10); float x2 = (float)base.hAxis.GetPosition(axisValue); if (pointF4 == PointF.Empty) { pointF4.X = x2; pointF4.Y = y3; if (arrayList != null && num7 < arrayList.Count) { num8 = (float)base.vAxis.GetPosition((double)arrayList[num7]); absolutePoint = graph.GetAbsolutePoint(new PointF(num8, num8)); num8 = absolutePoint.Y; } pointF4 = graph.GetAbsolutePoint(pointF4); pointF5 = pointF4; num9 = num8; } else { pointF5.X = x2; pointF5.Y = y3; if (arrayList != null && num7 < arrayList.Count) { num9 = (float)base.vAxis.GetPosition((double)arrayList[num7]); absolutePoint = graph.GetAbsolutePoint(new PointF(num9, num9)); num9 = absolutePoint.Y; } pointF5 = graph.GetAbsolutePoint(pointF5); } if (num7 != 0) { pointF4.X = (float)Math.Round((double)pointF4.X); pointF5.X = (float)Math.Round((double)pointF5.X); graph.StartAnimation(); graph.DrawLineRel(point2.BorderColor, point2.BorderWidth, point2.BorderStyle, graph.GetRelativePoint(pointF4), graph.GetRelativePoint(pointF5), point2.series.ShadowColor, point2.series.ShadowOffset); graph.StopAnimation(); } pointF4 = pointF5; num8 = num9; num7++; } } } } if (flag3) { arrayList = null; arrayList2 = null; foreach (Series item3 in common.DataManager.Series) { if (string.Compare(item3.ChartTypeName, this.Name, StringComparison.OrdinalIgnoreCase) == 0 && !(item3.ChartArea != area.Name) && item3.IsVisible()) { base.hAxis = area.GetAxis(AxisName.X, item3.XAxisType, item3.XSubAxisName); base.vAxis = area.GetAxis(AxisName.Y, item3.YAxisType, item3.YSubAxisName); base.axisPos.X = (float)base.vAxis.GetPosition(base.vAxis.Crossing); base.axisPos.Y = (float)base.vAxis.GetPosition(base.vAxis.Crossing); base.axisPos = graph.GetAbsolutePoint(base.axisPos); if (arrayList2 == null) { arrayList2 = new ArrayList(item3.Points.Count); } else { arrayList = arrayList2; arrayList2 = new ArrayList(item3.Points.Count); } int num11 = 0; float num12 = base.axisPos.Y; float num13 = base.axisPos.Y; PointF pointF6 = PointF.Empty; PointF pointF7 = PointF.Empty; foreach (DataPoint point3 in item3.Points) { double num14 = point3.Empty ? 0.0 : this.GetYValue(common, area, item3, point3, num11, 0); double axisValue2 = flag ? ((double)num11 + 1.0) : point3.XValue; if (arrayList != null && num11 < arrayList.Count) { num14 += (double)arrayList[num11]; } arrayList2.Insert(num11, num14); float y4 = (float)base.vAxis.GetPosition(num14); float x3 = (float)base.hAxis.GetPosition(axisValue2); if (pointF6 == PointF.Empty) { pointF6.X = x3; pointF6.Y = y4; if (arrayList != null && num11 < arrayList.Count) { num12 = (float)base.vAxis.GetPosition((double)arrayList[num11]); absolutePoint = graph.GetAbsolutePoint(new PointF(num12, num12)); num12 = absolutePoint.Y; } pointF6 = graph.GetAbsolutePoint(pointF6); pointF7 = pointF6; num13 = num12; } else { pointF7.X = x3; pointF7.Y = y4; if (arrayList != null && num11 < arrayList.Count) { num13 = (float)base.vAxis.GetPosition((double)arrayList[num11]); absolutePoint = graph.GetAbsolutePoint(new PointF(num13, num13)); num13 = absolutePoint.Y; } pointF7 = graph.GetAbsolutePoint(pointF7); } if (!point3.Empty && (item3.ShowLabelAsValue || point3.ShowLabelAsValue || point3.Label.Length > 0)) { StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; string text; if (point3.Label.Length == 0) { double value = this.GetYValue(common, area, item3, point3, num11, 0); if (this.hundredPercentStacked && point3.LabelFormat.Length == 0) { value = Math.Round(value, 2); } text = ValueConverter.FormatValue(item3.chart, point3, value, point3.LabelFormat, item3.YValueType, ChartElementType.DataPoint); } else { text = point3.ReplaceKeywords(point3.Label); if (item3.chart != null && item3.chart.LocalizeTextHandler != null) { text = item3.chart.LocalizeTextHandler(point3, text, point3.ElementId, ChartElementType.DataPoint); } } Region clip = graph.Clip; graph.Clip = new Region(); graph.StartAnimation(); PointF pointF8 = PointF.Empty; pointF8.X = pointF7.X; pointF8.Y = (float)(pointF7.Y - (pointF7.Y - num13) / 2.0); pointF8 = graph.GetRelativePoint(pointF8); SizeF relativeSize = graph.GetRelativeSize(graph.MeasureString(text, point3.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic))); RectangleF empty = RectangleF.Empty; SizeF sizeF = new SizeF(relativeSize.Width, relativeSize.Height); sizeF.Height += (float)(relativeSize.Height / 8.0); sizeF.Width += sizeF.Width / (float)text.Length; empty = new RectangleF((float)(pointF8.X - sizeF.Width / 2.0), (float)(pointF8.Y - sizeF.Height / 2.0 - relativeSize.Height / 10.0), sizeF.Width, sizeF.Height); graph.DrawPointLabelStringRel(common, text, point3.Font, new SolidBrush(point3.FontColor), pointF8, stringFormat, point3.FontAngle, empty, point3.LabelBackColor, point3.LabelBorderColor, point3.LabelBorderWidth, point3.LabelBorderStyle, item3, point3, num11); graph.StopAnimation(); graph.Clip = clip; } pointF6 = pointF7; num12 = num13; num11++; } } } } } }
public virtual double GetYValue(CommonElements common, ChartArea area, Series series, DataPoint point, int pointIndex, int yValueIndex) { double num = double.NaN; if (area.Area3DStyle.Enable3D) { switch (yValueIndex) { case -2: break; case -1: { double crossing = area.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName).Crossing; num = GetYValue(common, area, series, point, pointIndex, 0); if (num >= 0.0) { if (!double.IsNaN(prevPosY)) { crossing = prevPosY; } } else if (!double.IsNaN(prevNegY)) { crossing = prevNegY; } return(num - crossing); } default: prevPosY = double.NaN; prevNegY = double.NaN; { foreach (Series item in common.DataManager.Series) { if (string.Compare(series.ChartArea, item.ChartArea, StringComparison.Ordinal) != 0 || string.Compare(series.ChartTypeName, item.ChartTypeName, StringComparison.OrdinalIgnoreCase) != 0 || !item.IsVisible()) { continue; } string seriesStackGroupName = GetSeriesStackGroupName(item); if (stackGroupNameUsed && seriesStackGroupName != currentStackGroup) { continue; } if (double.IsNaN(num)) { num = item.Points[pointIndex].YValues[0]; } else { num = item.Points[pointIndex].YValues[0]; if (num >= 0.0 && !double.IsNaN(prevPosY)) { num += prevPosY; } if (num < 0.0 && !double.IsNaN(prevNegY)) { num += prevNegY; } } if (string.Compare(series.Name, item.Name, StringComparison.Ordinal) != 0) { if (num >= 0.0) { prevPosY = num; } if (num < 0.0) { prevNegY = num; } continue; } return(num); } return(num); } } } return(point.YValues[0]); }
public override double GetYValue(CommonElements common, ChartArea area, Series series, DataPoint point, int pointIndex, int yValueIndex) { double num = double.NaN; if (!area.Area3DStyle.Enable3D) { return(point.YValues[0]); } if (yValueIndex == -1) { Axis axis = area.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName); double crossing = axis.Crossing; num = this.GetYValue(common, area, series, point, pointIndex, 0); if (area.Area3DStyle.Enable3D && num < 0.0) { num = 0.0 - num; } if (num >= 0.0) { if (!double.IsNaN(this.prevPosY)) { crossing = this.prevPosY; } } else if (!double.IsNaN(this.prevNegY)) { crossing = this.prevNegY; } return(num - crossing); } this.prevPosY = double.NaN; this.prevNegY = double.NaN; this.prevPositionX = double.NaN; foreach (Series item in common.DataManager.Series) { if (string.Compare(series.ChartArea, item.ChartArea, StringComparison.Ordinal) == 0 && string.Compare(series.ChartTypeName, item.ChartTypeName, StringComparison.OrdinalIgnoreCase) == 0 && item.IsVisible()) { num = item.Points[pointIndex].YValues[0]; if (area.Area3DStyle.Enable3D && num < 0.0) { num = 0.0 - num; } if (!double.IsNaN(num)) { if (num >= 0.0 && !double.IsNaN(this.prevPosY)) { num += this.prevPosY; } if (num < 0.0 && !double.IsNaN(this.prevNegY)) { num += this.prevNegY; } } if (string.Compare(series.Name, item.Name, StringComparison.Ordinal) != 0) { if (num >= 0.0) { this.prevPosY = num; } if (num < 0.0) { this.prevNegY = num; } this.prevPositionX = item.Points[pointIndex].XValue; if (this.prevPositionX == 0.0 && ChartElement.IndexedSeries(series)) { this.prevPositionX = (double)(pointIndex + 1); } continue; } return(num); } } return(num); }
private void ProcessChartType(bool selection, ChartGraphics graph, CommonElements common, ChartArea area, bool shadow, bool labels, Series seriesToDraw) { bool flag = false; AxisType axisType = AxisType.Primary; AxisType axisType2 = AxisType.Primary; string a = string.Empty; string a2 = string.Empty; for (int i = 0; i < common.DataManager.Series.Count; i++) { Series series = common.DataManager.Series[i]; if (string.Compare(series.ChartTypeName, Name, StringComparison.OrdinalIgnoreCase) == 0 && !(series.ChartArea != area.Name) && series.IsVisible()) { if (i == 0) { axisType = series.XAxisType; axisType2 = series.YAxisType; a = series.XSubAxisName; a2 = series.YSubAxisName; } else if (axisType != series.XAxisType || axisType2 != series.YAxisType || a != series.XSubAxisName || a2 != series.YSubAxisName) { flag = true; break; } } } if (flag) { for (int j = 0; j < common.DataManager.Series.Count; j++) { Series series2 = common.DataManager.Series[j]; if (string.Compare(series2.ChartTypeName, Name, StringComparison.OrdinalIgnoreCase) == 0 && !(series2.ChartArea != area.Name) && series2.IsVisible()) { string seriesStackGroupName = GetSeriesStackGroupName(series2); seriesStackGroupName = (series2["StackedGroupName"] = "_X_" + series2.XAxisType.ToString() + series2.XSubAxisName + "_Y_" + series2.YAxisType.ToString() + series2.YSubAxisName + "__"); } } } stackGroupNames = new ArrayList(); foreach (Series item in common.DataManager.Series) { if (string.Compare(item.ChartTypeName, Name, StringComparison.OrdinalIgnoreCase) == 0 && !(item.ChartArea != area.Name) && item.IsVisible()) { string seriesStackGroupName2 = GetSeriesStackGroupName(item); if (!stackGroupNames.Contains(seriesStackGroupName2)) { stackGroupNames.Add(seriesStackGroupName2); } } } if (area.Area3DStyle.Enable3D) { if (!shadow) { ProcessChartType3D(selection, graph, common, area, labels, seriesToDraw); } return; } string[] series4 = (string[])area.GetSeriesFromChartType(Name).ToArray(typeof(string)); int numberOfPoints = common.DataManager.GetNumberOfPoints(series4); bool flag2 = area.IndexedSeries(series4); for (int k = 0; k < numberOfPoints; k++) { for (int l = 0; l < stackGroupNames.Count; l++) { currentStackGroup = (string)stackGroupNames[l]; int num = 0; double num2 = 0.0; double num3 = 0.0; foreach (Series item2 in common.DataManager.Series) { if (string.Compare(item2.ChartTypeName, Name, StringComparison.OrdinalIgnoreCase) != 0 || item2.ChartArea != area.Name || !item2.IsVisible() || k >= item2.Points.Count || GetSeriesStackGroupName(item2) != currentStackGroup) { continue; } DataPoint dataPoint = item2.Points[k]; dataPoint.positionRel = new PointF(float.NaN, float.NaN); Axis axis = area.GetAxis(AxisName.Y, item2.YAxisType, item2.YSubAxisName); Axis axis2 = area.GetAxis(AxisName.X, item2.XAxisType, item2.XSubAxisName); bool sameInterval = false; double interval = 1.0; if (!flag2) { if (item2.Points.Count == 1 && (item2.XValueType == ChartValueTypes.Date || item2.XValueType == ChartValueTypes.DateTime || item2.XValueType == ChartValueTypes.Time || item2.XValueType == ChartValueTypes.DateTimeOffset)) { ArrayList seriesFromChartType = area.GetSeriesFromChartType(Name); area.GetPointsInterval(seriesFromChartType, axis2.Logarithmic, axis2.logarithmBase, checkSameInterval: true, out sameInterval); interval = ((double.IsNaN(axis2.majorGrid.Interval) || axis2.majorGrid.IntervalType == DateTimeIntervalType.NotSet) ? axis2.GetIntervalSize(axis2.minimum, axis2.Interval, axis2.IntervalType) : axis2.GetIntervalSize(axis2.minimum, axis2.majorGrid.Interval, axis2.majorGrid.IntervalType)); } else { interval = area.GetPointsInterval(axis2.Logarithmic, axis2.logarithmBase); } } double pointWidth = item2.GetPointWidth(graph, axis2, interval, 0.8); pointWidth /= (double)stackGroupNames.Count; if (!selection) { common.EventsManager.OnBackPaint(item2, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition)); } double num4 = GetYValue(common, area, item2, dataPoint, k, 0); if (num != 0) { num4 = ((!(num4 >= 0.0)) ? (num4 + num3) : (num4 + num2)); } bool flag3 = false; double num5 = num4; num4 = axis.GetLogValue(num4); if (!(flag3 && labels)) { if (num4 > axis.GetViewMaximum()) { num4 = axis.GetViewMaximum(); } if (num4 < axis.GetViewMinimum()) { num4 = axis.GetViewMinimum(); } } double linearPosition = axis.GetLinearPosition(num4); double num6 = 0.0; num6 = ((num == 0) ? ((!(flag3 && labels)) ? axis.Crossing : 0.0) : ((!(GetYValue(common, area, item2, dataPoint, k, 0) >= 0.0)) ? num3 : num2)); double position = axis.GetPosition(num6); double num7 = dataPoint.XValue; if (flag2) { num7 = (double)k + 1.0; } double num8 = axis2.GetPosition(num7); if (stackGroupNames.Count > 1) { num8 = num8 - pointWidth * (double)stackGroupNames.Count / 2.0 + pointWidth / 2.0 + (double)l * pointWidth; } num7 = axis2.GetLogValue(num7); RectangleF empty = RectangleF.Empty; try { empty.X = (float)(num8 - pointWidth / 2.0); empty.Width = (float)pointWidth; if (position < linearPosition) { empty.Y = (float)position; empty.Height = (float)linearPosition - empty.Y; } else { empty.Y = (float)linearPosition; empty.Height = (float)position - empty.Y; } } catch (Exception) { num++; continue; } dataPoint.positionRel = new PointF((float)num8, empty.Top); if (dataPoint.Empty) { num++; continue; } if (common.ProcessModePaint) { bool flag4 = false; if (num7 < axis2.GetViewMinimum() || num7 > axis2.GetViewMaximum() || (num4 < axis.GetViewMinimum() && num6 < axis.GetViewMinimum()) || (num4 > axis.GetViewMaximum() && num6 > axis.GetViewMaximum())) { flag4 = true; } if (!flag4) { int num9 = 0; if (shadow) { num9 = item2.ShadowOffset; } if (!labels) { bool flag5 = false; if (empty.X < area.PlotAreaPosition.X || empty.Right > area.PlotAreaPosition.Right() || empty.Y < area.PlotAreaPosition.Y || empty.Bottom > area.PlotAreaPosition.Bottom()) { graph.SetClip(area.PlotAreaPosition.ToRectangleF()); flag5 = true; } graph.StartHotRegion(dataPoint); graph.StartAnimation(); if (!shadow || num9 != 0) { graph.FillRectangleRel(empty, (!shadow) ? dataPoint.Color : Color.Transparent, dataPoint.BackHatchStyle, dataPoint.BackImage, dataPoint.BackImageMode, dataPoint.BackImageTransparentColor, dataPoint.BackImageAlign, dataPoint.BackGradientType, (!shadow) ? dataPoint.BackGradientEndColor : Color.Transparent, dataPoint.BorderColor, dataPoint.BorderWidth, dataPoint.BorderStyle, item2.ShadowColor, num9, PenAlignment.Inset, (!shadow) ? ChartGraphics.GetBarDrawingStyle(dataPoint) : BarDrawingStyle.Default, isVertical: true); } graph.StopAnimation(); graph.EndHotRegion(); if (flag5) { graph.ResetClip(); } } else { graph.StartAnimation(); DrawLabels(common, graph, area, dataPoint, k, item2, empty); graph.StopAnimation(); } } } if (common.ProcessModeRegions && !shadow && !labels) { common.HotRegionsList.AddHotRegion(graph, empty, dataPoint, item2.Name, k); } if (!selection) { common.EventsManager.OnPaint(item2, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition)); } if (axis.Logarithmic) { num4 = Math.Pow(axis.logarithmBase, num4); } num++; if (GetYValue(common, area, item2, dataPoint, k, 0) >= 0.0) { num2 = num5; } else { num3 = num5; } } } } if (!flag) { return; } for (int m = 0; m < common.DataManager.Series.Count; m++) { Series series6 = common.DataManager.Series[m]; if (string.Compare(series6.ChartTypeName, Name, StringComparison.OrdinalIgnoreCase) == 0 && !(series6.ChartArea != area.Name) && series6.IsVisible()) { string text2 = GetSeriesStackGroupName(series6); int num10 = text2.IndexOf("__", StringComparison.Ordinal); if (num10 >= 0) { text2 = text2.Substring(num10 + 2); } if (text2.Length > 0) { series6["StackedGroupName"] = text2; } else { series6.DeleteAttribute("StackedGroupName"); } } } }
/// <summary> /// Remove any changes done while preparing PointAndFigure chart type for rendering. /// </summary> /// <param name="series">Series to be un-prepared.</param> /// <returns>True if series was removed from collection.</returns> internal static bool UnPrepareData(Series series) { if (series.Name.StartsWith("POINTANDFIGURE_ORIGINAL_DATA_", StringComparison.Ordinal)) { // Get reference to the chart control Chart chart = series.Chart; if (chart == null) { throw (new InvalidOperationException(SR.ExceptionPointAndFigureNullReference)); } // Unsubscribe for customize event if (_customizeSubscribed) { _customizeSubscribed = false; chart.Customize -= new EventHandler(OnCustomize); } // Get original PointAndFigure series Series pointAndFigureSeries = chart.Series[series.Name.Substring(29)]; Series.MovePositionMarkers(pointAndFigureSeries, series); // Copy data back to original PointAndFigure series pointAndFigureSeries.Points.Clear(); if (!series.IsCustomPropertySet("TempDesignData")) { foreach (DataPoint dp in series.Points) { pointAndFigureSeries.Points.Add(dp); } } // Restore series properties bool xValIndexed; bool parseSucceed = bool.TryParse(pointAndFigureSeries["OldXValueIndexed"], out xValIndexed); pointAndFigureSeries.IsXValueIndexed = parseSucceed && xValIndexed; int yVals; parseSucceed = int.TryParse(pointAndFigureSeries["OldYValuesPerPoint"], NumberStyles.Any, CultureInfo.InvariantCulture, out yVals); if (parseSucceed) { pointAndFigureSeries.YValuesPerPoint = yVals; } pointAndFigureSeries.DeleteCustomProperty("OldXValueIndexed"); pointAndFigureSeries.DeleteCustomProperty("OldYValuesPerPoint"); pointAndFigureSeries.DeleteCustomProperty(CustomPropertyName.EmptyPointValue); series["OldAutomaticXAxisInterval"] = "true"; if (pointAndFigureSeries.IsCustomPropertySet("OldAutomaticXAxisInterval")) { pointAndFigureSeries.DeleteCustomProperty("OldAutomaticXAxisInterval"); // Reset automatic interval for X axis if (pointAndFigureSeries.ChartArea.Length > 0) { // Get X axis connected to the series ChartArea area = chart.ChartAreas[pointAndFigureSeries.ChartArea]; Axis xAxis = area.GetAxis(AxisName.X, pointAndFigureSeries.XAxisType, pointAndFigureSeries.XSubAxisName); xAxis.interval = 0.0; xAxis.intervalType = DateTimeIntervalType.Auto; } } // Remove series from the collection chart.Series.Remove(series); return(true); } return(false); }
public virtual void Paint(ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw) { this.common = common; this.graph = graph; if (area.Area3DStyle.Enable3D) { this.chartArea3DEnabled = true; this.matrix3D = area.matrix3D; } else { this.chartArea3DEnabled = false; } foreach (Series item in common.DataManager.Series) { Axis axis; Axis axis2; double viewMinimum; double viewMaximum; double viewMinimum2; double viewMaximum2; float num2; if (string.Compare(item.ChartTypeName, this.Name, true, CultureInfo.CurrentCulture) == 0 && !(item.ChartArea != area.Name) && item.IsVisible()) { if (this.chartArea3DEnabled) { float num = default(float); ((ChartArea3D)area).GetSeriesZPositionAndDepth(item, out num, out this.seriesZCoordinate); this.seriesZCoordinate += (float)(num / 2.0); } axis = area.GetAxis(AxisName.X, item.XAxisType, area.Area3DStyle.Enable3D ? string.Empty : item.XSubAxisName); axis2 = area.GetAxis(AxisName.Y, item.YAxisType, area.Area3DStyle.Enable3D ? string.Empty : item.YSubAxisName); viewMinimum = axis.GetViewMinimum(); viewMaximum = axis.GetViewMaximum(); viewMinimum2 = axis2.GetViewMinimum(); viewMaximum2 = axis2.GetViewMaximum(); num2 = (float)((float)item.MarkerSize / 3.0); if (item.IsAttributeSet("PixelPointGapDepth")) { string s = ((DataPointAttributes)item)["PixelPointGapDepth"]; try { num2 = float.Parse(s, CultureInfo.CurrentCulture); } catch { throw new InvalidOperationException(SR.ExceptionCustomAttributeValueInvalid2("PermittedPixelError")); } if (!(num2 < 0.0) && !(num2 > 50.0)) { goto IL_019f; } throw new InvalidOperationException(SR.ExceptionCustomAttributeIsNotInRange0to50("PermittedPixelError")); } goto IL_019f; } continue; IL_019f: SizeF relativeSize = graph.GetRelativeSize(new SizeF(num2, num2)); SizeF relativeSize2 = graph.GetRelativeSize(new SizeF((float)viewMinimum, (float)viewMinimum2)); double num3 = Math.Abs(axis.PositionToValue((double)(relativeSize2.Width + relativeSize.Width), false) - axis.PositionToValue((double)relativeSize2.Width, false)); double num4 = Math.Abs(axis2.PositionToValue((double)(relativeSize2.Height + relativeSize.Height), false) - axis2.PositionToValue((double)relativeSize2.Height, false)); SolidBrush solidBrush = new SolidBrush(item.MarkerColor.IsEmpty ? item.Color : item.MarkerColor); SolidBrush solidBrush2 = new SolidBrush(item.EmptyPointStyle.MarkerColor.IsEmpty ? item.EmptyPointStyle.Color : item.EmptyPointStyle.MarkerColor); Pen pen = null; Pen pen2 = null; if (!item.MarkerBorderColor.IsEmpty && item.MarkerBorderWidth > 0) { pen = new Pen(item.MarkerBorderColor, (float)item.MarkerBorderWidth); } if (!item.EmptyPointStyle.MarkerBorderColor.IsEmpty && item.EmptyPointStyle.MarkerBorderWidth > 0) { pen2 = new Pen(item.EmptyPointStyle.MarkerBorderColor, (float)item.EmptyPointStyle.MarkerBorderWidth); } bool flag = area.IndexedSeries(item.Name); int num5 = 0; double num6 = 0.0; double num7 = 0.0; double num8 = 0.0; double num9 = 0.0; PointF empty = PointF.Empty; bool flag2 = false; double num10 = ((double)graph.common.ChartPicture.Width - 1.0) / 100.0; double num11 = ((double)graph.common.ChartPicture.Height - 1.0) / 100.0; int markerSize = item.MarkerSize; MarkerStyle markerStyle = item.MarkerStyle; MarkerStyle markerStyle2 = item.EmptyPointStyle.MarkerStyle; foreach (DataPoint point in item.Points) { num6 = (flag ? ((double)(num5 + 1)) : point.XValue); num6 = axis.GetLogValue(num6); num7 = axis2.GetLogValue(point.YValues[0]); flag2 = point.Empty; if (num6 < viewMinimum || num6 > viewMaximum || num7 < viewMinimum2 || num7 > viewMaximum2) { num8 = num6; num9 = num7; num5++; } else if (num5 > 0 && Math.Abs(num6 - num8) < num3 && Math.Abs(num7 - num9) < num4) { num5++; } else { empty.X = (float)(axis.GetLinearPosition(num6) * num10); empty.Y = (float)(axis2.GetLinearPosition(num7) * num11); this.DrawMarker(graph, point, num5, empty, flag2 ? markerStyle2 : markerStyle, markerSize, flag2 ? solidBrush2 : solidBrush, flag2 ? pen2 : pen); num8 = num6; num9 = num7; num5++; } } solidBrush.Dispose(); solidBrush2.Dispose(); if (pen != null) { pen.Dispose(); } if (pen2 != null) { pen2.Dispose(); } } }
/// <summary> /// Customize chart event, used to add empty points to make point and /// figure chart symbols look proportional. /// </summary> /// <param name="sender">The source Chart object of this event.</param> /// <param name="e">The EventArgs object that contains the event data.</param> static private void OnCustomize(Object sender, EventArgs e) { bool chartResized = false; Chart chart = (Chart)sender; // Loop through all series foreach (Series series in chart.Series) { // Check for the PointAndFigure chart type if (series.Name.StartsWith("POINTANDFIGURE_ORIGINAL_DATA_", StringComparison.Ordinal)) { // Get original series Series pointAndFigureSeries = chart.Series[series.Name.Substring(29)]; // Check if proportional symbol custom attribute is set bool proportionalSymbols = true; string attrValue = pointAndFigureSeries[CustomPropertyName.ProportionalSymbols]; if (attrValue != null && String.Compare(attrValue, "True", StringComparison.OrdinalIgnoreCase) != 0) { proportionalSymbols = false; } if (proportionalSymbols && pointAndFigureSeries.Enabled && pointAndFigureSeries.ChartArea.Length > 0) { // Resize chart if (!chartResized) { chartResized = true; chart.chartPicture.Resize(chart.chartPicture.ChartGraph, false); } // Find series chart area, X & Y axes ChartArea chartArea = chart.ChartAreas[pointAndFigureSeries.ChartArea]; Axis axisX = chartArea.GetAxis(AxisName.X, pointAndFigureSeries.XAxisType, pointAndFigureSeries.XSubAxisName); Axis axisY = chartArea.GetAxis(AxisName.Y, pointAndFigureSeries.YAxisType, pointAndFigureSeries.YSubAxisName); // Symbols are drawn only in 2D mode if (!chartArea.Area3DStyle.Enable3D) { // Get current box size double boxSize = double.Parse( pointAndFigureSeries["CurrentBoxSize"], CultureInfo.InvariantCulture); // Calculate symbol width and height double boxYSize = Math.Abs( axisY.GetPosition(axisY.Minimum) - axisY.GetPosition(axisY.Minimum + boxSize)); double boxXSize = Math.Abs( axisX.GetPosition(1.0) - axisX.GetPosition(0.0)); boxXSize *= 0.8; // Get absolute size in pixels SizeF markSize = chart.chartPicture.ChartGraph.GetAbsoluteSize( new SizeF((float)boxXSize, (float)boxYSize)); // Calculate number of empty points that should be added int pointCount = 0; if (markSize.Width > markSize.Height) { pointCount = (int)(pointAndFigureSeries.Points.Count * (markSize.Width / markSize.Height)); } // Add empty points DataPoint emptyPoint = new DataPoint(pointAndFigureSeries); emptyPoint.IsEmpty = true; emptyPoint.AxisLabel = " "; while (pointAndFigureSeries.Points.Count < pointCount) { pointAndFigureSeries.Points.Add(emptyPoint); } // Always use zeros for Y values of empty points pointAndFigureSeries[CustomPropertyName.EmptyPointValue] = "Zero"; // RecalculateAxesScale chart are data chartArea.ReCalcInternal(); } } } } }
internal void ProcessSinglePoint3D(DataPoint3D pointEx, bool selection, ChartGraphics graph, CommonElements common, ChartArea area) { DataPoint dataPoint = pointEx.dataPoint; Series series = dataPoint.series; dataPoint.positionRel = new PointF(float.NaN, float.NaN); hAxis = area.GetAxis(AxisName.X, series.XAxisType, series.XSubAxisName); vAxis = area.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName); double yValue = GetYValue(common, area, series, pointEx.dataPoint, pointEx.index - 1, yValueIndex); yValue = vAxis.GetLogValue(yValue); if (yValue > vAxis.GetViewMaximum() || yValue < vAxis.GetViewMinimum()) { return; } double yValue2 = pointEx.indexedSeries ? ((double)pointEx.index) : dataPoint.XValue; yValue2 = hAxis.GetLogValue(yValue2); if (yValue2 > hAxis.GetViewMaximum() || yValue2 < hAxis.GetViewMinimum() || (!ShouldDrawMarkerOnViewEdgeX() && ((yValue2 == hAxis.GetViewMaximum() && ShiftedX >= 0.0) || (yValue2 == hAxis.GetViewMinimum() && ShiftedX <= 0.0)))) { return; } PointF empty = PointF.Empty; empty.Y = (float)pointEx.yPosition; empty.X = (float)hAxis.GetLinearPosition(yValue2); empty.X += (float)ShiftedX; dataPoint.positionRel = new PointF(empty.X, empty.Y); int markerSize = dataPoint.MarkerSize; string markerImage = dataPoint.MarkerImage; MarkerStyle markerStyle = dataPoint.MarkerStyle; SizeF markerSize2 = GetMarkerSize(graph, common, area, dataPoint, markerSize, markerImage); Point3D[] array = new Point3D[1] { new Point3D(empty.X, empty.Y, pointEx.zPosition + (middleMarker ? (pointEx.depth / 2f) : pointEx.depth)) }; area.matrix3D.TransformPoints(array); PointF pointF = array[0].PointF; GraphicsPath path = null; if ((alwaysDrawMarkers || markerStyle != 0 || markerImage.Length > 0) && pointEx.index % series.MarkerStep == 0) { DrawingOperationTypes drawingOperationTypes = DrawingOperationTypes.DrawElement; if (common.ProcessModeRegions) { drawingOperationTypes |= DrawingOperationTypes.CalcElementPath; } graph.StartHotRegion(dataPoint); graph.StartAnimation(); path = graph.DrawMarker3D(area.matrix3D, area.Area3DStyle.Light, pointEx.zPosition + (middleMarker ? (pointEx.depth / 2f) : pointEx.depth), empty, (markerStyle == MarkerStyle.None) ? MarkerStyle.Circle : markerStyle, (int)markerSize2.Height, (dataPoint.MarkerColor == Color.Empty) ? dataPoint.Color : dataPoint.MarkerColor, (dataPoint.MarkerBorderColor == Color.Empty) ? dataPoint.BorderColor : dataPoint.MarkerBorderColor, GetMarkerBorderSize(dataPoint), markerImage, dataPoint.MarkerImageTransparentColor, (dataPoint.series != null) ? dataPoint.series.ShadowOffset : 0, (dataPoint.series != null) ? dataPoint.series.ShadowColor : Color.Empty, new RectangleF(pointF.X, pointF.Y, markerSize2.Width, markerSize2.Height), drawingOperationTypes); graph.StopAnimation(); graph.EndHotRegion(); } PointF empty2 = PointF.Empty; if (label3DInfoList != null && label3DInfoList.Count > 0 && ((Label3DInfo)label3DInfoList[label3DInfoList.Count - 1]).PointEx.zPosition != pointEx.zPosition) { DrawAccumulated3DLabels(graph, common, area); } if (label3DInfoList == null) { label3DInfoList = new ArrayList(); } Label3DInfo label3DInfo = new Label3DInfo(); label3DInfo.PointEx = pointEx; label3DInfo.MarkerPosition = pointF; label3DInfo.MarkerSize = markerSize2; label3DInfo.AnimatedPoint = empty2; label3DInfoList.Add(label3DInfo); if (common.ProcessModeRegions) { SizeF relativeSize = graph.GetRelativeSize(markerSize2); int insertIndex = common.HotRegionsList.FindInsertIndex(); if (markerStyle == MarkerStyle.Circle) { float[] array2 = new float[3] { pointF.X, pointF.Y, relativeSize.Width / 2f }; common.HotRegionsList.AddHotRegion(insertIndex, graph, array2[0], array2[1], array2[2], dataPoint, series.Name, pointEx.index - 1); } if (markerStyle == MarkerStyle.Square) { common.HotRegionsList.AddHotRegion(path, relativePath: false, graph, dataPoint, series.Name, pointEx.index - 1); } else { common.HotRegionsList.AddHotRegion(graph, new RectangleF(pointF.X - relativeSize.Width / 2f, pointF.Y - relativeSize.Height / 2f, relativeSize.Width, relativeSize.Height), dataPoint, series.Name, pointEx.index - 1); } } }
public virtual void Paint(ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw) { this.common = common; this.graph = graph; bool flag = false; if (area.Area3DStyle.Enable3D) { this.chartArea3DEnabled = true; this.matrix3D = area.matrix3D; } else { this.chartArea3DEnabled = false; } foreach (Series item in common.DataManager.Series) { Axis axis; Axis axis2; double viewMinimum; double viewMaximum; double viewMinimum2; double viewMaximum2; float num2; if (string.Compare(item.ChartTypeName, this.Name, true, CultureInfo.CurrentCulture) == 0 && !(item.ChartArea != area.Name) && item.IsVisible()) { if (this.chartArea3DEnabled) { float num = default(float); ((ChartArea3D)area).GetSeriesZPositionAndDepth(item, out num, out this.seriesZCoordinate); this.seriesZCoordinate += (float)(num / 2.0); } axis = area.GetAxis(AxisName.X, item.XAxisType, area.Area3DStyle.Enable3D ? string.Empty : item.XSubAxisName); axis2 = area.GetAxis(AxisName.Y, item.YAxisType, area.Area3DStyle.Enable3D ? string.Empty : item.YSubAxisName); viewMinimum = axis.GetViewMinimum(); viewMaximum = axis.GetViewMaximum(); viewMinimum2 = axis2.GetViewMinimum(); viewMaximum2 = axis2.GetViewMaximum(); num2 = 1f; if (item.IsAttributeSet("PixelPointGapDepth")) { string s = ((DataPointAttributes)item)["PixelPointGapDepth"]; try { num2 = float.Parse(s, CultureInfo.CurrentCulture); } catch { throw new InvalidOperationException(SR.ExceptionCustomAttributeValueInvalid2("PermittedPixelError")); } if (!(num2 < 0.0) && !(num2 > 1.0)) { goto IL_019c; } throw new InvalidOperationException(SR.ExceptionCustomAttributeIsNotInRange0to1("PermittedPixelError")); } goto IL_019c; } continue; IL_019c: SizeF relativeSize = graph.GetRelativeSize(new SizeF(num2, num2)); SizeF relativeSize2 = graph.GetRelativeSize(new SizeF((float)viewMinimum, (float)viewMinimum2)); double num3 = Math.Abs(axis.PositionToValue((double)(relativeSize2.Width + relativeSize.Width), false) - axis.PositionToValue((double)relativeSize2.Width, false)); Math.Abs(axis2.PositionToValue((double)(relativeSize2.Height + relativeSize.Height), false) - axis2.PositionToValue((double)relativeSize2.Height, false)); Pen pen = new Pen(item.Color, (float)item.BorderWidth); pen.DashStyle = graph.GetPenStyle(item.BorderStyle); pen.StartCap = LineCap.Round; pen.EndCap = LineCap.Round; Pen pen2 = new Pen(item.EmptyPointStyle.Color, (float)item.EmptyPointStyle.BorderWidth); pen2.DashStyle = graph.GetPenStyle(item.EmptyPointStyle.BorderStyle); pen2.StartCap = LineCap.Round; pen2.EndCap = LineCap.Round; bool flag2 = area.IndexedSeries(item.Name); int num4 = 0; double num5 = double.NaN; double num6 = double.NaN; DataPoint pointMin = null; DataPoint pointMax = null; double num7 = 0.0; double num8 = 0.0; double num9 = 0.0; double num10 = 0.0; DataPoint dataPoint = null; PointF empty = PointF.Empty; PointF pointF = PointF.Empty; PointF empty2 = PointF.Empty; bool flag3 = false; bool flag4 = false; bool flag5 = false; bool flag6 = false; bool flag7 = false; double num11 = ((double)graph.common.ChartPicture.Width - 1.0) / 100.0; double num12 = ((double)graph.common.ChartPicture.Height - 1.0) / 100.0; foreach (DataPoint point in item.Points) { num7 = (flag2 ? ((double)(num4 + 1)) : point.XValue); num7 = axis.GetLogValue(num7); num8 = axis2.GetLogValue(point.YValues[0]); flag6 = point.Empty; if (flag5 && !flag6 && !flag7) { flag7 = true; flag6 = true; } else { flag7 = false; } if (!flag4) { if (num7 < viewMinimum && num9 < viewMinimum) { goto IL_041a; } if (num7 > viewMaximum && num9 > viewMaximum) { goto IL_041a; } if (num8 < viewMinimum2 && num10 < viewMinimum2) { goto IL_041a; } if (num8 > viewMaximum2 && num10 > viewMaximum2) { goto IL_041a; } } if (!flag && (num9 < viewMinimum || num9 > viewMaximum || num7 > viewMaximum || num7 < viewMinimum || num10 < viewMinimum2 || num10 > viewMaximum2 || num8 < viewMinimum2 || num8 > viewMaximum2)) { graph.SetClip(area.PlotAreaPosition.ToRectangleF()); flag = true; } if (num4 > 0 && flag6 == flag5 && Math.Abs(num7 - num9) < num3) { if (!flag4) { flag4 = true; if (num8 > num10) { num6 = num8; num5 = num10; pointMax = point; pointMin = dataPoint; } else { num6 = num10; num5 = num8; pointMax = dataPoint; pointMin = point; } } else if (num8 > num6) { num6 = num8; pointMax = point; } else if (num8 < num5) { num5 = num8; pointMin = point; } dataPoint = point; empty.Y = (float)num8; num4++; } else { empty2.X = (float)(axis.GetLinearPosition(num7) * num11); empty2.Y = (float)(axis2.GetLinearPosition(num8) * num12); if (flag3) { pointF.X = (float)(axis.GetLinearPosition(num9) * num11); pointF.Y = (float)(axis2.GetLinearPosition(num10) * num12); } if (flag4) { num5 = axis2.GetLinearPosition(num5) * num12; num6 = axis2.GetLinearPosition(num6) * num12; this.DrawLine(item, dataPoint, pointMin, pointMax, num4, flag5 ? pen2 : pen, pointF.X, (float)num5, pointF.X, (float)num6); flag4 = false; pointF.Y = (float)(axis2.GetLinearPosition((double)empty.Y) * num12); } if (num4 > 0) { this.DrawLine(item, point, pointMin, pointMax, num4, flag6 ? pen2 : pen, pointF.X, pointF.Y, empty2.X, empty2.Y); } num9 = num7; num10 = num8; dataPoint = point; pointF = empty2; flag3 = false; flag5 = flag6; num4++; } continue; IL_041a: num9 = num7; num10 = num8; flag3 = true; num4++; } if (flag4) { if (flag3) { pointF.X = (float)(axis.GetLinearPosition(num9) * num11); pointF.Y = (float)(axis2.GetLinearPosition(num10) * num12); } num5 = axis2.GetLinearPosition(num5) * num12; num6 = axis2.GetLinearPosition(num6) * num12; this.DrawLine(item, dataPoint, pointMin, pointMax, num4 - 1, flag5 ? pen2 : pen, pointF.X, (float)num5, pointF.X, (float)num6); flag4 = false; num5 = double.NaN; num6 = double.NaN; pointMin = null; pointMax = null; } } if (flag) { graph.ResetClip(); } }