/// <summary> /// 品牌销量汇总 /// </summary> /// <param name="analysis"></param> /// <returns></returns> public static ChartData GetBrandRanking(List <BrandRanking> analysis) { var labels = analysis.Select(s => s.BrandName).ToList(); var dataSets = new List <ChartDecimalDataset>(); var colors = RandomChartBuilder.GetDefaultColors(); var datas = analysis.Select(s => s.NetAmount ?? 0).ToArray(); dataSets.Add(new ChartDecimalDataset { type = Wesley.ChartJS.ChartTypes.Bar, label = "品牌销量汇总", data = datas, backgroundColor = datas.Select((d, i) => { var color = colors[i % colors.Count]; return($"rgb({color.Item1},{color.Item2},{color.Item3})"); }) }); return(new ChartData() { datasets = dataSets, labels = labels }); }
/// <summary> /// 客户活跃度 /// </summary> /// <param name="analysis"></param> /// <returns></returns> public static ChartData GetCustomerActivity(List <CustomerActivityRanking> analysis) { var labels = analysis.Select(s => s.TerminalName).ToList(); var dataSets = new List <ChartNumberDataset>(); var colors = RandomChartBuilder.GetDefaultColors(); var datas = analysis.Select(s => s.VisitDaySum ?? 0).ToArray(); dataSets.Add(new ChartNumberDataset { type = Wesley.ChartJS.ChartTypes.Line, label = "客户活跃度", data = datas, tension = 0.4, backgroundColor = datas.Select((d, i) => { var color = colors[i % colors.Count]; return($"rgb({color.Item1},{color.Item2},{color.Item3})"); }) }); return(new ChartData() { datasets = dataSets, labels = labels }); }
public static ChartData GetNewCustomers(NewCustomerAnalysis analysis) { var labels = analysis.ChartDatas.Keys.Select(s => s).ToList(); var dataSets = new List <ChartNumberDataset>(); var colors = RandomChartBuilder.GetDefaultColors(); var datas = analysis.ChartDatas.Values.Select(s => System.Convert.ToInt32(s)).ToList(); dataSets.Add(new ChartNumberDataset { type = Wesley.ChartJS.ChartTypes.Line, label = "新增客户", data = datas, tension = 0.4, backgroundColor = datas.Select((d, i) => { var color = colors[i % colors.Count]; return($"rgb({color.Item1},{color.Item2},{color.Item3})"); }) }); return(new ChartData() { datasets = dataSets, labels = labels }); }
/// <summary> /// 销量走势图 /// </summary> /// <param name="analysis"></param> /// <returns></returns> public static ChartData GetSaleTrendChat(List <SaleTrending> analysis) { var labels = analysis.Select(s => s.SaleDateName).ToList(); var dataSets = new List <ChartDecimalDataset>(); var colors = RandomChartBuilder.GetDefaultColors(); var datas = analysis.Select(s => s.NetAmount ?? 0).ToArray(); dataSets.Add(new ChartDecimalDataset { type = Wesley.ChartJS.ChartTypes.Line, label = "销量走势图", data = datas, tension = 0.4, backgroundColor = datas.Select((d, i) => { var color = colors[i % colors.Count]; return($"rgb({color.Item1},{color.Item2},{color.Item3})"); }) }); return(new ChartData() { datasets = dataSets, labels = labels }); }
/// <summary> /// 库存滞销排行榜 /// </summary> /// <param name="analysis"></param> /// <returns></returns> public static ChartData GetUnsalable(List <UnSaleRanking> analysis) { var labels = analysis.Select(s => s.ProductName).ToList(); var dataSets = new List <ChartDecimalDataset>(); var colors = RandomChartBuilder.GetDefaultColors(); var datas = analysis.Select(s => s.TotalSumNetQuantity ?? 0).ToArray(); dataSets.Add(new ChartDecimalDataset { type = Wesley.ChartJS.ChartTypes.Line, label = "库存滞销排行榜", data = datas, tension = 0.4, backgroundColor = datas.Select((d, i) => { var color = colors[i % colors.Count]; return($"rgb({color.Item1},{color.Item2},{color.Item3})"); }) }); return(new ChartData() { datasets = dataSets, labels = labels }); }
/// <summary> /// 销售利润排行 /// </summary> /// <param name="analysis"></param> /// <returns></returns> public static ChartData GetSalesProfitRanking(List <CostProfitRanking> analysis) { var labels = analysis.Select(s => s.ProductName).ToList(); var dataSets = new List <ChartNumberDataset>(); var colors = RandomChartBuilder.GetDefaultColors(); var datas = analysis.Select(s => s.TotalSumNetQuantity ?? 0).ToArray(); dataSets.Add(new ChartNumberDataset { type = Wesley.ChartJS.ChartTypes.Bar, label = "销售利润排行", data = datas, backgroundColor = datas.Select((d, i) => { var color = colors[i % colors.Count]; return($"rgb({color.Item1},{color.Item2},{color.Item3})"); }) }); return(new ChartData() { datasets = dataSets, labels = labels }); }
/// <summary> /// 客户拜访排行 /// </summary> /// <param name="analysis"></param> /// <returns></returns> public static ChartData GetCustomerVisitRank(List <BusinessVisitRank> analysis) { var labels = analysis.Select(s => s.BusinessUserName).ToList(); var dataSets = new List <ChartNumberDataset>(); var colors = RandomChartBuilder.GetDefaultColors(); var datas = analysis.Select(s => s.VisitedCount ?? 0).ToArray(); dataSets.Add(new ChartNumberDataset { type = Wesley.ChartJS.ChartTypes.Bar, label = "客户拜访排行", data = datas, backgroundColor = datas.Select((d, i) => { var color = colors[i % colors.Count]; return($"rgb({color.Item1},{color.Item2},{color.Item3})"); }) }); return(new ChartData() { datasets = dataSets, labels = labels }); }
/// <summary> /// 热销排行榜 /// </summary> /// <param name="analysis"></param> /// <returns></returns> public static ChartData GetHotSalesRanking(List <HotSaleRanking> analysis, bool showLable = true) { var labels = analysis.Select(s => s.ProductName).ToList(); var dataSets = new List <ChartDecimalDataset>(); var colors = RandomChartBuilder.GetDefaultColors(); var datas = analysis.Select(s => s.TotalSumNetQuantity ?? 0).ToArray(); dataSets.Add(new ChartDecimalDataset { type = DCMS.ChartJS.ChartTypes.Bar, label = "热销排行榜", data = datas, backgroundColor = datas.Select((d, i) => { var color = colors[i % colors.Count]; return($"rgb({color.Item1},{color.Item2},{color.Item3})"); }) }); return(new ChartData() { datasets = dataSets, labels = labels }); }
private ChartData GetChartData(BusinessAnalysis analysis) { var labels = analysis.UserNames; var dataSets = new List <ChartNumberDataset>(); var colors = RandomChartBuilder.GetDefaultColors(); dataSets.Add(new ChartNumberDataset { type = Wesley.ChartJS.ChartTypes.Bar, label = "拜访量", data = analysis.VistCounts, tension = 0.4, indexAxis = "y", backgroundColor = analysis.VistCounts.Select((d, i) => { //var color = colors[i % colors.Count]; return($"rgb({colors[0].Item1},{colors[0].Item2},{colors[0].Item3})"); }), }); dataSets.Add(new ChartNumberDataset { type = Wesley.ChartJS.ChartTypes.Bar, label = "销单数", data = analysis.SaleCounts, tension = 0.4, indexAxis = "y", backgroundColor = analysis.VistCounts.Select((d, i) => { //var color = colors[i % colors.Count]; return($"rgb({colors[3].Item1},{colors[3].Item2},{colors[3].Item3})"); }) }); //dataSets.Add(new ChartNumberDataset //{ // type = Wesley.ChartJS.ChartTypes.Bar, // label = "销订数", // data = analysis.OrderCounts, // tension = 0.4, // backgroundColor = analysis.VistCounts.Select((d, i) => // { // return $"rgb({colors[5].Item1},{colors[5].Item2},{colors[5].Item3})"; // }) //}); return(new ChartData() { datasets = dataSets, labels = labels }); }
private ChartData GetChartData(SaleAnalysis analysis) { var labels = new[] { "今日净额", "昨天净额", "前天净额", "上周净额", "本周净额", "上月净额", "本季净额", "本年净额" }.ToList(); var dataSets = new List <ChartDecimalDataset>(); var colors = RandomChartBuilder.GetDefaultColors(); var datas = new decimal[] { analysis.Today?.NetAmount ?? 0, analysis.Yesterday?.NetAmount ?? 0, analysis.BeforeYesterday?.NetAmount ?? 0, analysis.LastWeek?.NetAmount ?? 0, analysis.ThisWeek?.NetAmount ?? 0, analysis.LastMonth?.NetAmount ?? 0, analysis.ThisQuarter?.NetAmount ?? 0, analysis.ThisYear?.NetAmount ?? 0, }; var descriptionChart = "今日销售净额"; if ((analysis?.Today?.NetAmount ?? 0) > (analysis?.LastWeekSame?.NetAmount ?? 0)) { descriptionChart = $"今日销售净额 {(analysis?.LastWeekSame?.NetAmount ?? 0)},比上周同期增加了 {((analysis?.Today?.NetAmount ?? 0) - (analysis?.LastWeekSame?.NetAmount ?? 0))}"; } else if ((analysis?.Today?.NetAmount ?? 0) < (analysis?.LastWeekSame?.NetAmount ?? 0)) { descriptionChart = $"今日销售净额 {(analysis?.LastWeekSame?.NetAmount ?? 0)},比上周同期减少了 {Math.Abs((analysis?.Today?.NetAmount ?? 0) - (analysis?.LastWeekSame?.NetAmount ?? 0))}"; } dataSets.Add(new ChartDecimalDataset { type = Wesley.ChartJS.ChartTypes.Doughnut, label = descriptionChart, data = datas, backgroundColor = datas.Select((d, i) => { var color = colors[i % colors.Count]; return($"rgb({color.Item1},{color.Item2},{color.Item3})"); }) }); return(new ChartData() { datasets = dataSets, labels = labels }); }
public static ChartData GetVisitingRate(CustomerVistAnalysis analysis) { float up = 100; if (analysis.TotalCustomer - analysis.Today.VistCount != 0) { if (analysis.TotalCustomer == 0) { analysis.TotalCustomer = 1; } up = (float)((analysis.TotalCustomer - analysis.Today.VistCount) / analysis.TotalCustomer) * 100; } var labels = new string[] { "总客户数", "拜访数", "拜访数", }; var dataSets = new List <ChartFloatDataset>(); var colors = RandomChartBuilder.GetDefaultColors(); var datas = new float[] { analysis.TotalCustomer, (float)(analysis?.Today?.Percentage), (up == 0 ? 100 : up) }; dataSets.Add(new ChartFloatDataset { type = Wesley.ChartJS.ChartTypes.Pie, label = "客户拜访分析", data = datas, tension = 0.4, backgroundColor = datas.Select((d, i) => { var color = colors[i % colors.Count]; return($"rgb({color.Item1},{color.Item2},{color.Item3})"); }) }); return(new ChartData() { datasets = dataSets, labels = labels }); }
private ChartData GetChartData(CustomerVistAnalysis analysis) { var labels = new[] { "今日拜访", "昨天拜访", "前天拜访", "上周拜访", "本周拜访", "上月拜访", "本年拜访" }.ToList(); var dataSets = new List <ChartNumberDataset>(); var colors = RandomChartBuilder.GetDefaultColors(); var datas = new int[] { analysis.Today?.VistCount ?? 0, analysis.Yesterday?.VistCount ?? 0, analysis.BeforeYesterday?.VistCount ?? 0, analysis.LastWeek?.VistCount ?? 0, analysis.ThisWeek?.VistCount ?? 0, analysis.LastMonth?.VistCount ?? 0, analysis.ThisYear?.VistCount ?? 0, }; dataSets.Add(new ChartNumberDataset { type = Wesley.ChartJS.ChartTypes.Bar, label = "客户拜访分析", data = datas, backgroundColor = datas.Select((d, i) => { var color = colors[i % colors.Count]; return($"rgb({color.Item1},{color.Item2},{color.Item3})"); }) }); return(new ChartData() { datasets = dataSets, labels = labels }); }