/// <summary> /// Override this function to support chart type drawing /// </summary> /// <param name="e">Paint value event arguments.</param> public override void PaintValue(PaintValueEventArgs e) { string chartTypeName = String.Empty; if (_chartTypeRegistry != null && e != null) { if (e.Value is string) { chartTypeName = (string)e.Value; } else if (e.Value is SeriesChartType) { chartTypeName = Series.GetChartTypeName((SeriesChartType)e.Value); } if (!string.IsNullOrEmpty(chartTypeName)) { IChartType chartType = _chartTypeRegistry.GetChartType(chartTypeName); // Get imahe from the chart type System.Drawing.Image chartImage = null; if (chartType != null) { chartImage = chartType.GetImage(_chartTypeRegistry); } // Draw image if (chartImage != null) { e.Graphics.DrawImage(chartImage, e.Bounds); } } } }
private void ChartPicture_BeforePaint(object sender, ChartPaintEventArgs e) { int num = 1; for (int i = 0; i < this.Series.Count; i++) { Series series = this.Series[i]; series.xValuesZerosChecked = false; series.xValuesZeros = false; IChartType chartType = e.CommonElements.ChartTypeRegistry.GetChartType(series.ChartTypeName); bool pointsApplyPaletteColors = chartType.ApplyPaletteColorsToPoints; if (series.Palette != 0) { pointsApplyPaletteColors = true; } this.PrepareData(this.Palette != 0 || this.PaletteCustomColors.Length > 0, pointsApplyPaletteColors, series.Name); if (series.tempMarkerStyleIsSet) { series.MarkerStyle = MarkerStyle.None; series.tempMarkerStyleIsSet = false; } if (chartType.GetLegendImageStyle(series) == LegendImageStyle.Marker && series.MarkerStyle == MarkerStyle.None) { series.MarkerStyle = (MarkerStyle)(num++); series.tempMarkerStyleIsSet = true; if (num > 9) { num = 1; } } } }
public virtual void AddMarkersPosition(CommonElements common, ChartArea area) { if (this.smartLabelsPositions.Count == 0 && area != null) { ChartTypeRegistry chartTypeRegistry = common.ChartTypeRegistry; foreach (Series item in common.DataManager.Series) { if (item.ChartArea == area.Name && item.SmartLabels.Enabled && !item.SmartLabels.MarkerOverlapping) { IChartType chartType = chartTypeRegistry.GetChartType(item.ChartTypeName); chartType.AddSmartLabelMarkerPositions(common, area, item, this.smartLabelsPositions); } } Axis[] axes = area.Axes; foreach (Axis axis in axes) { if (axis.ScaleBreakStyle.Spacing > 0.0 && axis.ScaleSegments.Count > 0) { for (int j = 0; j < axis.ScaleSegments.Count - 1; j++) { RectangleF breakLinePosition = axis.ScaleSegments[j].GetBreakLinePosition(common.graph, axis.ScaleSegments[j + 1]); breakLinePosition = common.graph.GetRelativeRectangle(breakLinePosition); if (this.smartLabelsPositions == null) { this.smartLabelsPositions = new ArrayList(); } this.smartLabelsPositions.Add(breakLinePosition); } } } } }
protected void PaintChartSeries3D(ChartGraphics graph) { ChartArea area = (ChartArea)this; ArrayList arrayList = this.GetSeriesDrawingOrder(this.reverseSeriesOrder); foreach (object item in arrayList) { Series series = (Series)item; IChartType chartType = base.Common.ChartTypeRegistry.GetChartType(series.ChartTypeName); chartType.Paint(graph, base.Common, area, series); } }
public void SetAttributes(CommonElements common, Series series) { IChartType chartType = common.ChartTypeRegistry.GetChartType(series.ChartTypeName); this.style = chartType.GetLegendImageStyle(series); this.seriesName = series.Name; this.shadowOffset = series.ShadowOffset; this.shadowColor = series.ShadowColor; bool enable3D = common.Chart.ChartAreas[series.ChartArea].Area3DStyle.Enable3D; this.SetAttributes(series, enable3D); }
protected internal bool IsChartAreaCircular(ChartArea area) { foreach (object chartType2 in area.ChartTypes) { IChartType chartType = area.Common.ChartTypeRegistry.GetChartType(chartType2.ToString()); if (chartType != null && (chartType.CircularChartArea || !chartType.RequireAxes)) { return(true); } } return(false); }
/// <summary> /// Releases unmanaged and - optionally - managed resources /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (disposing) { // Dispose managed resource foreach (string name in this._createdChartTypes.Keys) { IChartType chartType = (IChartType)_createdChartTypes[name]; chartType.Dispose(); } this._createdChartTypes.Clear(); } }
/// <summary> /// Gets minimum Unsigned stacked Y value from many series /// </summary> /// <param name="valueIndex">Index of Y value to use</param> /// <param name="series">Series IDs</param> /// <returns>Minimum stacked Y value</returns> internal double GetMinUnsignedStackedYValue(int valueIndex, params string[] series) { double returnValue = Double.MaxValue; double minValue = Double.MaxValue; double numberOfPoints = GetNumberOfPoints(series); for (int pointIndex = 0; pointIndex < numberOfPoints; pointIndex++) { double stackedMin = 0; double noStackedMin = 0; minValue = Double.MaxValue; foreach (string seriesName in series) { if (this._series[seriesName].Points.Count > pointIndex) { // Take chart type from the series ChartTypeRegistry chartTypeRegistry = (ChartTypeRegistry)serviceContainer.GetService(typeof(ChartTypeRegistry)); IChartType chartType = chartTypeRegistry.GetChartType(this._series[seriesName].ChartTypeName); // If stacked column and bar if (chartType.StackSign || double.IsNaN(this._series[seriesName].Points[pointIndex].YValues[valueIndex])) { continue; } if (chartType.Stacked) { if (this._series[seriesName].Points[pointIndex].YValues[valueIndex] < 0) { stackedMin += this._series[seriesName].Points[pointIndex].YValues[valueIndex]; if (stackedMin < minValue) { minValue = stackedMin; } } } else { noStackedMin = Math.Min(noStackedMin, this._series[seriesName].Points[pointIndex].YValues[valueIndex]); } } } minValue = Math.Min(noStackedMin, minValue); returnValue = Math.Min(returnValue, minValue); } return(returnValue); }
/// <summary> /// Event fired when chart picture is going to be painted. /// </summary> /// <param name="sender">Sender object.</param> /// <param name="e">Event arguments.</param> private void ChartPicture_BeforePaint(object sender, ChartPaintEventArgs e) { // Prepare series for drawing int markerIndex = 1; for (int index = 0; index < Series.Count; index++) { Series series = Series[index]; // Reset series "X values are zeros" flag series.xValuesZerosChecked = false; series.xValuesZeros = false; // Set series colors from palette IChartType chartType = e.CommonElements.ChartTypeRegistry.GetChartType(series.ChartTypeName); bool paletteColorsInPoints = chartType.ApplyPaletteColorsToPoints; // if the series palette is set the we can color all data points, even on column chart. if (series.Palette != ChartColorPalette.None) { paletteColorsInPoints = true; } PrepareData( paletteColorsInPoints, series.Name); // Clear temp. marker style if (series.tempMarkerStyleIsSet) { series.MarkerStyle = MarkerStyle.None; series.tempMarkerStyleIsSet = false; } // Set marker style for chart types based on markes if (chartType.GetLegendImageStyle(series) == LegendImageStyle.Marker && series.MarkerStyle == MarkerStyle.None) { series.MarkerStyle = (MarkerStyle)markerIndex++; series.tempMarkerStyleIsSet = true; if (markerIndex > 9) { markerIndex = 1; } } } }
/// <summary> /// Gets maximum Unsigned stacked Y value from many series ( Stacked Area chart ) /// </summary> /// <param name="valueIndex">Index of Y value to use</param> /// <param name="series">Series IDs</param> /// <returns>Maximum stacked Y value</returns> public double GetMaxUnsignedStackedYValue(int valueIndex, params string[] series) { double returnValue = 0; double maxValue = Double.MinValue; double numberOfPoints = GetNumberOfPoints(series); for (int pointIndex = 0; pointIndex < numberOfPoints; pointIndex++) { double stackedMax = 0; double noStackedMax = 0; foreach (string seriesName in series) { if (_series[seriesName].Points.Count > pointIndex) { // Take chart type from the series ChartTypeRegistry chartTypeRegistry = Common.ChartTypeRegistry; IChartType chartType = chartTypeRegistry.GetChartType(_series[seriesName].ChartTypeName); // If stacked column and bar if (chartType.StackSign || double.IsNaN(_series[seriesName].Points[pointIndex].YValues[valueIndex])) { continue; } if (chartType.Stacked) { maxValue = Double.MinValue; stackedMax += _series[seriesName].Points[pointIndex].YValues[valueIndex]; if (stackedMax > maxValue) { maxValue = stackedMax; } } else { noStackedMax = Math.Max(noStackedMax, _series[seriesName].Points[pointIndex].YValues[valueIndex]); } } } maxValue = Math.Max(maxValue, noStackedMax); returnValue = Math.Max(returnValue, maxValue); } return(returnValue); }
internal double GetMinUnsignedStackedYValue(int valueIndex, params string[] series) { double num = double.MaxValue; double num2 = double.MaxValue; double num3 = GetNumberOfPoints(series); for (int i = 0; (double)i < num3; i++) { double num4 = 0.0; double val = 0.0; num2 = double.MaxValue; foreach (string parameter in series) { if (this.series[parameter].Points.Count <= i) { continue; } IChartType chartType = ((ChartTypeRegistry)serviceContainer.GetService(typeof(ChartTypeRegistry))).GetChartType(this.series[parameter].ChartTypeName); if (chartType.StackSign || double.IsNaN(this.series[parameter].Points[i].YValues[valueIndex])) { continue; } if (chartType.Stacked) { if (this.series[parameter].Points[i].YValues[valueIndex] < 0.0) { num4 += this.series[parameter].Points[i].YValues[valueIndex]; if (num4 < num2) { num2 = num4; } } } else { val = Math.Min(val, this.series[parameter].Points[i].YValues[valueIndex]); } } num2 = Math.Min(val, num2); num = Math.Min(num, num2); } return(num); }
public double GetMinUnsignedStackedYValue(int valueIndex, params string[] series) { double num = 1.7976931348623157E+308; double num2 = 1.7976931348623157E+308; double num3 = (double)this.GetNumberOfPoints(series); for (int i = 0; (double)i < num3; i++) { double num4 = 0.0; double val = 0.0; num2 = 1.7976931348623157E+308; foreach (string parameter in series) { if (this.series[parameter].Points.Count > i) { ChartTypeRegistry chartTypeRegistry = (ChartTypeRegistry)this.serviceContainer.GetService(typeof(ChartTypeRegistry)); IChartType chartType = chartTypeRegistry.GetChartType(this.series[parameter].ChartTypeName); if (!chartType.StackSign && !double.IsNaN(this.series[parameter].Points[i].YValues[valueIndex])) { if (chartType.Stacked) { if (this.series[parameter].Points[i].YValues[valueIndex] < 0.0) { num4 += this.series[parameter].Points[i].YValues[valueIndex]; if (num4 < num2) { num2 = num4; } } } else { val = Math.Min(val, this.series[parameter].Points[i].YValues[valueIndex]); } } } } num2 = Math.Min(val, num2); num = Math.Min(num, num2); } return(num); }
public bool CanUseAxisScaleBreaks() { if (this.axis != null && this.axis.chartArea != null && this.axis.chartArea.Common.Chart != null) { if (this.axis.chartArea.Area3DStyle.Enable3D) { return(false); } if (this.axis.axisType != 0 && this.axis.axisType != AxisName.X2) { if (this.axis.Logarithmic) { return(false); } if (this.axis.View.IsZoomed) { return(false); } ArrayList axisSeries = AxisScaleBreakStyle.GetAxisSeries(this.axis); foreach (Series item in axisSeries) { if (item.ChartType == SeriesChartType.Renko || item.ChartType == SeriesChartType.PointAndFigure) { return(false); } IChartType chartType = this.axis.chartArea.Common.ChartTypeRegistry.GetChartType(item.ChartTypeName); if (chartType == null) { return(false); } if (chartType.CircularChartArea || chartType.Stacked || !chartType.RequireAxes) { return(false); } } return(true); } return(false); } return(false); }
/// <summary> /// Gets maximum stacked Y value from many series /// </summary> /// <param name="valueIndex">Index of Y value to use</param> /// <param name="series">Series IDs</param> /// <returns>Maximum stacked Y value</returns> public double GetMaxStackedYValue(int valueIndex, params string[] series) { double returnValue = 0; double numberOfPoints = GetNumberOfPoints(series); for (int pointIndex = 0; pointIndex < numberOfPoints; pointIndex++) { double stackedMax = 0; double noStackedMax = 0; foreach (string seriesName in series) { if (_series[seriesName].Points.Count > pointIndex) { // Take chart type from the series ChartTypeRegistry chartTypeRegistry = Common.ChartTypeRegistry; IChartType chartType = chartTypeRegistry.GetChartType(_series[seriesName].ChartTypeName); // If stacked area if (!chartType.StackSign) { continue; } if (chartType.Stacked) { if (_series[seriesName].Points[pointIndex].YValues[valueIndex] > 0) { stackedMax += _series[seriesName].Points[pointIndex].YValues[valueIndex]; } } else { noStackedMax = Math.Max(noStackedMax, _series[seriesName].Points[pointIndex].YValues[valueIndex]); } } } stackedMax = Math.Max(stackedMax, noStackedMax); returnValue = Math.Max(returnValue, stackedMax); } return(returnValue); }
internal double GetMinStackedYValue(int valueIndex, params string[] series) { double num = double.MaxValue; double num2 = GetNumberOfPoints(series); for (int i = 0; (double)i < num2; i++) { double num3 = 0.0; double num4 = 0.0; foreach (string parameter in series) { if (this.series[parameter].Points.Count <= i) { continue; } IChartType chartType = ((ChartTypeRegistry)serviceContainer.GetService(typeof(ChartTypeRegistry))).GetChartType(this.series[parameter].ChartTypeName); if (!chartType.StackSign || double.IsNaN(this.series[parameter].Points[i].YValues[valueIndex])) { continue; } if (chartType.Stacked) { if (this.series[parameter].Points[i].YValues[valueIndex] < 0.0) { num3 += this.series[parameter].Points[i].YValues[valueIndex]; } } else { num4 = Math.Min(num4, this.series[parameter].Points[i].YValues[valueIndex]); } } num3 = Math.Min(num3, num4); if (num3 == 0.0) { num3 = this.series[series[0]].Points[this.series[series[0]].Points.Count - 1].YValues[valueIndex]; } num = Math.Min(num, num3); } return(num); }
internal bool CanUseAxisScaleBreaks() { if (axis == null || axis.chartArea == null || axis.chartArea.Common.Chart == null) { return(false); } if (axis.chartArea.Area3DStyle.Enable3D) { return(false); } if (axis.axisType == AxisName.X || axis.axisType == AxisName.X2) { return(false); } if (axis.Logarithmic) { return(false); } if (axis.View.IsZoomed) { return(false); } foreach (Series item in GetAxisSeries(axis)) { if (item.ChartType == SeriesChartType.Renko || item.ChartType == SeriesChartType.PointAndFigure) { return(false); } IChartType chartType = axis.chartArea.Common.ChartTypeRegistry.GetChartType(item.ChartTypeName); if (chartType == null) { return(false); } if (chartType.CircularChartArea || chartType.Stacked || !chartType.RequireAxes) { return(false); } } return(true); }
/// <summary> /// Gets minimum stacked Y value from many series /// </summary> /// <param name="valueIndex">Index of Y value to use</param> /// <param name="series">Series IDs</param> /// <returns>Minimum stacked Y value</returns> public double GetMinStackedYValue(int valueIndex, params string[] series) { double returnValue = Double.MaxValue; double numberOfPoints = GetNumberOfPoints(series); for (int pointIndex = 0; pointIndex < numberOfPoints; pointIndex++) { double stackedMin = 0; double noStackedMin = 0; foreach (string seriesName in series) { if (_series[seriesName].Points.Count > pointIndex) { // Take chart type from the series ChartTypeRegistry chartTypeRegistry = Common.ChartTypeRegistry; IChartType chartType = chartTypeRegistry.GetChartType(_series[seriesName].ChartTypeName); // If stacked area if (!chartType.StackSign || double.IsNaN(_series[seriesName].Points[pointIndex].YValues[valueIndex])) { continue; } if (chartType.Stacked) { if (_series[seriesName].Points[pointIndex].YValues[valueIndex] < 0) { stackedMin += _series[seriesName].Points[pointIndex].YValues[valueIndex]; } } else { noStackedMin = Math.Min(noStackedMin, _series[seriesName].Points[pointIndex].YValues[valueIndex]); } } } stackedMin = Math.Min(stackedMin, noStackedMin); if (stackedMin == 0) { stackedMin = _series[series[0]].Points[^ 1].YValues[valueIndex];
public double GetMaxStackedYValue(int valueIndex, params string[] series) { double num = 0.0; double num2 = (double)this.GetNumberOfPoints(series); for (int i = 0; (double)i < num2; i++) { double num3 = 0.0; double num4 = 0.0; foreach (string parameter in series) { if (this.series[parameter].Points.Count > i) { ChartTypeRegistry chartTypeRegistry = (ChartTypeRegistry)this.serviceContainer.GetService(typeof(ChartTypeRegistry)); IChartType chartType = chartTypeRegistry.GetChartType(this.series[parameter].ChartTypeName); if (chartType.StackSign) { if (chartType.Stacked) { if (this.series[parameter].Points[i].YValues[valueIndex] > 0.0) { num3 += this.series[parameter].Points[i].YValues[valueIndex]; } } else { num4 = Math.Max(num4, this.series[parameter].Points[i].YValues[valueIndex]); } } } } num3 = Math.Max(num3, num4); num = Math.Max(num, num3); } return(num); }
public void SetData(bool initializeAxes) { this.stacked = false; this.switchValueAxes = false; this.requireAxes = true; this.hundredPercent = false; this.hundredPercentNegative = false; this.chartAreaIsCurcular = false; this.secondYScale = false; bool flag = false; this.series.Clear(); ChartAreaCollection chartAreas = base.Common.Chart.ChartAreas; bool flag2 = chartAreas.Count > 0 && chartAreas[0] == this && chartAreas.GetIndex("Default") == -1; foreach (Series item in base.Common.DataManager.Series) { if (item.IsVisible() && (this.name == item.ChartArea || (flag2 && string.Compare(item.ChartArea, "Default", StringComparison.Ordinal) == 0)) && base.Common.DataManager.GetNumberOfPoints(item.Name) != 0) { this.series.Add(item.Name); } } this.chartTypes.Clear(); foreach (Series item2 in base.Common.DataManager.Series) { IChartType chartType = base.Common.ChartTypeRegistry.GetChartType(item2.ChartTypeName); bool flag3 = false; if ((item2.IsVisible() || chartType.RequireAxes) && (this.name == item2.ChartArea || (flag2 && string.Compare(item2.ChartArea, "Default", StringComparison.Ordinal) == 0))) { foreach (string chartType2 in this.chartTypes) { if (chartType2 == item2.ChartTypeName) { flag3 = true; } } if (!flag3) { if (chartType.Stacked) { this.stacked = true; } if (!flag) { if (chartType.SwitchValueAxes) { this.switchValueAxes = true; } if (!chartType.RequireAxes) { this.requireAxes = false; } if (chartType.CircularChartArea) { this.chartAreaIsCurcular = true; } if (chartType.HundredPercent) { this.hundredPercent = true; } if (chartType.HundredPercentSupportNegative) { this.hundredPercentNegative = true; } if (chartType.SecondYScale) { this.secondYScale = true; } flag = true; } else if (chartType.SwitchValueAxes != this.switchValueAxes) { throw new InvalidOperationException(SR.ExceptionChartAreaChartTypesCanNotCombine); } if (base.Common.DataManager.GetNumberOfPoints(item2.Name) != 0) { this.chartTypes.Add(item2.ChartTypeName); } } } } for (int i = 0; i <= 1; i++) { ArrayList xAxesSeries = this.GetXAxesSeries((AxisType)((i != 0) ? 1 : 0), string.Empty); if (xAxesSeries.Count > 0) { bool flag4 = false; string text = ""; foreach (string item3 in xAxesSeries) { text = text + item3.Replace(",", "\\,") + ","; if (base.Common.DataManager.Series[item3].XValueIndexed) { flag4 = true; } } if (flag4) { try { base.Common.DataManipulator.CheckXValuesAlignment(base.Common.DataManipulator.ConvertToSeriesArray(text.TrimEnd(','), false)); } catch (Exception ex) { throw new ArgumentException(SR.ExceptionAxisSeriesNotAligned + ex.Message); } } } } if (initializeAxes) { this.SetDefaultAxesValues(); } }
public int[] GetSeriesDataStatistics(int segmentCount, out double minYValue, out double maxYValue, out double segmentSize, out double[] segmentMaxValue, out double[] segmentMinValue) { ArrayList axisSeries = AxisScaleBreakStyle.GetAxisSeries(this.axis); minYValue = 0.0; maxYValue = 0.0; this.axis.Common.DataManager.GetMinMaxYValue(axisSeries, out minYValue, out maxYValue); if (axisSeries.Count == 0) { segmentSize = 0.0; segmentMaxValue = null; segmentMinValue = null; return(null); } segmentSize = (maxYValue - minYValue) / (double)segmentCount; int[] array = new int[segmentCount]; segmentMaxValue = new double[segmentCount]; segmentMinValue = new double[segmentCount]; for (int i = 0; i < segmentCount; i++) { segmentMaxValue[i] = double.NaN; segmentMinValue[i] = double.NaN; } foreach (Series item in axisSeries) { int num = 1; IChartType chartType = this.axis.chartArea.Common.ChartTypeRegistry.GetChartType(item.ChartTypeName); if (chartType != null && chartType.ExtraYValuesConnectedToYAxis && chartType.YValuesPerPoint > 1) { num = chartType.YValuesPerPoint; } foreach (DataPoint point in item.Points) { if (!point.Empty) { for (int j = 0; j < num; j++) { int num2 = (int)Math.Floor((point.YValues[j] - minYValue) / segmentSize); if (num2 < 0) { num2 = 0; } if (num2 > segmentCount - 1) { num2 = segmentCount - 1; } array[num2]++; if (array[num2] == 1) { segmentMaxValue[num2] = point.YValues[j]; segmentMinValue[num2] = point.YValues[j]; } else { segmentMaxValue[num2] = Math.Max(segmentMaxValue[num2], point.YValues[j]); segmentMinValue[num2] = Math.Min(segmentMinValue[num2], point.YValues[j]); } } } } } return(array); }
internal void FillLabels(bool removeFirstRow) { if (!LabelStyle.Enabled || !enabled) { return; } if (chartArea != null && chartArea.chartAreaIsCurcular && axisType != AxisName.Y) { ICircularChartType circularChartType = chartArea.GetCircularChartType(); if (circularChartType == null || !circularChartType.XAxisLabelsSupported()) { return; } } bool flag = false; foreach (CustomLabel customLabel in CustomLabels) { if (customLabel.customLabel && (customLabel.RowIndex == 0 || chartArea.chartAreaIsCurcular)) { flag = true; } if (customLabel.customLabel && base.Common.Chart != null && base.Common.Chart.LocalizeTextHandler != null) { customLabel.Text = base.Common.Chart.LocalizeTextHandler(customLabel, customLabel.Text, 0, ChartElementType.AxisLabels); } } if (removeFirstRow) { if (flag) { return; } for (int i = 0; i < CustomLabels.Count; i++) { if (CustomLabels[i].RowIndex == 0) { CustomLabels.RemoveAt(i); i = -1; } } } ArrayList arrayList = null; switch (axisType) { case AxisName.X: arrayList = chartArea.GetXAxesSeries(AxisType.Primary, ((Axis)this).SubAxisName); break; case AxisName.Y: arrayList = chartArea.GetYAxesSeries(AxisType.Primary, ((Axis)this).SubAxisName); break; case AxisName.X2: arrayList = chartArea.GetXAxesSeries(AxisType.Secondary, ((Axis)this).SubAxisName); break; case AxisName.Y2: arrayList = chartArea.GetYAxesSeries(AxisType.Secondary, ((Axis)this).SubAxisName); break; } if (arrayList.Count == 0) { return; } string[] array = new string[arrayList.Count]; for (int j = 0; j < arrayList.Count; j++) { array[j] = (string)arrayList[j]; } bool flag2 = SeriesXValuesZeros(array); bool indexedSeries = true; if (!flag2) { indexedSeries = IndexedSeries(array); } int num = 0; if (labelStyle.ShowEndLabels) { num = 1; } IChartType chartType = base.Common.ChartTypeRegistry.GetChartType(chartArea.GetFirstSeries().ChartTypeName); bool flag3 = false; if (!chartType.RequireAxes) { return; } flag3 = ((axisType != AxisName.Y && axisType != AxisName.Y2) ? true : false); if (flag3 && !SeriesXValuesZeros((string[])arrayList.ToArray(typeof(string)))) { flag3 = false; } if (flag3 && (labelStyle.IntervalOffset != 0.0 || labelStyle.Interval != 0.0)) { flag3 = false; } ChartValueTypes chartValueTypes = (axisType != 0 && axisType != AxisName.X2) ? base.Common.DataManager.Series[arrayList[0]].YValueType : base.Common.DataManager.Series[arrayList[0]].indexedXValueType; if (labelStyle.IntervalType != 0 && labelStyle.IntervalType != DateTimeIntervalType.Number && chartValueTypes != ChartValueTypes.Time && chartValueTypes != ChartValueTypes.Date && chartValueTypes != ChartValueTypes.DateTimeOffset) { chartValueTypes = ChartValueTypes.DateTime; } double viewMaximum = GetViewMaximum(); double viewMinimum = GetViewMinimum(); if (flag3) { int numberOfPoints = base.Common.DataManager.GetNumberOfPoints((string[])arrayList.ToArray(typeof(string))); if (num == 1) { CustomLabels.Add(-0.5, 0.5, ValueConverter.FormatValue(base.Common.Chart, this, 0.0, LabelStyle.Format, chartValueTypes, ChartElementType.AxisLabels), customLabel: false); } for (int k = 0; k < numberOfPoints; k++) { CustomLabels.Add((double)k + 0.5, (double)k + 1.5, ValueConverter.FormatValue(base.Common.Chart, this, k + 1, LabelStyle.Format, chartValueTypes, ChartElementType.AxisLabels), customLabel: false); } if (num == 1) { CustomLabels.Add((double)numberOfPoints + 0.5, (double)numberOfPoints + 1.5, ValueConverter.FormatValue(base.Common.Chart, this, numberOfPoints + 1, LabelStyle.Format, chartValueTypes, ChartElementType.AxisLabels), customLabel: false); } foreach (string item in arrayList) { int l = (num == 1) ? 1 : 0; foreach (DataPoint point in base.Common.DataManager.Series[item].Points) { for (; CustomLabels[l].RowIndex > 0; l++) { } if ((axisType == AxisName.X || axisType == AxisName.X2) && point.AxisLabel.Length > 0) { CustomLabels[l].Text = point.AxisLabel; if (base.Common.Chart != null && base.Common.Chart.LocalizeTextHandler != null) { CustomLabels[l].Text = base.Common.Chart.LocalizeTextHandler(point, CustomLabels[l].Text, point.ElementId, ChartElementType.DataPoint); } } l++; } } } else { if (viewMinimum == viewMaximum) { return; } Series series = null; if (axisType == AxisName.X || axisType == AxisName.X2) { ArrayList xAxesSeries = chartArea.GetXAxesSeries((axisType != 0) ? AxisType.Secondary : AxisType.Primary, ((Axis)this).SubAxisName); if (xAxesSeries.Count > 0) { series = base.Common.DataManager.Series[xAxesSeries[0]]; if (series != null && !series.XValueIndexed) { series = null; } } } DateTimeIntervalType dateTimeIntervalType = (labelStyle.IntervalOffsetType == DateTimeIntervalType.Auto) ? labelStyle.IntervalType : labelStyle.IntervalOffsetType; double num2 = viewMinimum; if (!chartArea.chartAreaIsCurcular || axisType == AxisName.Y || axisType == AxisName.Y2) { num2 = AlignIntervalStart(num2, labelStyle.Interval, labelStyle.IntervalType, series); } if (labelStyle.IntervalOffset != 0.0 && series == null) { num2 += GetIntervalSize(num2, labelStyle.IntervalOffset, dateTimeIntervalType, series, 0.0, DateTimeIntervalType.Number, forceIntIndex: true, forceAbsInterval: false); } if (chartValueTypes == ChartValueTypes.DateTime || chartValueTypes == ChartValueTypes.Date || chartValueTypes == ChartValueTypes.Time || chartValueTypes == ChartValueTypes.DateTimeOffset || series != null) { double num3 = num2; if ((viewMaximum - num2) / GetIntervalSize(num2, labelStyle.Interval, labelStyle.IntervalType, series, 0.0, DateTimeIntervalType.Number, forceIntIndex: true) > 10000.0) { return; } int num4 = 0; double num5 = viewMaximum - GetIntervalSize(viewMaximum, labelStyle.Interval, labelStyle.IntervalType, series, labelStyle.IntervalOffset, dateTimeIntervalType, forceIntIndex: true) / 2.0; double num6 = viewMinimum + GetIntervalSize(viewMinimum, labelStyle.Interval, labelStyle.IntervalType, series, labelStyle.IntervalOffset, dateTimeIntervalType, forceIntIndex: true) / 2.0; while ((decimal)num3 <= (decimal)viewMaximum) { double intervalSize = GetIntervalSize(num3, labelStyle.Interval, labelStyle.IntervalType, series, labelStyle.IntervalOffset, dateTimeIntervalType, forceIntIndex: true); double num7 = num3; if (base.Logarithmic) { num7 = Math.Pow(logarithmBase, num7); } if (num4++ > 10000 || (num == 0 && num3 >= num5)) { break; } double num8 = num3 - intervalSize * 0.5; double toPosition = num3 + intervalSize * 0.5; if (num == 0 && num3 <= num6) { num3 += intervalSize; continue; } if ((decimal)num8 > (decimal)viewMaximum) { num3 += intervalSize; continue; } string pointLabel = GetPointLabel(arrayList, num7, !flag2, indexedSeries); if (pointLabel.Length == 0) { if (num3 <= maximum && (num3 != maximum || !base.Common.DataManager.Series[arrayList[0]].XValueIndexed)) { CustomLabels.Add(num8, toPosition, ValueConverter.FormatValue(base.Common.Chart, this, num7, LabelStyle.Format, chartValueTypes, ChartElementType.AxisLabels), customLabel: false); } } else { CustomLabels.Add(num8, toPosition, pointLabel, customLabel: false); } num3 += intervalSize; } return; } if (num2 != viewMinimum) { num = 1; } int num9 = 0; for (double num10 = num2 - (double)num * labelStyle.Interval; num10 < viewMaximum - 1.5 * labelStyle.Interval * (double)(1 - num); num10 = (double)((decimal)num10 + (decimal)labelStyle.Interval)) { num9++; if (num9 > 10000) { break; } double num7 = Axis.RemoveNoiseFromDoubleMath(num10) + Axis.RemoveNoiseFromDoubleMath(labelStyle.Interval); double value = Math.Log(labelStyle.Interval); double value2 = Math.Log(Math.Abs(num7)); int num11 = (int)Math.Abs(value) + 5; if (num11 > 15) { num11 = 15; } if (Math.Abs(value) < Math.Abs(value2) - 5.0) { num7 = Math.Round(num7, num11); } if ((viewMaximum - num2) / labelStyle.Interval > 10000.0) { break; } if (base.Logarithmic) { num7 = Math.Pow(logarithmBase, num7); } double num8 = (double)((decimal)num10 + (decimal)labelStyle.Interval * 0.5m); double toPosition = (double)((decimal)num10 + (decimal)labelStyle.Interval * 1.5m); if (!((decimal)num8 > (decimal)viewMaximum) && !((decimal)((num8 + toPosition) / 2.0) > (decimal)viewMaximum)) { string pointLabel2 = GetPointLabel(arrayList, num7, !flag2, indexedSeries); if (pointLabel2.Length > 15 && num7 < 1E-06) { num7 = 0.0; } if (pointLabel2.Length == 0) { if (!base.Common.DataManager.Series[arrayList[0]].XValueIndexed || !(num10 > maximum)) { CustomLabels.Add(num8, toPosition, ValueConverter.FormatValue(base.Common.Chart, this, num7, LabelStyle.Format, chartValueTypes, ChartElementType.AxisLabels), customLabel: false); } } else { CustomLabels.Add(num8, toPosition, pointLabel2, customLabel: false); } } } } }
/// <summary> /// Collect statistical information about the series. /// </summary> /// <param name="segmentCount">Segment count.</param> /// <param name="minYValue">Minimum Y value.</param> /// <param name="maxYValue">Maximum Y value.</param> /// <param name="segmentSize">Segment size.</param> /// <param name="segmentMaxValue">Array of segment scale maximum values.</param> /// <param name="segmentMinValue">Array of segment scale minimum values.</param> /// <returns></returns> internal int[] GetSeriesDataStatistics( int segmentCount, out double minYValue, out double maxYValue, out double segmentSize, out double[] segmentMaxValue, out double[] segmentMinValue) { // Get all series associated with the axis ArrayList axisSeries = AxisScaleBreakStyle.GetAxisSeries(axis); // Get range of Y values from axis series axis.Common.DataManager.GetMinMaxYValue(axisSeries, out minYValue, out maxYValue); int numberOfPoints = 0; foreach (Series series in axisSeries) { numberOfPoints = Math.Max(numberOfPoints, series.Points.Count); } if (axisSeries.Count == 0 || numberOfPoints == 0) { segmentSize = 0.0; segmentMaxValue = null; segmentMinValue = null; return(Array.Empty <int>()); } // Split range of values into predefined number of segments and calculate // how many points will be in each segment. segmentSize = (maxYValue - minYValue) / segmentCount; int[] segmentPointNumber = new int[segmentCount]; segmentMaxValue = new double[segmentCount]; segmentMinValue = new double[segmentCount]; for (int index = 0; index < segmentCount; index++) { segmentMaxValue[index] = double.NaN; segmentMinValue[index] = double.NaN; } foreach (Series series in axisSeries) { // Get number of Y values to process int maxYValueCount = 1; IChartType chartType = axis.ChartArea.Common.ChartTypeRegistry.GetChartType(series.ChartTypeName); if (chartType != null && chartType.ExtraYValuesConnectedToYAxis && chartType.YValuesPerPoint > 1) { maxYValueCount = chartType.YValuesPerPoint; } // Iterate throug all data points foreach (DataPoint dataPoint in series.Points) { if (!dataPoint.IsEmpty) { // Iterate through all yValues for (int yValueIndex = 0; yValueIndex < maxYValueCount; yValueIndex++) { // Calculate index of the scale segment int segmentIndex = (int)Math.Floor((dataPoint.YValues[yValueIndex] - minYValue) / segmentSize); if (segmentIndex < 0) { segmentIndex = 0; } if (segmentIndex > segmentCount - 1) { segmentIndex = segmentCount - 1; } // Increase number points in that segment ++segmentPointNumber[segmentIndex]; // Store Min/Max values for the segment if (segmentPointNumber[segmentIndex] == 1) { segmentMaxValue[segmentIndex] = dataPoint.YValues[yValueIndex]; segmentMinValue[segmentIndex] = dataPoint.YValues[yValueIndex]; } else { segmentMaxValue[segmentIndex] = Math.Max(segmentMaxValue[segmentIndex], dataPoint.YValues[yValueIndex]); segmentMinValue[segmentIndex] = Math.Min(segmentMinValue[segmentIndex], dataPoint.YValues[yValueIndex]); } } } } } return(segmentPointNumber); }
/// <summary> /// Checks if scale breaks can be used on specified axis. /// </summary> /// <returns>True if scale breaks can be used on this axis</returns> internal bool CanUseAxisScaleBreaks() { // Check input parameters if (axis == null || axis.ChartArea == null || axis.ChartArea.Common.Chart == null) { return(false); } // No scale breaks in 3D charts if (axis.ChartArea.Area3DStyle.Enable3D) { return(false); } // Axis scale break can only be applied to the Y and Y 2 axis if (axis.axisType == AxisName.X || axis.axisType == AxisName.X2) { return(false); } // No scale breaks for logarithmic axis if (axis.IsLogarithmic) { return(false); } // No scale breaks if axis zooming is enabled if (axis.ScaleView.IsZoomed) { return(false); } // Check series associated with this axis ArrayList axisSeries = AxisScaleBreakStyle.GetAxisSeries(axis); foreach (Series series in axisSeries) { // Some special chart type are not supported if (series.ChartType == SeriesChartType.Renko || series.ChartType == SeriesChartType.PointAndFigure) { return(false); } // Get chart type interface IChartType chartType = axis.ChartArea.Common.ChartTypeRegistry.GetChartType(series.ChartTypeName); if (chartType == null) { return(false); } // Circular and stacked chart types can not use scale breaks if (chartType.CircularChartArea || chartType.Stacked || !chartType.RequireAxes) { return(false); } } return(true); }
/// <summary> /// Fill labels from data from data manager or /// from axis scale. /// </summary> /// <param name="removeFirstRow">True if first row of auto generated labels must be removed.</param> internal void FillLabels(bool removeFirstRow) { #if SUBAXES // Process all sub-axis foreach (SubAxis subAxis in ((Axis)this).SubAxes) { subAxis.FillLabels(true); } #endif // SUBAXES // Labels are disabled for this axis if (!LabelStyle.Enabled || !enabled) { return; } // For circular chart area fill only Y axis labels if (ChartArea != null && ChartArea.chartAreaIsCurcular && axisType != AxisName.Y) { ICircularChartType type = ChartArea.GetCircularChartType(); if (type == null || !type.XAxisLabelsSupported()) { return; } } // Check if the custom labels exist bool customLabelsFlag = false; foreach (CustomLabel lab in CustomLabels) { if (lab.customLabel && (lab.RowIndex == 0 || ChartArea.chartAreaIsCurcular)) { customLabelsFlag = true; } } // Remove the first row of labels if custom labels not exist if (removeFirstRow) { if (!customLabelsFlag) { for (int index = 0; index < CustomLabels.Count; index++) { if (CustomLabels[index].RowIndex == 0) { CustomLabels.RemoveAt(index); index = -1; } } } else { return; } } // Get data series for this axis. List <string> dataSeries = null; switch (axisType) { case AxisName.X: dataSeries = ChartArea.GetXAxesSeries(AxisType.Primary, SubAxisName); break; case AxisName.Y: dataSeries = ChartArea.GetYAxesSeries(AxisType.Primary, SubAxisName); break; case AxisName.X2: dataSeries = ChartArea.GetXAxesSeries(AxisType.Secondary, SubAxisName); break; case AxisName.Y2: dataSeries = ChartArea.GetYAxesSeries(AxisType.Secondary, SubAxisName); break; } // There aren't data series connected with this axis. if (dataSeries == null || dataSeries.Count == 0) { return; } //Let's convert the ArrayList of the series names into to string[] string[] dataSeriesNames = new string[dataSeries.Count]; for (int i = 0; i < dataSeries.Count; i++) { dataSeriesNames[i] = dataSeries[i]; } // Check if series X values all set to zeros bool seriesXValuesZeros = ChartHelper.SeriesXValuesZeros(Common, dataSeriesNames); // Check if series is indexed (All X values zeros or IsXValueIndexed flag set) bool indexedSeries = true; if (!seriesXValuesZeros) { indexedSeries = ChartHelper.IndexedSeries(Common, dataSeriesNames); } // Show End Labels int endLabels = 0; if (labelStyle.IsEndLabelVisible) { endLabels = 1; } // Get chart type of the first series IChartType chartType = Common.ChartTypeRegistry.GetChartType(ChartArea.GetFirstSeries().ChartTypeName); bool fromSeries = false; if (!chartType.RequireAxes) { return; } else if (axisType == AxisName.Y || axisType == AxisName.Y2) { fromSeries = false; } else { fromSeries = true; } // X values from data points are not 0. if (fromSeries && !ChartHelper.SeriesXValuesZeros(Common, dataSeries.ToArray())) { fromSeries = false; } // X values from data points are not 0. if (fromSeries && (labelStyle.GetIntervalOffset() != 0 || labelStyle.GetInterval() != 0)) { fromSeries = false; } // Get value type ChartValueType valueType; if (axisType == AxisName.X || axisType == AxisName.X2) { // If X value is indexed the type is always String. So we use indexed type instead valueType = Common.DataManager.Series[dataSeries[0]].indexedXValueType; } else { valueType = Common.DataManager.Series[dataSeries[0]].YValueType; } if (labelStyle.GetIntervalType() != DateTimeIntervalType.Auto && labelStyle.GetIntervalType() != DateTimeIntervalType.Number && valueType != ChartValueType.Time && valueType != ChartValueType.Date && valueType != ChartValueType.DateTimeOffset) { valueType = ChartValueType.DateTime; } // *********************************** // Pre calculate some values // *********************************** double viewMaximum = ViewMaximum; double viewMinimum = ViewMinimum; // *********************************** // Labels are filled from data series. // *********************************** if (fromSeries) { int numOfPoints; numOfPoints = Common.DataManager.GetNumberOfPoints(dataSeries.ToArray()); // Show end labels if (endLabels == 1) { // min position CustomLabels.Add(-0.5, 0.5, ValueConverter.FormatValue( Common.Chart, this, null, 0.0, LabelStyle.Format, valueType, ChartElementType.AxisLabels), false); } // Labels from point position for (int point = 0; point < numOfPoints; point++) { CustomLabels.Add(point + 0.5, point + 1.5, ValueConverter.FormatValue( Common.Chart, this, null, point + 1, LabelStyle.Format, valueType, ChartElementType.AxisLabels), false); } // Show end labels if (endLabels == 1) { // max position CustomLabels.Add(numOfPoints + 0.5, numOfPoints + 1.5, ValueConverter.FormatValue( Common.Chart, this, null, numOfPoints + 1, LabelStyle.Format, valueType, ChartElementType.AxisLabels), false); } int pointIndx; foreach (string seriesIndx in dataSeries) { // End labels enabled if (endLabels == 1) { pointIndx = 1; } else { pointIndx = 0; } // Set labels from data points labels foreach (DataPoint dataPoint in Common.DataManager.Series[seriesIndx].Points) { // Find first row of labels while (CustomLabels[pointIndx].RowIndex > 0) { pointIndx++; } // Add X labels if ((axisType == AxisName.X || axisType == AxisName.X2) && dataPoint.AxisLabel.Length > 0) { CustomLabels[pointIndx].Text = dataPoint.AxisLabel; } pointIndx++; } } } // *********************************** // Labels are filled from axis scale. // *********************************** else { if (viewMinimum == viewMaximum) { return; } double labValue; // Value, which will be converted to text and used for, labels. double beginPosition; // Begin position for a label double endPosition; // End position for a label double start; // Start position for all labels // Get first series attached to this axis Series axisSeries = null; if (axisType == AxisName.X || axisType == AxisName.X2) { List <string> seriesArray = ChartArea.GetXAxesSeries((axisType == AxisName.X) ? AxisType.Primary : AxisType.Secondary, SubAxisName); if (seriesArray.Count > 0) { axisSeries = Common.DataManager.Series[seriesArray[0]]; if (axisSeries != null && !axisSeries.IsXValueIndexed) { axisSeries = null; } } } // *********************************** // Check if the AJAX zooming and scrolling mode is enabled. // Labels are filled slightly different in this case. // *********************************** DateTimeIntervalType offsetType = (labelStyle.GetIntervalOffsetType() == DateTimeIntervalType.Auto) ? labelStyle.GetIntervalType() : labelStyle.GetIntervalOffsetType(); // By default start is equal to minimum start = viewMinimum; // Adjust start position depending on the interval type if (!ChartArea.chartAreaIsCurcular || axisType == AxisName.Y || axisType == AxisName.Y2) { start = ChartHelper.AlignIntervalStart(start, labelStyle.GetInterval(), labelStyle.GetIntervalType(), axisSeries); } // Move start if there is start position if (labelStyle.GetIntervalOffset() != 0 && axisSeries == null) { start += ChartHelper.GetIntervalSize(start, labelStyle.GetIntervalOffset(), offsetType, axisSeries, 0, DateTimeIntervalType.Number, true, false); } // *************************************** // Date type // *************************************** if (valueType == ChartValueType.DateTime || valueType == ChartValueType.Date || valueType == ChartValueType.Time || valueType == ChartValueType.DateTimeOffset || axisSeries != null) { double position = start; double dateInterval; // Too many labels if ((viewMaximum - start) / ChartHelper.GetIntervalSize(start, labelStyle.GetInterval(), labelStyle.GetIntervalType(), axisSeries, 0, DateTimeIntervalType.Number, true) > ChartHelper.MaxNumOfGridlines) { return; } int counter = 0; double endLabelMaxPosition = viewMaximum - ChartHelper.GetIntervalSize(viewMaximum, labelStyle.GetInterval(), labelStyle.GetIntervalType(), axisSeries, labelStyle.GetIntervalOffset(), offsetType, true) / 2f; double endLabelMinPosition = viewMinimum + ChartHelper.GetIntervalSize(viewMinimum, labelStyle.GetInterval(), labelStyle.GetIntervalType(), axisSeries, labelStyle.GetIntervalOffset(), offsetType, true) / 2f; while ((decimal)position <= (decimal)viewMaximum) { dateInterval = ChartHelper.GetIntervalSize(position, labelStyle.GetInterval(), labelStyle.GetIntervalType(), axisSeries, labelStyle.GetIntervalOffset(), offsetType, true); labValue = position; // For IsLogarithmic axes if (IsLogarithmic) { labValue = Math.Pow(logarithmBase, labValue); } // Check if we do not exceed max number of elements if (counter++ > ChartHelper.MaxNumOfGridlines) { break; } if (endLabels == 0 && position >= endLabelMaxPosition) { break; } beginPosition = position - dateInterval * 0.5; endPosition = position + dateInterval * 0.5; if (endLabels == 0 && position <= endLabelMinPosition) { position += dateInterval; continue; } if ((decimal)beginPosition > (decimal)viewMaximum) { position += dateInterval; continue; } string pointLabel = GetPointLabel(dataSeries, labValue, !seriesXValuesZeros, indexedSeries); if (pointLabel.Length == 0) { // Do not draw last label for indexed series if (position <= maximum && (position != maximum || !Common.DataManager.Series[dataSeries[0]].IsXValueIndexed)) { CustomLabels.Add(beginPosition, endPosition, ValueConverter.FormatValue( Common.Chart, this, null, labValue, LabelStyle.Format, valueType, ChartElementType.AxisLabels), false); } } else { // Add a label to the collection CustomLabels.Add(beginPosition, endPosition, pointLabel, false); } position += dateInterval; } } else { // *************************************** // Scale value type // *************************************** // Show First label if Start Label position is used if (start != viewMinimum) { endLabels = 1; } // Set labels int labelCounter = 0; for (double position = start - endLabels * labelStyle.GetInterval(); position < viewMaximum - 1.5 * labelStyle.GetInterval() * (1 - endLabels); position = (double)((decimal)position + (decimal)labelStyle.GetInterval())) { // Prevent endless loop that may be caused by very small interval // and double/decimal rounding errors ++labelCounter; if (labelCounter > ChartHelper.MaxNumOfGridlines) { break; } labValue = (double)((decimal)position + (decimal)labelStyle.GetInterval()); // This line is introduce because sometimes 0 value will appear as // very small value close to zero. double inter = Math.Log(labelStyle.GetInterval()); double valu = Math.Log(Math.Abs(labValue)); int digits = (int)Math.Abs(inter) + 5; if (digits > 15) { digits = 15; } if (Math.Abs(inter) < Math.Abs(valu) - 5) { labValue = Math.Round(labValue, digits); } // Too many labels if ((viewMaximum - start) / labelStyle.GetInterval() > ChartHelper.MaxNumOfGridlines) { return; } // For IsLogarithmic axes if (IsLogarithmic) { labValue = Math.Pow(logarithmBase, labValue); } beginPosition = (double)((decimal)position + (decimal)labelStyle.GetInterval() * 0.5m); endPosition = (double)((decimal)position + (decimal)labelStyle.GetInterval() * 1.5m); if ((decimal)beginPosition > (decimal)viewMaximum) { continue; } // Show End label if Start Label position is used // Use decimal type to solve rounding issues if ((decimal)((beginPosition + endPosition) / 2.0) > (decimal)viewMaximum) { continue; } string pointLabel = GetPointLabel(dataSeries, labValue, !seriesXValuesZeros, indexedSeries); if (pointLabel.Length > 15 && labValue < 0.000001) { labValue = 0.0; } if (pointLabel.Length == 0) { // Do not draw last label for indexed series if (!(Common.DataManager.Series[dataSeries[0]].IsXValueIndexed && position > maximum)) { // Add a label to the collection CustomLabels.Add(beginPosition, endPosition, ValueConverter.FormatValue( Common.Chart, this, null, labValue, LabelStyle.Format, valueType, ChartElementType.AxisLabels), false); } } else { // Add a label to the collection CustomLabels.Add(beginPosition, endPosition, pointLabel, false); } } } } }
public ArrayList GetDataPointDrawingOrder(ArrayList seriesNamesList, IChartType chartType, bool selection, COPCoordinates coord, IComparer comparer, int mainYValueIndex, bool sideBySide) { ChartArea chartArea = (ChartArea)this; ArrayList arrayList = new ArrayList(); double num = 1.0; if (chartArea.Area3DStyle.Clustered && !chartType.Stacked && sideBySide) { num = (double)seriesNamesList.Count; } if (chartType.SupportStackedGroups) { int numberOfStackGroups = this.GetNumberOfStackGroups(seriesNamesList); if (this.Area3DStyle.Clustered && seriesNamesList.Count > 0) { num = (double)numberOfStackGroups; } } bool flag = chartArea.IndexedSeries((string[])seriesNamesList.ToArray(typeof(string))); int num2 = 0; foreach (object seriesNames in seriesNamesList) { Series series = base.Common.DataManager.Series[(string)seriesNames]; if (chartType.SupportStackedGroups && this.stackGroupNames != null) { string empty = string.Empty; num2 = this.GetSeriesStackGroupIndex(series, ref empty); if (chartType is StackedColumnChart) { ((StackedColumnChart)chartType).currentStackGroup = empty; } else if (chartType is StackedBarChart) { ((StackedBarChart)chartType).currentStackGroup = empty; } } Axis axis = (series.YAxisType == AxisType.Primary) ? chartArea.AxisY : chartArea.AxisY2; Axis axis2 = (series.XAxisType == AxisType.Primary) ? chartArea.AxisX : chartArea.AxisX2; axis2.GetViewMinimum(); axis2.GetViewMaximum(); axis.GetViewMinimum(); axis.GetViewMaximum(); bool flag2 = true; double interval = 1.0; if (!flag) { interval = ((ChartAreaAxes)chartArea).GetPointsInterval(seriesNamesList, axis2.Logarithmic, axis2.logarithmBase, true, out flag2); } double num3 = series.GetPointWidth(chartArea.Common.graph, axis2, interval, 0.8) / num; float depth = default(float); float zPosition = default(float); this.GetSeriesZPositionAndDepth(series, out depth, out zPosition); int num4 = 0; foreach (DataPoint point in series.Points) { num4++; double xPosition; double position; if (flag) { xPosition = axis2.GetPosition((double)num4) - num3 * num / 2.0 + num3 / 2.0 + (double)num2 * num3; position = axis2.GetPosition((double)num4); } else if (flag2) { xPosition = axis2.GetPosition(point.XValue) - num3 * num / 2.0 + num3 / 2.0 + (double)num2 * num3; position = axis2.GetPosition(point.XValue); } else { xPosition = axis2.GetPosition(point.XValue); position = axis2.GetPosition(point.XValue); } DataPoint3D dataPoint3D = new DataPoint3D(); dataPoint3D.indexedSeries = flag; dataPoint3D.dataPoint = point; dataPoint3D.index = num4; dataPoint3D.xPosition = xPosition; dataPoint3D.xCenterVal = position; dataPoint3D.width = series.GetPointWidth(chartArea.Common.graph, axis2, interval, 0.8) / num; dataPoint3D.depth = depth; dataPoint3D.zPosition = zPosition; double yValue = chartType.GetYValue(base.Common, chartArea, series, point, num4 - 1, mainYValueIndex); dataPoint3D.yPosition = axis.GetPosition(yValue); dataPoint3D.height = axis.GetPosition(yValue - chartType.GetYValue(base.Common, chartArea, series, point, num4 - 1, -1)); arrayList.Add(dataPoint3D); } if (num > 1.0 && sideBySide) { num2++; } } if (comparer == null) { comparer = new PointsDrawingOrderComparer((ChartArea)this, selection, coord); } arrayList.Sort(comparer); return(arrayList); }
internal static Series CreateNewSeries(Chart control, string suggestedChartArea) { int countSeries = control.Series.Count + 1; string seriesName = "Series" + countSeries.ToString(System.Globalization.CultureInfo.InvariantCulture); // Check if this name already in use bool seriesFound = true; while (seriesFound) { seriesFound = false; foreach (Series series in control.Series) { if (series.Name == seriesName) { seriesFound = true; } } if (seriesFound) { ++countSeries; seriesName = "Series" + countSeries.ToString(System.Globalization.CultureInfo.InvariantCulture); } } // Create new series Series newSeries = new Series(seriesName); // Check if default chart area name exists if (control.ChartAreas.Count > 0) { bool defaultFound = false; if (!string.IsNullOrEmpty(suggestedChartArea) && control.ChartAreas.IndexOf(suggestedChartArea) != -1) { newSeries.ChartArea = suggestedChartArea; defaultFound = true; } else { foreach (ChartArea area in control.ChartAreas) { if (area.Name == newSeries.ChartArea) { defaultFound = true; break; } } } // If default chart area was not found - use name of the first area if (!defaultFound) { newSeries.ChartArea = control.ChartAreas[0].Name; } // Check if series area is circular if (control.ChartAreas[newSeries.ChartArea].chartAreaIsCurcular) { // Change default chart type newSeries.ChartTypeName = ChartTypeNames.Radar; // Check if it's a Polar chart type IChartType chartType = control.ChartAreas[newSeries.ChartArea].GetCircularChartType() as IChartType; if (chartType != null && String.Compare(chartType.Name, ChartTypeNames.Polar, StringComparison.OrdinalIgnoreCase) == 0) { newSeries.ChartTypeName = ChartTypeNames.Polar; } } } return(newSeries); }
private void GetValuesFromData(Axis axis, out double autoMinimum, out double autoMaximum) { int numberOfAllPoints = this.GetNumberOfAllPoints(); if (!axis.refreshMinMaxFromData && !double.IsNaN(axis.minimumFromData) && !double.IsNaN(axis.maximumFromData) && axis.numberOfPointsInAllSeries == numberOfAllPoints) { autoMinimum = axis.minimumFromData; autoMaximum = axis.maximumFromData; } else { AxisType type = AxisType.Primary; if (axis.axisType == AxisName.X2 || axis.axisType == AxisName.Y2) { type = AxisType.Secondary; } string[] array = (string[])this.GetXAxesSeries(type, axis.SubAxisName).ToArray(typeof(string)); string[] seriesNames = (string[])this.GetYAxesSeries(type, axis.SubAxisName).ToArray(typeof(string)); if (axis.axisType == AxisName.X2 || axis.axisType == AxisName.X) { if (this.stacked) { try { base.Common.DataManager.GetMinMaxXValue(out autoMinimum, out autoMaximum, array); } catch (Exception) { throw new InvalidOperationException(SR.ExceptionAxisStackedChartsDataPointsNumberMismatch); } } else if (this.secondYScale) { autoMaximum = base.Common.DataManager.GetMaxXWithRadiusValue((ChartArea)this, array); autoMinimum = base.Common.DataManager.GetMinXWithRadiusValue((ChartArea)this, array); ChartValueTypes xValueType = base.Common.DataManager.Series[array[0]].XValueType; if (xValueType != ChartValueTypes.Date && xValueType != ChartValueTypes.DateTime && xValueType != ChartValueTypes.Time && xValueType != ChartValueTypes.DateTimeOffset) { axis.roundedXValues = true; } } else { base.Common.DataManager.GetMinMaxXValue(out autoMinimum, out autoMaximum, array); } } else if (this.stacked) { try { if (this.hundredPercent) { autoMaximum = base.Common.DataManager.GetMaxHundredPercentStackedYValue(this.hundredPercentNegative, 0, seriesNames); autoMinimum = base.Common.DataManager.GetMinHundredPercentStackedYValue(this.hundredPercentNegative, 0, seriesNames); } else { double val = -1.7976931348623157E+308; double val2 = 1.7976931348623157E+308; double num = -1.7976931348623157E+308; double num2 = 1.7976931348623157E+308; ArrayList arrayList = this.SplitSeriesInStackedGroups(seriesNames); foreach (string[] item in arrayList) { double maxStackedYValue = base.Common.DataManager.GetMaxStackedYValue(0, item); double minStackedYValue = base.Common.DataManager.GetMinStackedYValue(0, item); double maxUnsignedStackedYValue = base.Common.DataManager.GetMaxUnsignedStackedYValue(0, item); double minUnsignedStackedYValue = base.Common.DataManager.GetMinUnsignedStackedYValue(0, item); val = Math.Max(val, maxStackedYValue); val2 = Math.Min(val2, minStackedYValue); num = Math.Max(num, maxUnsignedStackedYValue); num2 = Math.Min(num2, minUnsignedStackedYValue); } autoMaximum = Math.Max(val, num); autoMinimum = Math.Min(val2, num2); } if (axis.Logarithmic && autoMinimum < 1.0) { autoMinimum = 1.0; } } catch (Exception) { throw new InvalidOperationException(SR.ExceptionAxisStackedChartsDataPointsNumberMismatch); } } else if (this.secondYScale) { autoMaximum = base.Common.DataManager.GetMaxYWithRadiusValue((ChartArea)this, seriesNames); autoMinimum = base.Common.DataManager.GetMinYWithRadiusValue((ChartArea)this, seriesNames); } else { bool flag = false; if (base.Common != null && base.Common.Chart != null) { foreach (Series item2 in base.Common.Chart.Series) { if (item2.ChartArea == ((ChartArea)this).Name) { IChartType chartType = base.Common.ChartTypeRegistry.GetChartType(item2.ChartTypeName); if (chartType != null && chartType.ExtraYValuesConnectedToYAxis) { flag = true; break; } } } } if (flag) { base.Common.DataManager.GetMinMaxYValue(out autoMinimum, out autoMaximum, seriesNames); } else { base.Common.DataManager.GetMinMaxYValue(0, out autoMinimum, out autoMaximum, seriesNames); } } axis.maximumFromData = autoMaximum; axis.minimumFromData = autoMinimum; axis.refreshMinMaxFromData = false; axis.numberOfPointsInAllSeries = numberOfAllPoints; } }