/// <summary> /// Updates the values of the rating items. /// </summary> private void UpdateValues() { IList <RatingItem> ratingItems = GetRatingItems().ToList(); RatingItem oldSelectedItem = this.GetSelectedRatingItem(); IEnumerable <Tuple <RatingItem, double> > itemAndWeights = EnumerableFunctions .Zip( ratingItems, ratingItems .Select(ratingItem => 1.0) .GetWeightedValues(WeightedValue), (item, percent) => Tuple.Create(item, percent)); foreach (Tuple <RatingItem, double> itemAndWeight in itemAndWeights) { itemAndWeight.Item1.Value = itemAndWeight.Item2; } RatingItem newSelectedItem = this.GetSelectedRatingItem(); if (HoveredRatingItem == null) { DisplayValue = WeightedValue; } }
/// <summary> /// Calculates the length of the data points. /// </summary> protected void CalculateDataPointLength() { if (!(ActualIndependentAxis is ICategoryAxis)) { IEnumerable <UnitValue> values = ActiveDataPoints .Select(dataPoint => ActualIndependentAxis.GetPlotAreaCoordinate(dataPoint.ActualIndependentValue)) .Where(value => ValueHelper.CanGraph(value.Value)) .OrderBy(value => value.Value) .ToList(); _dataPointlength = EnumerableFunctions.Zip( values, values.Skip(1), (left, right) => new Range <double>(left.Value, right.Value)) .Select(range => range.Maximum - range.Minimum) .MinOrNullable(); } }
/// <summary> /// Updates the value and actual value of the rating items. /// </summary> private void UpdateDisplayValues() { IList <RatingItem> ratingItems = GetRatingItems().ToList(); IEnumerable <Tuple <RatingItem, double> > itemAndWeights = EnumerableFunctions .Zip( ratingItems, ratingItems .Select(ratingItem => 1.0) .GetWeightedValues(WeightedValue), (item, percent) => Tuple.Create(item, percent)); RatingItem selectedItem = null; Tuple <RatingItem, double> selectedItemAndWeight = itemAndWeights.LastOrDefault(i => i.Item2 > 0.0); if (selectedItemAndWeight != null) { selectedItem = selectedItemAndWeight.Item1; } else { selectedItem = GetSelectedRatingItem(); } foreach (Tuple <RatingItem, double> itemAndWeight in itemAndWeights) { if (SelectionMode == RatingSelectionMode.Individual && itemAndWeight.Item1 != selectedItem) { itemAndWeight.Item1.DisplayValue = 0.0; } else { itemAndWeight.Item1.DisplayValue = itemAndWeight.Item2; } } }