🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / C# DEVEXPRESS RMOS / GRAFİK chartControl1 kullanımı1

GRAFİK chartControl1 kullanımı1

 

1-) C# DEVEXPRESS RMOS - lookupEdit de gösterme ve label yani etiket destekleyenleri bulma

        List<bool> destek = new List<bool>();

        DataTable dt;

        DataRow dr;

        Array typesValues;

        public void MyGrafikLookAndDestek()

        {

            try

            {

                // lookŞekil

                dt = new DataTable();

                dt.Columns.Add("key");

                dt.Columns.Add("value");

                // string s= ViewType.Bar.ToString();

                // int  sa = Convert.ToInt32(ViewType.Bar);

                string[] typesName = Enum.GetNames(typeof(ViewType));

                typesValues = Enum.GetValues(typeof(ViewType));

 

                int i = 0;

                foreach (int item in typesValues)

                {

                    destek.Add(MyGrafikDestek(typesName[i])); //  ((BarSeriesLabel)series1.Label).Visible = true; kısmını destekleyip desteklemediğine bakıyorum

                    MyDurumAddRow(Convert.ToInt32(item) + "", typesName[i]);

                    i++;

                }

                lookSekil.Properties.DataSource = dt;

                lookSekil.Properties.DisplayMember = "value";

                lookSekil.Properties.ValueMember = "key";

                lookSekil.EditValue = "0";

            }

            catch (Exception ex)

            {

                RHMesaj.MyMessageError(MyClass, "MyGrafikLookAndDestek", "", ex);

            }

        }

        public bool MyGrafikDestek(string deger)

        {

            try

            {

                var content = (ViewType)Enum.Parse(typeof(ViewType), deger);

                series1 = new Series("", content); // ViewType.Bar

                ((BarSeriesLabel)series1.Label).Visible = true;

                return true;

            }

            catch (Exception ex)

            {

                return false;

            }

        }

        

        public void MyDurumAddRow(string key, string value)

        {

            try

            {

                dr = dt.NewRow();

                dr[0] = key;

                dr[1] = value;

                dt.Rows.Add(dr);

            }

            catch (Exception ex)

            {

                RHMesaj.MyMessageError(MyClass, "MyDurumAddRow", "", ex);

            }

        }

2-) grafik oluşturma

Series series1;

        public void MyCreate()

        {

            try

            {

                chartControl1.Series.Clear();

                string column = "";

                switch (lookDurum.EditValue.ToString())

                {

                    case "0": // Ana Alan

                        column = "uTeknikArizalar_anaAlan";

                        break;

                    case "1": // Bildiren Departma

                        column = "uTeknikArizalar_bildirenDepart";

                        break;

                    case "2": // Onaran Personel

                        column = "uTeknikArizalar_onarKullanici";

                        break;

                    case "3": // Ana Arıza

                        column = "uTeknikArizalar_anaAriza";

                        break;

                    default:

                        column = "uTeknikArizalar_anaAlan";

                        break;

                }

                string SQL = "select count(" + column + ") as toplam," + column + " from uTeknikArizalar where uTeknikArizalar_tarih BETWEEN '" + MyLibrary.MyGetSaatBasSQL(basTar.DateTime.ToString("yyyy-MM-dd HH:mm")) + "' AND '" + MyLibrary.MyGetSaatBitSQL(bitTar.DateTime.ToString("yyyy-MM-dd HH:mm")) + "' AND " + column + "<>'' AND " + column + " IS NOT NULL group by " + column + "";

 

                DataTable dt = RHVeritabani.MyGetDataTable(SQL);

 

                foreach (DataRow item in dt.Rows)

                {

                    var content = (ViewType)Enum.Parse(typeof(ViewType), lookSekil.EditValue.ToString());

                    series1 = new Series(item["toplam"].ToString() + " " + item["" + column + ""].ToString(), content); // ViewType.Bar

                    if (destek[Convert.ToInt32(lookSekil.EditValue)] == true) // destekleyenlerde true yapıyorum

                    {

                        ((BarSeriesLabel)series1.Label).Visible = true;

                    }

                    series1.Points.Add(new SeriesPoint(item["" + column + ""].ToString(), item["toplam"].ToString()));

                    chartControl1.Series.Add(series1);

                }

            }

            catch (InvalidCastException ex1)

            {

                RHMesaj.MyMessageInformation("Grafik Şekli Desteklenmiyor! Lütfen Grafik Şeklini Değiştiriniz.");

                Console.WriteLine(ex1.Message);

                lookSekil.Focus();

            }

            catch (ArgumentException ex2)

            {

                RHMesaj.MyMessageInformation("Grafik Şekli Desteklenmiyor! Lütfen Grafik Şeklini Değiştiriniz.");

                Console.WriteLine(ex2.Message);

                lookSekil.Focus();

            }

            catch (Exception ex)

            {

                RHMesaj.MyMessageError(MyClass, "MyCreate", ex.GetType().FullName, ex);

            }

        }

3-) YAZDIRMAK YANİ PRİNT YAPMAK GRAFİK chartControl1 print yapmak

 

        static ChartPrinter cp;

        public static void MyGrafikYazdir(ChartControl pChartControl1)

        {

            try

            {

                pChartControl1.OptionsPrint.SizeMode = PrintSizeMode.Stretch;

                pChartControl1.OptionsPrint.ImageFormat = PrintImageFormat.Bitmap;

 

                Link l = new Link(new PrintingSystem());

                l.Landscape = true;

                l.PaperKind = System.Drawing.Printing.PaperKind.A3;

                cp = new ChartPrinter(pChartControl1);

                cp.Initialize(l.PrintingSystem, l);

                cp.SizeMode = PrintSizeMode.Stretch;

                l.CreateDetailArea += new CreateAreaEventHandler(l_CreateDetailArea);

                l.ShowPreviewDialog();

                cp.Release();

            }

            catch (Exception ex)

            {

                throw new Exception(ex.Message);

            }

        }

       public static void l_CreateDetailArea(object sender, CreateAreaEventArgs e)

        {

            cp.CreateDetail(e.Graph);

        }

 

 2021 Ocak 18 Pazartesi
 364