コード例 #1
0
ファイル: Dashboard.xaml.cs プロジェクト: saamodra/KenkoApp
        private ChartKeuangan GetChartKeuangan(string sp)
        {
            ChartKeuangan chartKeuangan = new ChartKeuangan();
            SqlConnection connection    = new SqlConnection(ConfigurationManager.AppSettings["ConString"]);

            connection.Open();
            SqlCommand cmd = new SqlCommand(sp, connection);

            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader RDR = cmd.ExecuteReader();

            while (RDR.Read())
            {
                chartKeuangan.keuangan.Add(Convert.ToDouble(RDR["total"]));
                chartKeuangan.bulan.Add(RDR["bulan"].ToString());
            }
            connection.Close();

            return(chartKeuangan);
        }
コード例 #2
0
ファイル: Dashboard.xaml.cs プロジェクト: saamodra/KenkoApp
        private void refreshGrafikKeuangan()
        {
            ChartKeuangan chartPenjualan = GetChartKeuangan("sp_chartPenjualan");
            ChartKeuangan chartPembelian = GetChartKeuangan("sp_chartPembelian");

            CartesianChart ch = new CartesianChart();

            ch.Foreground = new SolidColorBrush(Colors.Black);
            ch.Series     = new SeriesCollection
            {
                new ColumnSeries
                {
                    Title  = "Penjualan",
                    Values = new ChartValues <double>(chartPenjualan.keuangan)
                },
                new ColumnSeries
                {
                    Title  = "Pembelian",
                    Values = new ChartValues <double>(chartPembelian.keuangan)
                }
            };

            ch.AxisX.Add(new Axis
            {
                Title     = "Bulan",
                Labels    = chartPenjualan.bulan,
                Separator = new Separator
                {
                    Step = 1
                }
            });

            ch.AxisY.Add(new Axis
            {
                Title          = "Keuangan",
                LabelFormatter = value => value.ToString("C", CultureInfo.CreateSpecificCulture("id-ID"))
            });


            keuanganChart.Children.Add(ch);
        }