コード例 #1
0
ファイル: PieChartService.cs プロジェクト: kin0428/Splg
        /// <summary>
        /// チャートスクリプト取得
        /// </summary>
        public ChartResult GetChartResult(IChartDto chartDto)
        {
            var targetScript = Flotr2ScriptResource.PieChartScriptTemplete;

            PieChartDto = (PieChartDto)chartDto;

            //ファンクション設定
            targetScript = InjectParameter(targetScript, FunctionParameterKey.FunctionName, PieChartDto.FunctionName);

            //コンテナー設定
            targetScript = InjectScriptParameterByChartContainer(targetScript, PieChartDto.PieChartContainer);

            //プロパティ設定
            targetScript = InjectParameterToProperties(targetScript, PieChartDto.PieChartProperties);

            return new ChartResult()
                    {
                        ChartScript = targetScript,
                        ChartContainerSettings = new ChartContainerSettings()
                                                    {
                                                        ChartContainerId = PieChartDto.PieChartContainer.ViewContainerId,
                                                        ChartContainerClass =  PieChartDto.PieChartContainer.ViewContainerClass
                                                    }
                    };
        }
コード例 #2
0
ファイル: ChartController.cs プロジェクト: kin0428/Splg
        public ActionResult ShowPieChart(PieChartDto pieChartDto)
        {
            var flotr2ChartProvider = new Flotr2ChartProvider();

            var chartResult =  flotr2ChartProvider.GetChartResult(pieChartDto, Flotr2Const.ChartType.Pie);

            return PartialView("~/Views/Chart/Mobile/_Flotr2Chart.cshtml", chartResult);
        }
コード例 #3
0
ファイル: JlgChartService.cs プロジェクト: kin0428/Splg
        /// <summary>
        /// パス成功率用Dto抽出
        /// </summary>
        private PieChartDto PickChartAtPassSucceedAverage(TeamStats teamStats, string viewContainerId, string functionName)
        {
            var tmp = new[]{
                new {Label = JlgChartConst.PassSucceedAtSuccessLabel, X = 0, Y = teamStats.PassIndex.PassSucceed, Value = 0},
                new {Label = JlgChartConst.PassSucceedAtFailedLabel, X = 0, Y = (teamStats.PassIndex.PassFailed), Value = 0 },
             };

            var items = tmp.OrderByDescending(m => m.Y).ToList();

            var pieChartDto = new PieChartDto()
            {
                FunctionName = functionName,
                PieChartContainer = new PieChartContainer()
                {
                    ViewContainerId = viewContainerId,
                    ViewContainerClass = JlgChartConst.ChartCssClassName.pie_chart.ToString(),
                    DataSources = new List<PieDataSource>()
                                      {
                                          new PieDataSource(){ Label = items[0].Label, X = items[0].X, Y = items[0].Y, Value = items[0].Value },
                                          new PieDataSource(){ Label = items[1].Label, X = items[1].X, Y = items[1].Y, Value = items[1].Value },
                                      }
                },
                PieChartProperties = new ChartProperties()
                {
                    IsHtmlText = false,
                    ShadowSize = 0.5m,
                    FontSize = 10.5m,
                    Resolution = 2,
                    Colors = new List<string>() {"#00ff00", "#005500"},
                    Legend = new Legend() { position = Flotr2Const.LegendPosition.se, BackgroundColor = "#FFF", BorderColor = "#AAA" },
                    Pie = new Pie() { IsVisible = true, Explode = 0, SizeRatio = 0.9m, FillOpacity = 0.8m },
                    XAxis = new XAxis() { MinValue = 0, MaxValue = 1, IsVisibleLabels = false },
                    YAxis = new YAxis() { MinValue = 0, MaxValue = 1, IsVisibleLabels = false },
                    Grid = new Grid() { IsVisibleHorizontalLines = false, IsVisibleVerticalLines = false, BackGroundImageAddress = string.Empty, GridOutlineWidth = 0 },
                    Mouse = new Mouse() { IsTrackable = false, TrackFormatter = string.Empty },
                    Bubble = new Bubble() { IsVisible = false, BaseRadius = 0m },
                    Marker = new Marker() { IsVisible = false, FontSize = 10, IsRelative = false, LabelFormatter = string.Empty },
                }
            };

            return pieChartDto;
        }
コード例 #4
0
ファイル: JlgChartService.cs プロジェクト: kin0428/Splg
        /// <summary>
        /// 失点パターンチャートDto抽出
        /// </summary>
        private PieChartDto PickChartAtLostPattern(TeamStats teamStats, string viewContainerId, string functionName)
        {
            var tmp = new[]{
                new {Label = JlgChartConst.GoalIndexAtPkLabel, X = 0, Y = teamStats.LostIndex.AtPk, Value = 0},
                new {Label = JlgChartConst.GoalIndexAtSetPlayDirectlyLabel, X = 0, Y = teamStats.LostIndex.AtSetPlayDirectly, Value = 0 },
                new {Label = JlgChartConst.GoalIndexAtSetPlayLabel, X = 0, Y = teamStats.LostIndex.AtSetPlay, Value = 0},
                new {Label = JlgChartConst.GoalIndexAtCrossLabel, X = 0, Y = teamStats.LostIndex.AtCross, Value = 0},
                new {Label = JlgChartConst.GoalIndexAtThroughPassLabel, X = 0, Y = teamStats.LostIndex.AtThroughPass, Value = 0 },
                new {Label = JlgChartConst.GoalIndexAtShortPassLabel, X = 0, Y = teamStats.LostIndex.AtShortPass, Value = 0  },
                new {Label = JlgChartConst.GoalIndexAtLongPassLabel, X = 0, Y = teamStats.LostIndex.AtLongPass, Value = 0 },
                new {Label = JlgChartConst.GoalIndexAtDribbleLabel, X = 0, Y = teamStats.LostIndex.AtDribble, Value = 0},
                new {Label = JlgChartConst.GoalIndexAtLooseBallLabel,X = 0, Y = teamStats.LostIndex.AtLooseBall, Value = 0},
                new {Label = JlgChartConst.GoalIndexAtOtherLabel,X = 0, Y = teamStats.LostIndex.AtOther, Value = 0}
             };

            var items = tmp.OrderByDescending(m => m.Y).ToList();

            var pieChartDto = new PieChartDto()
            {
                FunctionName = functionName,
                PieChartContainer = new PieChartContainer()
                {
                    ViewContainerId = viewContainerId,

                    //Todo:コンテナ設定用CssClass
                    ViewContainerClass = JlgChartConst.ChartCssClassName.pie_chart.ToString(),
                    DataSources = new List<PieDataSource>()
                    {
                        new PieDataSource(){ Label = items[0].Label, X = items[0].X, Y = items[0].Y, Value = items[0].Value },
                        new PieDataSource(){ Label = items[1].Label, X = items[1].X, Y = items[1].Y, Value = items[1].Value },
                        new PieDataSource(){ Label = items[2].Label, X = items[2].X, Y = items[2].Y, Value = items[2].Value },
                        new PieDataSource(){ Label = items[3].Label, X = items[3].X, Y = items[3].Y, Value = items[3].Value },
                        new PieDataSource(){ Label = items[4].Label, X = items[4].X, Y = items[4].Y, Value = items[4].Value },
                        new PieDataSource(){ Label = items[5].Label, X = items[5].X, Y = items[5].Y, Value = items[5].Value },
                        new PieDataSource(){ Label = items[6].Label, X = items[6].X, Y = items[6].Y, Value = items[6].Value },
                        new PieDataSource(){ Label = items[7].Label, X = items[7].X, Y = items[7].Y, Value = items[7].Value },
                        new PieDataSource(){ Label = items[8].Label, X = items[8].X, Y = items[8].Y, Value = items[8].Value },
                        new PieDataSource(){ Label = items[9].Label, X = items[9].X, Y = items[9].Y, Value = items[9].Value },
                    }
                },
                PieChartProperties = new ChartProperties()
                {
                    IsHtmlText = false,
                    ShadowSize = 0.5m,
                    FontSize = 10.5m,
                    Resolution = 2,
                    Colors = new List<string>() { "#002b55", "#2b95ff", "#0055aa", "#80bfff", "#d5eaff", "#004080", "#55aaff", "#006ad5", "#aad5ff", "#0080ff" },
                    Legend = new Legend() { position = Flotr2Const.LegendPosition.se, BackgroundColor = "#FFF", BorderColor = "#AAA" },
                    Pie = new Pie() { IsVisible = true, Explode = 0, SizeRatio = 0.9m, FillOpacity = 0.8m },
                    XAxis = new XAxis() { MinValue = 0, MaxValue = 1, IsVisibleLabels = false },
                    YAxis = new YAxis() { MinValue = 0, MaxValue = 1, IsVisibleLabels = false },
                    Grid = new Grid() { IsVisibleHorizontalLines = false, IsVisibleVerticalLines = false, BackGroundImageAddress = string.Empty, GridOutlineWidth = 0 },
                    Mouse = new Mouse() { IsTrackable = false, TrackFormatter = string.Empty },
                    Bubble = new Bubble() { IsVisible = false, BaseRadius = 0m },
                    Marker = new Marker() { IsVisible = false, FontSize = 10, IsRelative = false, LabelFormatter = string.Empty },
                }
            };

            return pieChartDto;
        }
コード例 #5
0
        public async Task <ValueTuple <PieChartDto, PieChartDto, PieChartDto> > StatisticsInventoryAnalysisAsync(
            IServiceProvider serviceProvider,
            Guid?id = null)
        {
            var materialRepo = serviceProvider.GetService <IRepository <Material, Guid> >();
            var productRepo  = serviceProvider.GetService <IRepository <Product, Guid> >();

            if (id == null || id == Guid.Empty)
            {
                var query = await _warehouseRepo.Query()
                            .Join(_inventoryRepo.Query(),
                                  warehouse => warehouse.Id,
                                  inventory => inventory.WarehouseId,
                                  (warehouse, inventory) => new
                {
                    WarehouseName   = warehouse.Name,
                    InventoryName   = inventory.Name,
                    InventoryAmount = inventory.Amount,
                    InventoryNumber = inventory.Number,
                    Category        = inventory.GoodsCategory,
                }).ToListAsync();

                var warehousePie = new PieChartDto
                {
                    Data = query
                           .GroupBy(q => q.WarehouseName)
                           .Select(q => new PieDto
                    {
                        Name  = q.Key,
                        Ratio = (double)q.Sum(t => t.InventoryAmount)
                    })
                           .ToList()
                };

                var materialPie = new PieChartDto
                {
                    Data = query.Where(q => q.Category == GoodsCategory.Material)
                           .Join(await materialRepo.Query().Select(material => new { Number = material.Number, Type = material.Type }).ToListAsync(),
                                 q => q.InventoryNumber,
                                 material => material.Number,
                                 (q, material) => new PieDto
                    {
                        Name  = material.Type,
                        Ratio = q.InventoryAmount
                    })
                           .GroupBy(p => p.Name)
                           .Select(p => new PieDto
                    {
                        Name  = p.Key,
                        Ratio = p.Sum(t => t.Ratio)
                    }).ToList()
                };

                var productPie = new PieChartDto
                {
                    Data = query.Where(q => q.Category == GoodsCategory.Product)
                           .Join(await productRepo.Query().Select(product => new { Number = product.Number, Type = product.Type }).ToListAsync(),
                                 q => q.InventoryNumber,
                                 product => product.Number,
                                 (q, product) => new PieDto
                    {
                        Name  = product.Type,
                        Ratio = q.InventoryAmount
                    })
                           .GroupBy(q => q.Name)
                           .Select(p => new PieDto
                    {
                        Name  = p.Key,
                        Ratio = p.Sum(t => t.Ratio)
                    }).ToList()
                };

                return(warehousePie, materialPie, productPie);
            }
            else
            {
                var query = await _inventoryRepo.Query().Where(inventory => inventory.WarehouseId == id).ToListAsync();

                var materialPie = new PieChartDto
                {
                    Data = query.Where(q => q.GoodsCategory == GoodsCategory.Material)
                           .Join(await materialRepo.Query().Select(material => new { Number = material.Number, Type = material.Type }).ToListAsync(),
                                 q => q.Number,
                                 material => material.Number,
                                 (q, material) => new PieDto
                    {
                        Name  = material.Type,
                        Ratio = q.Amount
                    })
                           .GroupBy(q => q.Name)
                           .Select(p => new PieDto
                    {
                        Name  = p.Key,
                        Ratio = p.Sum(t => t.Ratio)
                    }).ToList()
                };

                var productPie = new PieChartDto
                {
                    Data = query.Where(q => q.GoodsCategory == GoodsCategory.Product)
                           .Join(await productRepo.Query().Select(product => new { Number = product.Number, Type = product.Type }).ToListAsync(),
                                 q => q.Number,
                                 product => product.Number,
                                 (q, product) => new PieDto
                    {
                        Name  = product.Type,
                        Ratio = q.Amount
                    })
                           .GroupBy(q => q.Name)
                           .Select(p => new PieDto
                    {
                        Name  = p.Key,
                        Ratio = p.Sum(t => t.Ratio)
                    }).ToList()
                };

                return(null, materialPie, productPie);
            }
        }
コード例 #6
0
        public async Task <ValueTuple <PieChartDto, PieChartDto, PieChartDto, PieChartDto> > GeneralStatisticsAnalysisAsync(
            IServiceProvider serviceProvider,
            DateTime startDate,
            DateTime endDate)
        {
            var customerDatas = await _saleOrderRepo.Query()
                                .Where(po => po.DateTime != null && po.DateTime >= startDate && po.DateTime <= endDate)
                                .Join(serviceProvider.GetService <IRepository <Customer, Guid> >().Query(),
                                      po => po.CustomerNumber,
                                      customer => customer.Number,
                                      (po, customer) => new
            {
                Type          = customer.Type,
                TotalAmount   = po.TotalAmount,
                TotalQuantity = po.TotalQuantity
            })
                                .GroupBy(o => o.Type)
                                .Select(o => new
            {
                Type          = o.Key,
                TotalAmount   = o.Sum(t => t.TotalAmount),
                TotalQuantity = o.Sum(t => t.TotalQuantity)
            })
                                .ToListAsync();


            var customerAmountPie = new PieChartDto
            {
                Data = customerDatas
                       .Select(d => new PieDto
                {
                    Name  = d.Type,
                    Ratio = d.TotalAmount
                })
                       .ToList()
            };

            var customerQuantityPie = new PieChartDto
            {
                Data = customerDatas
                       .Select(d => new PieDto
                {
                    Name  = d.Type,
                    Ratio = d.TotalQuantity
                })
                       .ToList()
            };

            var productDatas = await _saleOrderRepo.Query()
                               .Where(po => po.DateTime != null && po.DateTime >= startDate && po.DateTime <= endDate)
                               .Join(_saleOrderItemRepo.Query(),
                                     po => po.Id,
                                     poi => poi.SaleOrderId,
                                     (po, poi) => new
            {
                ProductNumber = poi.Number,
                ProductAmount = poi.Amount,
                ProductPrice  = poi.Price
            })
                               .Join(serviceProvider.GetService <IRepository <Product, Guid> >().Query(),
                                     p => p.ProductNumber,
                                     product => product.Number,
                                     (p, product) => new
            {
                Type          = product.Type,
                TotalAmount   = p.ProductAmount * p.ProductPrice,
                TotalQuantity = p.ProductAmount
            })
                               .GroupBy(o => o.Type)
                               .Select(o => new
            {
                Type          = o.Key,
                TotalAmount   = o.Sum(t => t.TotalAmount),
                TotalQuantity = o.Sum(t => t.TotalQuantity)
            })
                               .ToListAsync();

            var productAmountPie = new PieChartDto
            {
                Data = productDatas
                       .Select(d => new PieDto
                {
                    Name  = d.Type,
                    Ratio = d.TotalAmount
                })
                       .ToList()
            };

            var productQuantityPie = new PieChartDto
            {
                Data = productDatas
                       .Select(d => new PieDto
                {
                    Name  = d.Type,
                    Ratio = d.TotalQuantity
                })
                       .ToList()
            };

            return(customerAmountPie, customerQuantityPie, productAmountPie, productQuantityPie);
        }
コード例 #7
0
        public async Task <ValueTuple <PieChartDto, PieChartDto, PieChartDto, PieChartDto> > GeneralStatisticsAnalysisAsync(
            IServiceProvider serviceProvider,
            DateTime startDate,
            DateTime endDate)
        {
            var vendorDatas = await _purchaseOrderRepo.Query()
                              .Where(po => po.DateTime != null && po.DateTime >= startDate && po.DateTime <= endDate)
                              .Join(serviceProvider.GetService <IRepository <Vendor, Guid> >().Query(),
                                    po => po.VendorNumber,
                                    vendor => vendor.Number,
                                    (po, vendor) => new
            {
                Type          = vendor.Type,
                TotalAmount   = po.TotalAmount,
                TotalQuantity = po.TotalQuantity
            })
                              .GroupBy(o => o.Type)
                              .Select(o => new
            {
                Type          = o.Key,
                TotalAmount   = o.Sum(t => t.TotalAmount),
                TotalQuantity = o.Sum(t => t.TotalQuantity)
            })
                              .ToListAsync();


            var vendorAmountPie = new PieChartDto
            {
                Data = vendorDatas
                       .Select(d => new PieDto
                {
                    Name  = d.Type,
                    Ratio = d.TotalAmount
                })
                       .ToList()
            };

            var vendorQuantityPie = new PieChartDto
            {
                Data = vendorDatas
                       .Select(d => new PieDto
                {
                    Name  = d.Type,
                    Ratio = d.TotalQuantity
                })
                       .ToList()
            };

            var materialDatas = await _purchaseOrderRepo.Query()
                                .Where(po => po.DateTime != null && po.DateTime >= startDate && po.DateTime <= endDate)
                                .Join(_purchaseOrderItemRepo.Query(),
                                      po => po.Id,
                                      poi => poi.PurchaseOrderId,
                                      (po, poi) => new
            {
                MaterialNumber = poi.Number,
                MaterialAmount = poi.Amount,
                MaterialPrice  = poi.Price
            })
                                .Join(serviceProvider.GetService <IRepository <Material, Guid> >().Query(),
                                      p => p.MaterialNumber,
                                      material => material.Number,
                                      (p, material) => new
            {
                Type          = material.Type,
                TotalAmount   = p.MaterialAmount * p.MaterialPrice,
                TotalQuantity = p.MaterialAmount
            })
                                .GroupBy(o => o.Type)
                                .Select(o => new
            {
                Type          = o.Key,
                TotalAmount   = o.Sum(t => t.TotalAmount),
                TotalQuantity = o.Sum(t => t.TotalQuantity)
            })
                                .ToListAsync();

            var materialAmountPie = new PieChartDto
            {
                Data = materialDatas
                       .Select(d => new PieDto
                {
                    Name  = d.Type,
                    Ratio = d.TotalAmount
                })
                       .ToList()
            };

            var materialQuantityPie = new PieChartDto
            {
                Data = materialDatas
                       .Select(d => new PieDto
                {
                    Name  = d.Type,
                    Ratio = d.TotalQuantity
                })
                       .ToList()
            };

            return(vendorAmountPie, vendorQuantityPie, materialAmountPie, materialQuantityPie);
        }