示例#1
0
        private void RenderChart()
        {
            Bunifu.DataViz.Canvas    canvas    = new Bunifu.DataViz.Canvas();
            Bunifu.DataViz.DataPoint datapoint = new Bunifu.DataViz.DataPoint(Bunifu.DataViz.BunifuDataViz._type.Bunifu_line);
            Canvas    line = new Canvas();
            DataPoint dp1  = new DataPoint(Bunifu.DataViz.BunifuDataViz._type.Bunifu_line);

            conn.Open();
            MySqlCommand scom = conn.CreateCommand();

            scom.CommandText = "SELECT DATE_FORMAT(date_sold, '%m.%d.%Y') AS 'date', SUM(total_price) AS 'total' FROM sales_report GROUP BY date_sold ORDER BY date_sold DESC LIMIT 10";


            MySqlDataReader dr = scom.ExecuteReader();

            while (dr.Read())
            {
                datapoint.addLabely(dr["date"].ToString(), dr["total"].ToString());
            }
            conn.Close();
            canvas.addData(datapoint);
            chartBestSeller.Render(canvas);
        }
示例#2
0
        private void linegraph()
        {
            var canvas     = new Bunifu.DataViz.Canvas();
            var DataPoint1 = new Bunifu.DataViz.DataPoint(Bunifu.DataViz.BunifuDataViz._type.Bunifu_spline);
            var DataPoint2 = new Bunifu.DataViz.DataPoint(Bunifu.DataViz.BunifuDataViz._type.Bunifu_spline);
            var DataPoint3 = new Bunifu.DataViz.DataPoint(Bunifu.DataViz.BunifuDataViz._type.Bunifu_spline);
            var DataPoint4 = new Bunifu.DataViz.DataPoint(Bunifu.DataViz.BunifuDataViz._type.Bunifu_spline);

            connect.Open();
            string sql = "Select count(*) from cases where subdistrict=@subdistrict and Year(case_date_in)=@year";

            var subs = new List <string>()
            {
                "Andir", "Antapani", "Arcamanik", "Astanaanyar", "Babakan Ciparay", "Bandung Kidul", "Bandung Kulon", "Bandung Wetan", "Batununggal", "Bojongloa Kaler", "Bojongloa Kidul", "Buah Batu", "Cibeunying Kaler", "Cibeunying Kidul", "Cibiru", "Cicendo", "Cidadap", "Cinambo", "Coblong", "Gedebage", "Kiaracondong", "Lengkong", "Mandalajati", "Panyileukan", "Rancasari", "Regol", "Sukajadi", "Sukasari", "Sumurbandung", "Ujung Berung"
            };
            var years = new List <int>()
            {
                2014, 2015, 2016, 2017
            };

            using (MySqlCommand cmd = new MySqlCommand(sql, connect))
            {
                foreach (int year in years)
                {
                    foreach (string sub in subs)
                    {
                        cmd.Parameters.Add(new MySqlParameter("@subdistrict", MySqlDbType.VarChar, 30)
                        {
                            Value = sub
                        });
                        cmd.Parameters.Add(new MySqlParameter("@year", MySqlDbType.Int32)
                        {
                            Value = year
                        });

                        int data = Convert.ToInt32(cmd.ExecuteScalar());

                        if (year == 2014)
                        {
                            DataPoint1.addLabely(sub, data.ToString());
                        }
                        else if (year == 2015)
                        {
                            DataPoint2.addLabely(sub, data.ToString());
                        }
                        else if (year == 2016)
                        {
                            DataPoint3.addLabely(sub, data.ToString());
                        }
                        else
                        {
                            DataPoint4.addLabely(sub, data.ToString());
                        }
                        cmd.Parameters.Clear();
                    }
                }
                canvas.addData(DataPoint1);
                canvas.addData(DataPoint2);
                canvas.addData(DataPoint3);
                canvas.addData(DataPoint4);
            }
            bunifuDataViz2.Render(canvas);
            connect.Close();
        }