Esempio n. 1
0
        public void Refresh(List <BusinessRanking> analysis)
        {
            RankSeries       = new ObservableCollection <BusinessRanking>(analysis);
            SaleAmount       = analysis.Select(s => s.SaleAmount).Sum();
            SaleReturnAmount = analysis.Select(s => s.SaleReturnAmount).Sum();
            NetAmount        = analysis.Select(s => s.NetAmount).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 = Wesley.ChartJS.ChartTypes.Bar,
                    data = ChartDataProvider.GetSalesRanking(ranks)
                }
            };

            ChartConfig = data;
        }
Esempio n. 2
0
        /// <summary>
        /// 业务销售排行
        /// </summary>
        /// <param name="app"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        private async Task <ChartViewConfig> SalesRankingPage_Chart(Module app, string title)
        {
            ChartViewConfig chartData = null;

            try
            {
                var result = await _reportingService.GetBusinessRankingAsync(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();
                    }

                    if (series != null && series.Any())
                    {
                        chartData = new ChartViewConfig()
                        {
                            BackgroundColor = Color.White,
                            ChartConfig     = new ChartConfig
                            {
                                type = Wesley.ChartJS.ChartTypes.Bar,
                                data = ChartDataProvider.GetSalesRanking(result.ToList())
                            }
                        };
                    }
                }
                return(chartData);
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
                return(chartData);
            }
        }