internal override void AdjustDataPointLabelVisibilityRating(LabelVisibilityManager.DataPointRange range, Dictionary <XYDataPoint, double> dataPointRanks) { BubbleDataPoint bubbleDataPoint1 = (BubbleDataPoint)null; double num = double.MinValue; foreach (XYDataPoint xyDataPoint in range.DataPoints) { BubbleDataPoint bubbleDataPoint2 = xyDataPoint as BubbleDataPoint; if (bubbleDataPoint2 != null && bubbleDataPoint2.SizeValueInScaleUnitsWithoutAnimation > num) { num = bubbleDataPoint2.SizeValueInScaleUnitsWithoutAnimation; bubbleDataPoint1 = bubbleDataPoint2; } } if (bubbleDataPoint1 == null) { return; } if (dataPointRanks.ContainsKey((XYDataPoint)bubbleDataPoint1)) { Dictionary <XYDataPoint, double> dictionary; XYDataPoint index; (dictionary = dataPointRanks)[index = (XYDataPoint)bubbleDataPoint1] = dictionary[index] + 150.0; } else { dataPointRanks.Add((XYDataPoint)bubbleDataPoint1, 150.0); } }
private Dictionary <XYDataPoint, double> GetDefaultRanking(LabelVisibilityManager.DataPointRange range, LabelVisibilityManager.DataPointRange prevRange, ref bool useMaximum) { Dictionary <XYDataPoint, double> dictionary = new Dictionary <XYDataPoint, double>(); if (!range.ProjectedYRange.HasData) { double num1 = 0.05; if (prevRange != null && prevRange.DataPointProjectedYRange.HasData && range.DataPointProjectedYRange.HasData) { if (range.DataPointProjectedYRange.Maximum - prevRange.DataPointProjectedYRange.Maximum > num1 && range.DataPointProjectedYRange.Minimum - prevRange.DataPointProjectedYRange.Minimum > num1) { useMaximum = true; } else if (prevRange.DataPointProjectedYRange.Maximum - range.DataPointProjectedYRange.Maximum > num1 && prevRange.DataPointProjectedYRange.Minimum - range.DataPointProjectedYRange.Minimum > num1) { useMaximum = false; } else if (range.DataPointProjectedYRange.Maximum - prevRange.DataPointProjectedYRange.Maximum > num1 && prevRange.DataPointProjectedYRange.Minimum - range.DataPointProjectedYRange.Minimum > num1) { double num2 = Math.Abs(range.DataPointProjectedYRange.Maximum - prevRange.DataPointProjectedYRange.Maximum); double num3 = Math.Abs(range.DataPointProjectedYRange.Minimum - prevRange.DataPointProjectedYRange.Minimum); useMaximum = num2 > num3; } else { useMaximum = !useMaximum; } } } XYDataPoint key = (XYDataPoint)null; double d = double.NaN; foreach (XYDataPoint xyDataPoint in range.DataPoints) { if (double.IsNaN(d)) { key = xyDataPoint; d = xyDataPoint.YValueInScaleUnitsWithoutAnimation; } else if (useMaximum && d < xyDataPoint.YValueInScaleUnitsWithoutAnimation) { key = xyDataPoint; d = xyDataPoint.YValueInScaleUnitsWithoutAnimation; } else if (!useMaximum && d >= xyDataPoint.YValueInScaleUnitsWithoutAnimation) { key = xyDataPoint; d = xyDataPoint.YValueInScaleUnitsWithoutAnimation; } } if (key != null) { dictionary.Add(key, 50.0); } if (range.ProjectedYRange.HasData) { useMaximum = !useMaximum; } return(dictionary); }
internal override void AdjustDataPointLabelVisibilityRating(LabelVisibilityManager.DataPointRange range, Dictionary <XYDataPoint, double> dataPointRanks) { XYDataPoint key = (XYDataPoint)null; if (range.DataPoints.Count > 0) { key = range.DataPoints[range.DataPoints.Count / 2] as XYDataPoint; } if (key == null) { return; } if (dataPointRanks.ContainsKey(key)) { Dictionary <XYDataPoint, double> dictionary; XYDataPoint index; (dictionary = dataPointRanks)[index = key] = dictionary[index] + 150.0; } else { dataPointRanks.Add(key, 150.0); } }
internal override void AdjustDataPointLabelVisibilityRating(LabelVisibilityManager.DataPointRange range, Dictionary <XYDataPoint, double> dataPointRanks) { if (range.DataPoints.Count <= 0) { return; } XYDataPoint xyDataPoint = range.DataPoints[0] as XYDataPoint; foreach (XYDataPoint key in range.DataPoints) { if (ValueHelper.Compare(key.XValue as IComparable, xyDataPoint.XValue as IComparable) == 0) { if (dataPointRanks.ContainsKey(key)) { dataPointRanks[key] = 100.0; } else { dataPointRanks.Add(key, 100.0); } } } }
internal override void AdjustDataPointLabelVisibilityRating(LabelVisibilityManager.DataPointRange range, Dictionary <XYDataPoint, double> dataPointRanks) { }
public virtual void UpdateDataPointLabelVisibility() { DateTime now = DateTime.Now; if (this._xScalePositions == null) { this.RecalculateXIntervals(); } if (this._yScalePositions == null) { this.RecalculateYIntervals(); } if (this._chartArea == null || this._chartArea.Series.Count <= 0) { return; } if (this._dataPointRanges.Count == 0) { this.CreateDataPointRanges(); } List <XYDataPoint> list = new List <XYDataPoint>(); Dictionary <Type, SeriesPresenter> dictionary = new Dictionary <Type, SeriesPresenter>(); foreach (Series series in this._chartArea.Series) { if (!dictionary.ContainsKey(series.SeriesPresenter.GetType())) { dictionary.Add(series.SeriesPresenter.GetType(), series.SeriesPresenter); } if (series.Visibility == Visibility.Visible && series.LabelVisibility == Visibility.Visible) { foreach (XYDataPoint xyDataPoint in ((XYSeriesPresenter)series.SeriesPresenter).Series.DataPointsByXValue) { if (xyDataPoint.ActualLabelContent != null && xyDataPoint.XValueInScaleUnitsWithoutAnimation >= 0.0 && (xyDataPoint.XValueInScaleUnitsWithoutAnimation <= 1.0 && xyDataPoint.Visibility == Visibility.Visible)) { if (this.IsOnlyXAxisUsed) { list.Add(xyDataPoint); } else if (xyDataPoint.YValueInScaleUnitsWithoutAnimation >= 0.0 && xyDataPoint.YValueInScaleUnitsWithoutAnimation <= 1.0) { list.Add(xyDataPoint); } } } } } if (list.Count < 30) { foreach (DataPoint dataPoint in list) { dataPoint.ActualLabelVisibility = Visibility.Visible; } } else { foreach (LabelVisibilityManager.DataPointRange dataPointRange in this._dataPointRanges) { dataPointRange.DataPoints.Clear(); dataPointRange.DataPointProjectedYRange = Range <double> .Empty; for (int index = 0; index < list.Count; ++index) { XYDataPoint xyDataPoint = list[index]; if (xyDataPoint.XValueInScaleUnitsWithoutAnimation >= dataPointRange.ProjectedXRange.Minimum && xyDataPoint.XValueInScaleUnitsWithoutAnimation < dataPointRange.ProjectedXRange.Maximum && (!dataPointRange.ProjectedYRange.HasData || xyDataPoint.YValueInScaleUnitsWithoutAnimation >= dataPointRange.ProjectedYRange.Minimum && xyDataPoint.YValueInScaleUnitsWithoutAnimation < dataPointRange.ProjectedYRange.Maximum)) { dataPointRange.DataPoints.Add((DataPoint)xyDataPoint); dataPointRange.DataPointProjectedYRange = dataPointRange.DataPointProjectedYRange.Add(xyDataPoint.YValueInScaleUnitsWithoutAnimation); list.RemoveAt(index); --index; } } } foreach (DataPoint dataPoint in list) { dataPoint.ActualLabelVisibility = Visibility.Collapsed; } bool useMaximum = true; LabelVisibilityManager.DataPointRange prevRange = (LabelVisibilityManager.DataPointRange)null; foreach (LabelVisibilityManager.DataPointRange range in this._dataPointRanges) { Dictionary <XYDataPoint, double> defaultRanking = this.GetDefaultRanking(range, prevRange, ref useMaximum); prevRange = range; foreach (SeriesPresenter seriesPresenter in dictionary.Values) { seriesPresenter.LabelPresenter.AdjustDataPointLabelVisibilityRating(range, defaultRanking); } double num1 = -1.0; foreach (double num2 in defaultRanking.Values) { if (num2 > num1) { num1 = num2; } } foreach (XYDataPoint key in range.DataPoints) { double num2; if (defaultRanking.TryGetValue(key, out num2) && num2 == num1) { key.ActualLabelVisibility = Visibility.Visible; } else { key.ActualLabelVisibility = Visibility.Collapsed; } } } } }