예제 #1
0
        public RootObject GetChangeIndexChart(ReportCriteria reportCriteria)
        {
            try
            {
                Dictionary <string, object> parameters = new Dictionary <string, object>();

                parameters.Add(Constants.StoredProcedures.GetIndexChange.CountryCodes, reportCriteria.countryCodeIds);
                // parameters.Add(Constants.StoredProcedures.GetIndexChange.CategoryIds, reportCriteria.categoryCodeIds);
                parameters.Add(Constants.StoredProcedures.GetIndexChange.Years, reportCriteria.years);
                //parameters.Add(Constants.StoredProcedures.GetIndexChange.Months, reportCriteria.months);

                var fullReport = _imfUnitOfWork.Repository <IndexChangeReport>().SqlCommand(Constants.StoredProcedures.GetIndexChangeChart.Sql, parameters);

                List <IndexChangeReport> lstChangeIndexReport = new List <IndexChangeReport>();
                List <string>            lstCountryName       = new List <string>();
                lstChangeIndexReport = fullReport.ToList();
                lstCountryName       = fullReport.AsEnumerable().Select(o => o.CountryName).Distinct().ToList();


                RootObject      objRootObject = new RootObject();
                List <datasets> lstChartList  = new List <datasets>();
                List <Datum>    lstDatum      = new List <Datum>();

                List <string> lstColors = new List <string> {
                    "#3cba9f", "#3A76BC"
                };
                //var tempList = new List<string> { "Name", "DOB", "Address" };
                var random = new Random();
                foreach (string objCountryName in lstCountryName)
                {
                    datasets     objChartList = new datasets();
                    List <Datum> objDatum     = new List <Datum>();

                    var color = "#{0:X6}" + Convert.ToString(random.Next(0x1000000)); //String.Format("#{0:X6}", random.Next(0x1000000));//String.Format("#{0:X6}", random.Next(0x1000000)); // = "#A197B9"
                    objChartList.strokeColor = color;                                 // "#3cba9f";
                    objChartList.fill        = "false";
                    objChartList.label       = objCountryName.ToString();
                    objDatum = (from stad in lstChangeIndexReport.Where(x => x.CountryName == objCountryName)
                                select new Datum()
                    {
                        x = stad.Report.ToString(),
                        y = stad.ChangeIndex
                    }).ToList();

                    objChartList.data = objDatum;
                    lstChartList.Add(objChartList);
                }

                objRootObject.datasets     = lstChartList.ToList();
                objRootObject.lstYEARMONTH = fullReport.AsEnumerable().Select(o => o.Report).Distinct().ToList();


                return(objRootObject);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
예제 #2
0
        public ActionResult DashBord()
        {
            //labels: [  ],
            //datasets: [{
            //             data: [15, 20, 30, 10, 50],
            //             backgroundColor: ["#BDC3C7", "#9B59B6", "#E74C3C", "#26B99A", "#3498DB"],
            //             hoverBackgroundColor: ["#CFD4D8", "#B370CF", "#E95E4F", "#36CAAB", "#49A9EA"]
            //            }
            //              ]

            var    itemsName = db.Items.OrderBy(d => d.ItemId).Take(5).Skip(0).Select(f => f.ItemName).ToList();
            MyData data      = new MyData();

            data.labels = itemsName; //new List<string>() { "Symbian", "Blackberry", "Other", "Android", "IOS" };
            datasets datas = new datasets();

            datas.data = new List <int>()
            {
                15, 20, 30, 10, 50
            };
            datas.backgroundColor = new List <string>()
            {
                "#BDC3C7", "#9B59B6", "#E74C3C", "#26B99A", "#3498DB"
            };
            datas.hoverBackgroundColor = new List <string>()
            {
                "#CFD4D8", "#B370CF", "#E95E4F", "#36CAAB", "#49A9EA"
            };
            List <datasets> lds = new List <datasets>();

            lds.Add(datas);
            data.datasets = lds;


            ViewBag.tpo = db.PurchaseOrders.Count();
            ViewBag.tso = db.SaleOrders.Count();


            ViewBag.Mydata = data;;


            return(View());
        }
예제 #3
0
        public HttpResponseMessage tst()
        {
            MyData data = new MyData();

            data.labels = new List <string>()
            {
                "Symbian", "Blackberry", "Other", "Android", "IOS"
            };
            datasets datas = new datasets();

            datas.data = new List <int>()
            {
                15, 20, 30, 10, 50
            };
            datas.backgroundColor = new List <string>()
            {
                "#BDC3C7", "#9B59B6", "#E74C3C", "#26B99A", "#3498DB"
            };
            datas.hoverBackgroundColor = new List <string>()
            {
                "#CFD4D8", "#B370CF", "#E95E4F", "#36CAAB", "#49A9EA"
            };
            List <datasets> lds = new List <datasets>();

            lds.Add(datas);
            data.datasets = lds;

            try
            {
                var TempData = data;



                return(Request.CreateResponse(HttpStatusCode.OK, TempData));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
예제 #4
0
        public string analise(int tip, int code, int codd, int codee, int codde, int co, int cod)
        {
            if (codd < 12)
            {
                codd++;
            }
            else
            {
                code++;
                codd = 1;
            }
            DateTime dt_max = new DateTime(code, codd, 1);
            DateTime dt_min = new DateTime(codee, codde, 1);

            Dominio.Analise analise = new Dominio.Analise()
            {
                Data_max = dt_max, Data_min = dt_min
            };
            analise.ID = cod;
            commands["CONSULTAR"].execute(analise);
            if (analise.ID == 0)
            {
                Dominio.data asd = new Dominio.data()
                {
                    labels = analise.generic_labels,//new string[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" },
                };
                var fdsa = new List <Dominio.datasets>()
                {
                };
                for (int i = 0; i < analise.resultado.Keys.Count; i++)
                {
                    if (co == 0)
                    {
                        List <EntidadeDominio> b = analise.resultado.Values.ElementAt(i);
                        Random rnd    = new Random();
                        string color  = "rgb(" + rnd.Next(0, 255) + "," + rnd.Next(0, 255) + " , " + rnd.Next(0, 255) + ")";
                        var    goLuiz = new datasets()
                        {
                            label = analise.resultado.Keys.ElementAt(i), backgroundColor = color, borderColor = color, fill = false
                        };
                        var grr = new List <double>()
                        {
                        };
                        foreach (Bagagem sl in b)
                        {
                            grr.Add(sl.peso);
                        }
                        goLuiz.data = grr.ToArray();
                        fdsa.Add(goLuiz);
                    }
                    else if (co == i + 1)
                    {
                        List <EntidadeDominio> b = analise.resultado.Values.ElementAt(i);
                        Random rnd    = new Random();
                        string color  = "rgb(" + rnd.Next(0, 255) + "," + rnd.Next(0, 255) + " , " + rnd.Next(0, 255) + ")";
                        var    goLuiz = new datasets()
                        {
                            label = analise.resultado.Keys.ElementAt(i), backgroundColor = color, borderColor = color, fill = false
                        };
                        var grr = new List <double>()
                        {
                        };
                        foreach (Bagagem sl in b)
                        {
                            grr.Add(sl.peso);
                        }
                        goLuiz.data = grr.ToArray();
                        fdsa.Add(goLuiz);
                    }
                }
                asd.datasets = fdsa.ToArray();

                Dominio.options asdf = new Dominio.options()
                {
                    responsive = true,
                    title      = new title()
                    {
                        display = true, text = "bagagem por voo em tempo (ano " + analise.Data_min.Year + ")"
                    },
                    tooltips = new tooltips()
                    {
                        intersect = false, mode = "index"
                    },
                    hover = new hover()
                    {
                        intersect = true, mode = "nearest"
                    },
                    scales = new scales()
                    {
                        xAxes = new xAxes[] { new xAxes()
                                              {
                                                  display = true, scaleLabel = new scaleLabel()
                                                  {
                                                      display = true, labelString = "mês"
                                                  }
                                              } },
                        yAxes = new yAxes[] { new yAxes()
                                              {
                                                  display = true, scaleLabel = new scaleLabel()
                                                  {
                                                      display = true, labelString = "peso em Kg"
                                                  }
                                              } }
                    }
                };
                if (tip == 0)
                {
                    analise.chartsjs.type = "line";
                }
                else
                {
                    analise.chartsjs.type = "bar";
                }
                analise.chartsjs.data    = asd;
                analise.chartsjs.options = asdf;
            }
            else
            {
                Dominio.data asd = new Dominio.data()
                {
                    labels = analise.generic_labels,
                };
                var fdsa = new List <Dominio.datasets>()
                {
                };
                for (int i = 0; i < analise.resultado.Keys.Count; i++)
                {
                    if (co == 0)
                    {
                        List <EntidadeDominio> b = analise.resultado.Values.ElementAt(i);
                        Random rnd    = new Random();
                        string color  = "rgb(" + rnd.Next(0, 255) + "," + rnd.Next(0, 255) + " , " + rnd.Next(0, 255) + ")";
                        var    goLuiz = new datasets()
                        {
                            label = analise.resultado.Keys.ElementAt(i), backgroundColor = color, borderColor = color, fill = false
                        };
                        var grr = new List <double>()
                        {
                        };
                        foreach (Check_in sl in b)
                        {
                            grr.Add(sl.ID);
                        }
                        goLuiz.data = grr.ToArray();
                        fdsa.Add(goLuiz);
                    }
                    else if (co == i + 1)
                    {
                        List <EntidadeDominio> b = analise.resultado.Values.ElementAt(i);
                        Random rnd    = new Random();
                        string color  = "rgb(" + rnd.Next(0, 255) + "," + rnd.Next(0, 255) + " , " + rnd.Next(0, 255) + ")";
                        var    goLuiz = new datasets()
                        {
                            label = analise.resultado.Keys.ElementAt(i), backgroundColor = color, borderColor = color, fill = false
                        };
                        var grr = new List <double>()
                        {
                        };
                        foreach (Check_in sl in b)
                        {
                            grr.Add(sl.ID);
                        }
                        goLuiz.data = grr.ToArray();
                        fdsa.Add(goLuiz);
                    }
                }
                asd.datasets = fdsa.ToArray();

                Dominio.options asdf = new Dominio.options()
                {
                    responsive = true,
                    title      = new title()
                    {
                        display = true, text = "passageiros por voo em tempo (ano " + analise.Data_min.Year + ")"
                    },
                    tooltips = new tooltips()
                    {
                        intersect = false, mode = "index"
                    },
                    hover = new hover()
                    {
                        intersect = true, mode = "nearest"
                    },
                    scales = new scales()
                    {
                        xAxes = new xAxes[] { new xAxes()
                                              {
                                                  display = true, scaleLabel = new scaleLabel()
                                                  {
                                                      display = true, labelString = "mês"
                                                  }
                                              } },
                        yAxes = new yAxes[] { new yAxes()
                                              {
                                                  display = true, scaleLabel = new scaleLabel()
                                                  {
                                                      display = true, labelString = "quantidade"
                                                  }
                                              } }
                    }
                };
                if (tip == 0)
                {
                    analise.chartsjs.type = "line";
                }
                else
                {
                    analise.chartsjs.type = "bar";
                }
                analise.chartsjs.data    = asd;
                analise.chartsjs.options = asdf;
            }
            return(JsonConvert.SerializeObject(analise.chartsjs, Formatting.None, new JsonSerializerSettings()
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            }));                                                                                                                                                         //System.IO.File.ReadAllText("./analise.json");
        }
예제 #5
0
        public string processar(EntidadeDominio entidade)
        {
            Analise analise = (Analise)entidade;

            if (analise.ID == 0)
            {
                Dominio.data asd = new Dominio.data()
                {
                    labels = analise.generic_labels,//new string[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" },
                };
                var fdsa = new List <Dominio.datasets>()
                {
                };
                for (int i = 0; i < analise.resultado.Keys.Count; i++)
                {
                    List <EntidadeDominio> b = analise.resultado.Values.ElementAt(i);
                    Random rnd    = new Random();
                    string color  = "rgb(" + rnd.Next(0, 255) + "," + rnd.Next(0, 255) + " , " + rnd.Next(0, 255) + ")";
                    var    goLuiz = new datasets()
                    {
                        label = analise.resultado.Keys.ElementAt(i), backgroundColor = color, borderColor = color, fill = false
                    };
                    var grr = new List <double>()
                    {
                    };
                    foreach (Bagagem sl in b)
                    {
                        grr.Add(sl.peso);
                    }
                    goLuiz.data = grr.ToArray();
                    fdsa.Add(goLuiz);
                }
                asd.datasets = fdsa.ToArray();

                Dominio.options asdf = new Dominio.options()
                {
                    responsive = true,
                    title      = new title()
                    {
                        display = true, text = "bagagem por voo em tempo (ano " + analise.Data_max.Year + ")"
                    },
                    tooltips = new tooltips()
                    {
                        intersect = false, mode = "index"
                    },
                    hover = new hover()
                    {
                        intersect = true, mode = "nearest"
                    },
                    scales = new scales()
                    {
                        xAxes = new xAxes[] { new xAxes()
                                              {
                                                  display = true, scaleLabel = new scaleLabel()
                                                  {
                                                      display = true, labelString = "mês"
                                                  }
                                              } },
                        yAxes = new yAxes[] { new yAxes()
                                              {
                                                  display = true, scaleLabel = new scaleLabel()
                                                  {
                                                      display = true, labelString = "peso em Kg"
                                                  }
                                              } }
                    }
                };
                analise.chartsjs.type    = "line";
                analise.chartsjs.data    = asd;
                analise.chartsjs.options = asdf;
            }

            return("sucesso!");
        }
        public chartsjs Get(int tip, int code, int codd, int codee, int codde, int co, int cod)
        {
            //qtd do eixo?
            if (codd < 12)
            {
                codd++;
            }
            else
            {
                code++;
                codd = 1;
            }
            //code ano max
            //codee ano min
            //codd mes max
            //codde mes min
            DateTime dt_max = new DateTime(code, codd, 1);
            DateTime dt_min = new DateTime(codee, codde, 1);

            Dominio.Analise analise = new Dominio.Analise()
            {
                Data_max = dt_max, Data_min = dt_min
            };
            analise.Id = cod;
            Random rnd = new Random();

            if (analise.Id == 0)
            {
                List <string> lbls = new List <string>();
                //var dev = db.Pedidoes.Where(ddd => ddd.DataPedido >= dt_min && ddd.DataPedido <= dt_max).ToList();
                var dev = db.Pedidoes.Where(ddd => ddd.DataPedido >= dt_min && ddd.DataPedido <= dt_max)
                          .DistinctBy(ddd => ddd.DataPedido.Year)
                          .DistinctBy(ddd => ddd.DataPedido.Month);
                foreach (var b in dev)
                {
                    lbls.Add(b.DataPedido.ToString("MMMM"));
                }
                Dominio.data asd = new Dominio.data()
                {
                    //eixo x do grafico
                    //labels = lbls.ToArray(),
                    labels = new string[] { "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" },
                };
                var fdsa = new List <Dominio.datasets>()
                {
                };
                //qtd do eixo!!
                for (int i = 0; i < analise.resultado.Keys.Count; i++)
                {
                    if (co == 0)
                    {
                        //qts pedidos dentro da lista?
                        // cor randomica
                        var color = "rgb(" + rnd.Next(0, 255) + "," + rnd.Next(0, 255) + " , " + rnd.Next(0, 255) + ")";
                        var go    = new datasets()
                        {
                            label = db.Produtoes.ToList().Where(bbb => bbb.Id == int.Parse(analise.resultado.Keys.ElementAt(i))).ElementAt(0).Titulo, backgroundColor = (string)color.Clone(), borderColor = (string)color.Clone(), fill = false
                        };
                        var grr = new List <double>()
                        {
                        };

                        //eixo y
                        var queen = new double[12];
                        //foreach dentro de pedido
                        foreach (DetalhesPedido bbb in analise.prod)
                        {
                            Pedido p = db.Pedidoes.Find(bbb.PedidoId);

                            if (bbb.ProdutoId.ToString() == analise.resultado.Keys.ElementAt(i) && p.DataPedido >= dt_min && p.DataPedido <= dt_max)
                            {
                                //pedido por mes, contador de pedidos por mes
                                switch (p.DataPedido.Month)
                                {
                                case 1:
                                    queen[0]++;
                                    break;

                                case 2:
                                    queen[1]++;
                                    break;

                                case 3:
                                    queen[2]++;
                                    break;

                                case 4:
                                    queen[3]++;
                                    break;

                                case 5:
                                    queen[4]++;
                                    break;

                                case 6:
                                    queen[5]++;
                                    break;

                                case 7:
                                    queen[6]++;
                                    break;

                                case 8:
                                    queen[7]++;
                                    break;

                                case 9:
                                    queen[8]++;
                                    break;

                                case 10:
                                    queen[9]++;
                                    break;

                                case 11:
                                    queen[10]++;
                                    break;

                                case 12:
                                    queen[11]++;
                                    break;
                                }
                            }
                        }
                        grr.AddRange(queen);
                        go.data = grr.ToArray();
                        fdsa.Add(go);
                    }
                    else if (co == i + 1)
                    {
                        List <DetalhesPedido> b = analise.prod;
                        var color = "rgb(" + rnd.Next(0, 255) + "," + rnd.Next(0, 255) + " , " + rnd.Next(0, 255) + ")";
                        var go    = new datasets()
                        {
                            label = analise.resultado.Keys.ElementAt(i), backgroundColor = (string)color.Clone(), borderColor = (string)color.Clone(), fill = false
                        };
                        var grr = new List <double>()
                        {
                        };
                        //eixo y
                        var queen = new double[12];
                        foreach (DetalhesPedido bbb in b)
                        {
                            if (bbb.ProdutoId.ToString() == analise.resultado.Keys.ElementAt(i))
                            {
                                Pedido p = db.Pedidoes.Find(bbb.PedidoId);
                                switch (p.DataPedido.Month)
                                {
                                case 1:
                                    queen[0]++;
                                    break;

                                case 2:
                                    queen[1]++;
                                    break;

                                case 3:
                                    queen[2]++;
                                    break;

                                case 4:
                                    queen[3]++;
                                    break;

                                case 5:
                                    queen[4]++;
                                    break;

                                case 6:
                                    queen[5]++;
                                    break;

                                case 7:
                                    queen[6]++;
                                    break;

                                case 8:
                                    queen[7]++;
                                    break;

                                case 9:
                                    queen[8]++;
                                    break;

                                case 10:
                                    queen[9]++;
                                    break;

                                case 11:
                                    queen[10]++;
                                    break;

                                case 12:
                                    queen[11]++;
                                    break;
                                }
                            }
                        }
                        grr.AddRange(queen);
                        go.data = grr.ToArray();
                        fdsa.Add(go);
                    }
                }
                asd.datasets = fdsa.ToArray();

                Dominio.options asdf = new Dominio.options()
                {
                    //titulo do grafico
                    responsive = true,
                    title      = new title()
                    {
                        display = true, text = "Quantidade de Vendas por Jogo (ano " + analise.Data_min.Year + ")"
                    },
                    tooltips = new tooltips()
                    {
                        intersect = false, mode = "index"
                    },
                    hover = new hover()
                    {
                        intersect = true, mode = "nearest"
                    },
                    //Legenda das escalas qtd por mês
                    scales = new scales()
                    {
                        xAxes = new xAxes[] { new xAxes()
                                              {
                                                  display = true, scaleLabel = new scaleLabel()
                                                  {
                                                      display = true, labelString = "Meses"
                                                  }
                                              } },
                        yAxes = new yAxes[] { new yAxes()
                                              {
                                                  display = true, scaleLabel = new scaleLabel()
                                                  {
                                                      display = true, labelString = "Quantidade"
                                                  }
                                              } }
                    }
                };
                //tipo do grafico linha ou barra
                if (tip == 0)
                {
                    analise.chartsjs.type = "line";
                }
                else
                {
                    analise.chartsjs.type = "bar";
                }
                analise.chartsjs.data    = asd;
                analise.chartsjs.options = asdf;
            }

            return(analise.chartsjs);
        }