private void RefreshData(List <HotSaleRanking> analysis) { RankSeries = new ObservableCollection <HotSaleRanking>(analysis); TotalSumReturnAmount = analysis.Select(s => s.TotalSumReturnAmount ?? 0).Sum(); TotalSumNetAmount = analysis.Select(s => s.TotalSumNetAmount ?? 0).Sum(); var ranks = analysis.ToList(); if (ranks.Count > 10) { ranks = ranks.Take(10).ToList(); } var data = new ChartViewConfig() { BackgroundColor = Color.White, ChartConfig = new ChartConfig { type = DCMS.ChartJS.ChartTypes.Bar, data = ChartDataProvider.GetHotSalesRanking(ranks) } }; ChartConfig = data; }
/// <summary> /// 热销排行榜 /// </summary> /// <param name="app"></param> /// <param name="title"></param> /// <returns></returns> private async Task <ChartViewConfig> HotSalesRankingPage_Chart(Module app, string title) { ChartViewConfig chartData = null; try { var result = await _reportingService.GetHotSaleRankingAsync(0, 0, 0, 0, DateTime.Now.AddDays(-15), DateTime.Now, this.ForceRefresh, new System.Threading.CancellationToken()); if (result != null && result.Any()) { var series = result.ToList(); if (series.Count > 50) { series = result.Take(50).ToList(); } chartData = new ChartViewConfig() { BackgroundColor = Color.White, ChartConfig = new ChartConfig { type = Wesley.ChartJS.ChartTypes.Bar, data = ChartDataProvider.GetHotSalesRanking(series) } }; } return(chartData); } catch (Exception ex) { Crashes.TrackError(ex); return(chartData); } }