/// <summary> /// Updates the chart based on the computed data (stored in RawData) /// </summary> protected void RefreshChartAndTable(IEnumerable <Bucket> buckets) { if (buckets == null) { throw new ArgumentNullException(nameof(buckets)); } HistogramableValue hv = SelectedFieldToGraph; int count = 0; double average = 0; gcTrends.Clear(); foreach (Bucket b in buckets) { gcTrends.XVals.Add(gcTrends.XDataType == GoogleColumnDataType.@string ? b.DisplayName : b.OrdinalValue); gcTrends.YVals.Add(b.Values[hv.DataField]); if (!b.ExcludeFromAverage) { average += b.Values[hv.DataField]; count++; } if (b.HasRunningTotals) { gcTrends.Y2Vals.Add(b.RunningTotals[hv.DataField]); } } if (gcTrends.ShowAverage = (ckIncludeAverage.Checked && count > 0)) { gcTrends.AverageValue = average / count; } string szLabel = "{0}"; { switch (hv.DataType) { case HistogramValueTypes.Integer: szLabel = Resources.LocalizedText.ChartTotalsNumOfX; break; case HistogramValueTypes.Time: szLabel = Resources.LocalizedText.ChartTotalsHoursOfX; break; case HistogramValueTypes.Decimal: case HistogramValueTypes.Currency: szLabel = Resources.LocalizedText.ChartTotalsAmountOfX; break; } } gcTrends.YLabel = String.Format(CultureInfo.CurrentCulture, szLabel, hv.DataName); gcTrends.Y2Label = Resources.LocalizedText.ChartRunningTotal; gcTrends.ClickHandlerJS = BucketManager.ChartJScript; pnlChart.Visible = true; }
public static IEnumerable <CustomRatingProgress> CustomRatingsForUser(string szUser) { if (szUser == null) { throw new ArgumentNullException(nameof(szUser)); } Profile pf = Profile.GetUser(szUser); // build a map of all histogrammable values for naming List <HistogramableValue> lst = new List <HistogramableValue>(LogbookEntryDisplay.HistogramableValues); foreach (CustomPropertyType cpt in CustomPropertyType.GetCustomPropertyTypes()) { HistogramableValue hv = LogbookEntryDisplay.HistogramableValueForPropertyType(cpt); if (hv != null) { lst.Add(hv); } } Dictionary <string, HistogramableValue> d = new Dictionary <string, HistogramableValue>(); foreach (HistogramableValue hv in lst) { d[hv.DataField] = hv; } // MUST use the pf.GetPreferenceForKey with one argument because you need the serialize/deserialize to get the correct type conversion. IEnumerable <CustomRatingProgress> rgProgressForUser = pf.GetPreferenceForKey <IEnumerable <CustomRatingProgress> >(szPrefKeyCustomRatings); if (rgProgressForUser == null) { return(Array.Empty <CustomRatingProgress>()); } foreach (CustomRatingProgress crp in rgProgressForUser) { crp.Username = szUser; foreach (CustomRatingProgressItem crpi in crp.ProgressItems) { crpi.FieldFriendlyName = d.TryGetValue(crpi.FieldName, out HistogramableValue hv) ? hv.DataName : crpi.FieldName; } List <CustomRatingProgressItem> lstItems = new List <CustomRatingProgressItem>(crp.ProgressItems); lstItems.Sort((crpi1, crpi2) => { return(crpi1.FARRef.CompareCurrentCultureIgnoreCase(crpi2.FARRef)); }); crp.ProgressItems = lstItems; } return(rgProgressForUser); }