示例#1
0
        public void ViewChart()
        {
            try
            {
                using (SqlConnection con = new SqlConnection(strConString))
                {
                    SqlCommand cmd = new SqlCommand("select * From tblTransaksi", con);
                    con.Open();
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    DataTable      dt = new DataTable();
                    da.Fill(dt);
                    con.Close();

                    //----ViewChart----//
                    //DataTable primaryData = new DataTable();

                    //dt.Columns.Add("Language", typeof(System.String));
                    //dt.Columns.Add("User", typeof(System.Double));

                    //dt.Rows.Add("Java", 62000);
                    //dt.Rows.Add("Python", 46000);
                    //dt.Rows.Add("Javascript", 38000);
                    //dt.Rows.Add("C++", 31000);
                    //dt.Rows.Add("C#", 27000);
                    //dt.Rows.Add("php", 14000);
                    //dt.Rows.Add("Perl", 14000);

                    StaticSource source = new StaticSource(dt);
                    DataModel    model  = new DataModel();
                    model.DataSources.Add(source);

                    PageLevelTheme.Theme = FusionChartsTheme.ThemeName.FUSION;

                    Charts.PieChart pie = new Charts.PieChart("first_3D_chart");
                    pie.ThreeD = true;
                    pie.Width.Pixel(600);
                    pie.Height.Pixel(450);
                    pie.Data.Source = model;
                    pie.Data.CategoryField("[Nama Perusahaan]");
                    pie.Data.SeriesFields("[Nama Barang]");

                    pie.Caption.Text = "Transaction Tables";
                    pie.Values.Show  = false;

                    //Chart newChart = new Chart("column2d", "simplechart", "600", "400", "jsonurl", "data.json");
                    //chart.Text = newChart.Render();

                    //ViewData["Chart"] = pie.Render();
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Oops!! following error occured : " + message.ToString() + "');", true);
            }
        }
示例#2
0
        protected override async Task OnInitializedAsync()
        {
            // create data table to store data
            DataTable ChartData = new DataTable();

            // Add columns to data table
            ChartData.Columns.Add("Programming Language", typeof(System.String));
            ChartData.Columns.Add("Users", typeof(System.Double));
            // Add rows to data table

            ChartData.Rows.Add("Java", 62000);
            ChartData.Rows.Add("Python", 46000);
            ChartData.Rows.Add("Javascript", 38000);
            ChartData.Rows.Add("C++", 31000);
            ChartData.Rows.Add("C#", 27000);
            ChartData.Rows.Add("PHP", 14000);
            ChartData.Rows.Add("Perl", 14000);

            // Create static source with this data table
            StaticSource source = new StaticSource(ChartData);
            // Create instance of DataModel class
            DataModel model = new DataModel();

            // Add DataSource to the DataModel
            model.DataSources.Add(source);
            // Instantiate Column Chart
            Charts.ColumnChart column = new Charts.ColumnChart("first_chart");
            // Set Chart's width and height
            column.Width.Pixel(700);
            column.Height.Pixel(400);
            // Set DataModel instance as the data source of the chart
            column.Data.Source = model;
            // Set Chart Title
            column.Caption.Text = "Most popular programming language";
            // Set chart sub title
            column.SubCaption.Text = "2017-2018";
            // hide chart Legend
            column.Legend.Show = false;
            // set XAxis Text
            column.XAxis.Text = "Programming Language";
            // Set YAxis title
            column.YAxis.Text = "User";
            // set chart theme
            column.ThemeName = FusionChartsTheme.ThemeName.FUSION;
            // set chart rendering json
            ChartJson = column.Render();
        }
        public void OnPostChartGenerator()
        {
            int userID = Convert.ToInt32(HttpContext.Session.GetInt32("userID"));

            var MonthList = new List <string>()
            {
                "Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień"
            };

            int    StartDay        = int.Parse(Request.Form["StartDay"]);
            string StartMonth      = Request.Form["StartMonth"].ToString();
            int    StartYear       = int.Parse(Request.Form["StartYear"]);
            int    StartMonthValue = MonthList.IndexOf(StartMonth) + 1;
            string StartDate       = StartYear + "-" + StartMonthValue + "-" + StartDay;

            int    EndDay        = int.Parse(Request.Form["EndDay"]);
            string EndMonth      = Request.Form["EndMonth"].ToString();
            int    EndYear       = int.Parse(Request.Form["EndYear"]);
            int    EndMonthValue = MonthList.IndexOf(EndMonth) + 1;
            string EndDate       = EndYear + "-" + EndMonthValue + "-" + EndDay;

            string Lift = Request.Form["Lift"].ToString();
            IDictionary <string, string> LiftQueryList = new Dictionary <string, string>()
            {
                { "Wyciskanie leżąc", "BENCH" },
                { "Wyciskanie stojąc", "OHP" },
                { "Przysiad", "SQUAT" },
                { "Martwy ciąg", "DEADLIFT" },
            };

            string LiftQuery = LiftQueryList[Lift];


            List <string> LiftList;
            List <string> DateList;

            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                //string query = "SELECT value, m_date FROM [FOODMATE].[dbo].[Lifts] WHERE user_id = @userID AND lift_name = @liftName AND m_date BETWEEN @StartDate AND @EndDate;";

                string query = "SELECT x.lift_id, x.user_id, x.m_date, x.lift_name, x.value FROM [FOODMATE].[dbo].[Lifts] x " +
                               "JOIN(SELECT y.m_date FROM[FOODMATE].[dbo].[Lifts] y " +
                               "WHERE y.user_id = @userID AND y.m_date BETWEEN @StartDate AND @EndDate group by m_date) z " +
                               "ON x.user_id = @UserID AND lift_name = @liftName AND x.m_date = z.m_date;";

                using (SqlCommand command = new SqlCommand(query, connection))
                {
                    command.Parameters.AddWithValue("@StartDate", StartDate);
                    command.Parameters.AddWithValue("@EndDate", EndDate);
                    command.Parameters.AddWithValue("@userID", userID);
                    command.Parameters.AddWithValue("@liftName", LiftQuery);

                    connection.Open();

                    LiftList = new List <string>();
                    DateList = new List <string>();

                    DataTable      dt      = new DataTable();
                    SqlDataAdapter adapter = new SqlDataAdapter(command);
                    adapter.Fill(dt);
                    foreach (DataRow row in dt.Rows)
                    {
                        LiftList.Add(row["value"].ToString());
                        DateList.Add(row["m_date"].ToString().Remove(10));
                    }
                    connection.Close();
                }
            }

            // create data table to store data
            DataTable ChartData = new DataTable();

            // Add columns to data table
            ChartData.Columns.Add("Czas", typeof(System.String));
            ChartData.Columns.Add("Wielkość", typeof(System.Double));
            // Add rows to data table
            var i = 0;

            foreach (var day in DateList)
            {
                ChartData.Rows.Add(DateList[i], LiftList[i]);
                i++;
            }

            // Create static source with this data table
            StaticSource source = new StaticSource(ChartData);
            // Create instance of DataModel class
            DataModel model = new DataModel();

            // Add DataSource to the DataModel
            model.DataSources.Add(source);

            Charts.SplineChart splineChart = new Charts.SplineChart("spline_chart");

            splineChart.ThemeName = FusionChartsTheme.ThemeName.FUSION;
            splineChart.Width.Pixel(700);
            splineChart.Height.Pixel(400);
            splineChart.Data.Source = model;

            splineChart.Caption.Text = Lift;
            splineChart.Caption.Bold = true;

            splineChart.Values.Show = true;

            splineChart.XAxis.Text = "Czas";
            splineChart.YAxis.Text = "kg";

            splineChart.Legend.Show = false;
            splineChart.ThemeName   = FusionChartsTheme.ThemeName.FUSION;

            ViewData["Chart"] = splineChart.Render();
        }
示例#4
0
        public async Task OnPostAsync()
        {
            const string path = @"..\车辆基本信息表.csv";

            CarDetails = new List <CarDetail>();
            var lists = FileService.ReadFromFile(path);

            CarDetails = InitializeService.InitializeCarDetail(lists);
            sta        = new List <CarStatic>();
            Dictionary <string, CarStatic> dic = new Dictionary <string, CarStatic>();

            foreach (var item in CarDetails)
            {
                if (dic.ContainsKey(item.CarType))
                {
                    ++dic[item.CarType].Total;
                    if (item.State == "y")
                    {
                        ++dic[item.CarType].rent;
                    }
                    else
                    {
                        ++dic[item.CarType].free;
                    }
                }
                else
                {
                    int onrent = item.State == "y" ? 1 : 0;
                    dic.Add(item.CarType, new CarStatic
                    {
                        Type  = item.CarType,
                        Total = 1,
                        rent  = onrent,
                        free  = 1 - onrent
                    });
                }
            }
            foreach (var item in dic)
            {
                sta.Add(item.Value);
            }
            switch (SearchOption)
            {
            case "TotalInfo":

                break;

            case "BarChart":

                try
                {
                    DataTable ChartData = new DataTable();
                    ChartData.Columns.Add("Programming Language", typeof(System.String));
                    ChartData.Columns.Add("Users", typeof(int));
                    foreach (var item in sta)
                    {
                        ChartData.Rows.Add(item.Type, item.Total);
                    }
                    // Create static source with this data table
                    StaticSource source = new StaticSource(ChartData);
                    // Create instance of DataModel class
                    DataModel model = new DataModel();
                    // Add DataSource to the DataModel
                    model.DataSources.Add(source);
                    // Instantiate Column Chart
                    Charts.ColumnChart column = new Charts.ColumnChart("first_chart");
                    // Set Chart's width and height
                    column.Width.Pixel(700);
                    column.Height.Pixel(400);
                    // Set DataModel instance as the data source of the chart
                    column.Data.Source = model;
                    // Set Chart Title
                    column.Caption.Text = "All type of the cars";
                    // Set chart sub title
                    column.SubCaption.Text = "2020.06";
                    // hide chart Legend
                    column.Legend.Show = false;
                    // set XAxis Text
                    column.XAxis.Text = "CarType";
                    // Set YAxis title
                    column.YAxis.Text = "Total";
                    // set chart theme
                    column.ThemeName = FusionChartsTheme.ThemeName.FUSION;
                    // set chart rendering json
                    ChartJson = column.Render();
                }catch
                {
                }
                break;

            default:
                break;
            }
        }
        public void OnPostChartGenerator()
        {
            int userID = Convert.ToInt32(HttpContext.Session.GetInt32("userID"));

            var MonthList = new List <string>()
            {
                "Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień"
            };

            int    StartDay        = int.Parse(Request.Form["StartDay"]);
            string StartMonth      = Request.Form["StartMonth"].ToString();
            int    StartYear       = int.Parse(Request.Form["StartYear"]);
            int    StartMonthValue = MonthList.IndexOf(StartMonth) + 1;
            string StartDate       = StartYear + "-" + StartMonthValue + "-" + StartDay;

            int    EndDay        = int.Parse(Request.Form["EndDay"]);
            string EndMonth      = Request.Form["EndMonth"].ToString();
            int    EndYear       = int.Parse(Request.Form["EndYear"]);
            int    EndMonthValue = MonthList.IndexOf(EndMonth) + 1;
            string EndDate       = EndYear + "-" + EndMonthValue + "-" + EndDay;

            string BodyPart = Request.Form["BodyPart"].ToString();
            IDictionary <string, string> BodyPartQueryList = new Dictionary <string, string>()
            {
                { "Lewa łydka", "l_calve" },
                { "Prawa łydka", "r_calve" },
                { "Lewe udo", "l_thigh" },
                { "Prawe udo", "r_thigh" },
                { "Pośladki", "butt" },
                { "Pas", "waist" },
                { "Klatka piersiowa", "chest" },
                { "Lewe ramię", "l_arm" },
                { "Prawe ramię", "r_arm" },
                { "Lewe przedramię", "l_forearm" },
                { "Prawe przedramię", "r_forearm" },
                { "Waga", "u_weight" }
            };
            string BodyPartQuery = BodyPartQueryList[BodyPart];


            List <string> BodyPartList;
            List <string> DateList;

            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                string query = "SELECT x.measurement_id, x.m_date, x.user_id, x.l_calve, x.r_calve, x.l_thigh, x.r_thigh, x.butt, x.waist, x.chest, x.l_arm, x.r_arm, x.l_forearm, x.r_forearm, x.u_weight FROM[FOODMATE].[dbo].[Measurements] x " +
                               "JOIN(SELECT y.m_date FROM [FOODMATE].[dbo].[Measurements] y " +
                               "WHERE y.user_id = @UserID AND y.m_date BETWEEN @StartDate AND @EndDate group by m_date) z " +
                               "ON x.user_id = @UserID AND x.m_date = z.m_date;";

                using (SqlCommand command = new SqlCommand(query, connection))
                {
                    command.Parameters.AddWithValue("@StartDate", StartDate);
                    command.Parameters.AddWithValue("@EndDate", EndDate);
                    command.Parameters.AddWithValue("@userID", userID);

                    connection.Open();

                    BodyPartList = new List <string>();
                    DateList     = new List <string>();

                    DataTable      dt      = new DataTable();
                    SqlDataAdapter adapter = new SqlDataAdapter(command);
                    adapter.Fill(dt);
                    foreach (DataRow row in dt.Rows)
                    {
                        BodyPartList.Add(row[BodyPartQuery].ToString());
                        DateList.Add(row["m_date"].ToString().Remove(10));
                    }
                    connection.Close();
                }
            }

            for (int j = 0; j <= BodyPartList.Count - 1; j++)
            {
                if (BodyPartList[j] == "")
                {
                    BodyPartList[j] = BodyPartList[j - 1];
                    Console.WriteLine(DateList[j]);
                    Console.WriteLine(BodyPartList[j]);
                }
            }

            // create data table to store data
            DataTable ChartData = new DataTable();

            // Add columns to data table
            ChartData.Columns.Add("Czas", typeof(System.String));
            ChartData.Columns.Add("Wielkość", typeof(System.Double));
            // Add rows to data table
            var i = 0;

            foreach (var day in DateList)
            {
                ChartData.Rows.Add(DateList[i], BodyPartList[i]);
                i++;
            }

            // Create static source with this data table
            StaticSource source = new StaticSource(ChartData);
            // Create instance of DataModel class
            DataModel model = new DataModel();

            // Add DataSource to the DataModel
            model.DataSources.Add(source);

            Charts.SplineChart splineChart = new Charts.SplineChart("spline_chart");

            splineChart.ThemeName = FusionChartsTheme.ThemeName.FUSION;
            splineChart.Width.Pixel(700);
            splineChart.Height.Pixel(400);
            splineChart.Data.Source = model;

            splineChart.Caption.Text = BodyPart;
            splineChart.Caption.Bold = true;

            splineChart.Values.Show = true;

            splineChart.XAxis.Text = "Czas";
            splineChart.YAxis.Text = "cm";

            splineChart.Legend.Show = false;
            splineChart.ThemeName   = FusionChartsTheme.ThemeName.FUSION;

            ViewData["Chart"] = splineChart.Render();
        }
示例#6
0
        public async Task <IActionResult> OnGetAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            controller = await _context.Controllers.FirstOrDefaultAsync(m => m.Id == id);

            string[] values = controller.Values;

            if (values.Length == 0)
            {
                return(Page());
            }

            int start_point = 0;

            // create data table to store data
            DataTable ChartData = new DataTable();

            // Add columns to data table

            if (controller.Type == "humidity")
            {
                ChartData.Columns.Add("time", typeof(System.String));
                ChartData.Columns.Add("mm/pt", typeof(System.Double));
                foreach (var item in values)
                {
                    if (item != "")
                    {
                        ChartData.Rows.Add(start_point, item.Split('|')[1]);
                        start_point += 10;
                    }
                }
            }
            else if (controller.Type == "temperature")
            {
                ChartData.Columns.Add("time", typeof(System.String));
                ChartData.Columns.Add("Degrees", typeof(System.Double));
                foreach (var item in values)
                {
                    double dd = 0;
                    if (item != "")
                    {
                        ChartData.Rows.Add(start_point, item.Split('|')[1]);
                        start_point += 10;
                    }
                }
            }
            else if (controller.Type == "pressure")
            {
                ChartData.Columns.Add("time", typeof(System.String));
                ChartData.Columns.Add("bar", typeof(System.Double));
                foreach (var item in values)
                {
                    //DateTime dt = DateTime.Parse(item.Split('|')[0]);
                    ChartData.Rows.Add(start_point, item.Split('|')[3]);
                    start_point += 10;
                }
                start_point = 0;
            }
            else if (controller.Type == "movement")
            {
                ChartData.Columns.Add("time", typeof(System.String));
                ChartData.Columns.Add("actions", typeof(System.Double));
                foreach (var item in values)
                {
                    if (item != "")
                    {
                        //DateTime dt = DateTime.Parse(item.Split('|')[0]);
                        int value = 0;
                        if (item.Split('|')[1] == "true")
                        {
                            value = 1;
                        }
                        ChartData.Rows.Add(start_point, value);
                        start_point += 10;
                    }
                }
            }
            else if (controller.Type == "lightning")
            {
                ChartData.Columns.Add("time", typeof(System.String));
                ChartData.Columns.Add("lux", typeof(System.Double));
                foreach (var item in values)
                {
                    if (item != "")
                    {
                        //DateTime dt = DateTime.Parse(item.Split('|')[0]);
                        ChartData.Rows.Add(start_point, item.Split('|')[1]);
                        start_point += 10;
                    }
                }
            }
            else
            {
                ChartData.Columns.Add("sample", typeof(System.String));
                ChartData.Columns.Add("sample2", typeof(System.Double));
            }
            // Add rows to data table



            //ChartData.Rows.Add("Java", 62000);
            //ChartData.Rows.Add("Python", 46000);
            //ChartData.Rows.Add("Javascript", 38000);
            //ChartData.Rows.Add("C++", 31000);
            //ChartData.Rows.Add("C#", 27000);
            //ChartData.Rows.Add("PHP", 14000);
            //ChartData.Rows.Add("Perl", 14000);

            // Create static source with this data table
            StaticSource source = new StaticSource(ChartData);
            // Create instance of DataModel class
            DataModel model = new DataModel();

            // Add DataSource to the DataModel
            model.DataSources.Add(source);
            // Instantiate Column Chart
            Charts.ColumnChart column = new Charts.ColumnChart("first_chart");
            // Set Chart's width and height
            column.Width.Pixel(700);
            column.Height.Pixel(400);
            // Set DataModel instance as the data source of the chart
            column.Data.Source = model;
            // Set Chart Title
            column.Caption.Text = controller.Type;
            // Set chart sub title
            // hide chart Legend
            column.Legend.Show = false;
            // set XAxis Text
            column.XAxis.Text = "Time";
            // Set YAxis title
            column.YAxis.Text = "Value";
            // set chart theme
            column.ThemeName = FusionChartsTheme.ThemeName.FUSION;
            // set chart rendering json
            ChartJson = column.Render();

            if (controller == null)
            {
                return(NotFound());
            }
            return(Page());
        }
示例#7
0
        public IActionResult Diagram()
        {
            DataTable ChartData = new DataTable();

            ChartData.Columns.Add("Стоимость", typeof(double));
            ChartData.Columns.Add("Спрос", typeof(int));

            var sales    = _saleLogic.Read(null);
            var products = _productLogic.Read(null);
            var spros    = new List <int>();
            var prices   = new List <double>();

            if (products != null)
            {
                foreach (var product in products)
                {
                    prices.Add(product.Price);
                    spros.Add(0);
                }
            }

            if (sales != null)
            {
                foreach (var sale in sales)
                {
                    if (sale.TableProducts != null)
                    {
                        foreach (var tp in sale.TableProducts)
                        {
                            foreach (var product in products)
                            {
                                if (tp.Product == product)
                                {
                                    spros[products.IndexOf(product)] += tp.Amount;
                                }
                            }
                        }
                    }
                }
            }


            for (int i = 0; i < products.Count(); i++)
            {
                ChartData.Rows.Add(prices[i], spros[i]);
            }

            StaticSource source = new StaticSource(ChartData);
            DataModel    model  = new DataModel();

            model.DataSources.Add(source);
            Charts.ColumnChart column = new Charts.ColumnChart("first_chart");
            column.Width.Pixel(700);
            column.Height.Pixel(400);
            column.Data.Source  = model;
            column.Caption.Text = "Диаграмма цена/спрос";
            column.Legend.Show  = false;
            column.XAxis.Text   = "Стоимость";
            column.YAxis.Text   = "Спрос";
            column.ThemeName    = FusionChartsTheme.ThemeName.FUSION;

            return(View("Diagram", column.Render()));
        }