如何使ZedGraph清晰!? [英] how to make ZedGraph clear!!?

查看:99
本文介绍了如何使ZedGraph清晰!?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在程序中使用zedgraph,当我加载它时,它工作良好.但是,当我单击记录"按钮以插入其他信息时,因此该图重复了其条形以获取相同的信息,因此我想在记录或删除数据库中的任何信息之前先弄清楚.
请帮助我

i am using zedgraph in my program, it works good, when i load my it. but when i click on record button so as to insert other information, so the graph duplicated its bars for the same information, so i want to make it clear before i record or delete any information from database.
PLEASE help me

         try {

             // get a reference to the GraphPane
             GraphPane myPane = zg1.GraphPane;

             // Set the Titles
 myPane.Title.Text = "Les locations enregistrees dans la base de donnée";
 myPane.XAxis.Title.Text = "Les Locations";
 myPane.YAxis.Title.Text = "La durée du location & Prix du location";

             // Make up some data points
             int iNbLocations = 0;
         _bd.Command.CommandText = "SELECT COUNT(*) FROM locations";
             Debug.WriteLine( Environment.NewLine );
             Debug.WriteLine( _bd.Command.CommandText );
             _bd.Reader = _bd.Command.ExecuteReader();
             if (_bd.Reader.Read()) {
             iNbLocations = int.Parse(_bd.Reader[0].ToString());
             }//if
             _bd.Reader.Close();
             //Max = 5
             if (iNbLocations > 5) {
                 iNbLocations = 5;
             }//if
         //Initialisation de la taille des tableaux des données
             string[] labels = new string[iNbLocations];
             double[] y = new double[iNbLocations];
             double[] y2 = new double[iNbLocations];
                     _bd.Command.CommandText = "SELECT NbJourLocation,"+
                     "DateLocation, idLocations, PrixLocation " +
         "FROM Locations ORDER BY Idlocations desc LIMIT 5";

         Debug.WriteLine( Environment.NewLine );
         Debug.WriteLine( _bd.Command.CommandText );
         _bd.Reader = _bd.Command.ExecuteReader();
         for (int i=0; i<inblocations;i++)
                     if(_bd.Reader.Read()) {

     labels[i] = _bd.Reader["idLocations"].ToString();
     y[i] = double.Parse(_bd.Reader["NbJourLocation"].ToString());
     y2[i] = double.Parse(_bd.Reader["PrixLocation"].ToString());

             }//if

         }//for i
         _bd.Reader.Close();

         // Generate a red bar with "Curve 1" in the legend
BarItem myBar = myPane.AddBar(  "Nombres des Jours du Location", null, y,
                                       Color.GreenYellow );
    myBar.Bar.Fill = new Fill( Color.Red, Color.Azure,
                                       Color.Red );

     // Generate a blue bar with "Curve 2" in the legend
     myBar = myPane.AddBar( "Prix Location", null, y2, Color.Blue );
     myBar.Bar.Fill = new Fill( Color.Blue, Color.White,
                                       Color.Blue );



     // Draw the X tics between the labels instead of
     // at the labels
     myPane.XAxis.MajorTic.IsBetweenLabels = true;

     // Set the XAxis labels
     myPane.XAxis.Scale.TextLabels = labels;
     // Set the XAxis to Text type
     myPane.XAxis.Type = AxisType.Text;
     // Fill the Axis and Pane backgrounds
     myPane.Chart.Fill = new Fill( Color.White,
                        Color.FromArgb( 255, 255, 166), 90F );
     myPane.Fill = new Fill( Color.FromArgb( 250, 250, 255) );



     }//try
 catch (Exception ex) {
     Debug.WriteLine( Environment.NewLine );
     Debug.WriteLine( ex.Message );
         MessageBox.Show("Une erreur a été détectée : " +
                Environment.NewLine + ex.Message, "Erreur");
     }

     // Tell ZedGraph to refigure the
     // axes since the data have changed

     zg1.AxisChange();

推荐答案

将其放在try块的第一行之后即可.

Putting this right after the first line in the try block should do it.

myPane.Clear() 



我感到您的图形感到痛苦.



I feel your graph pain.


您是否尝试过:
zg1.GraphPane.CurveList.Clear();
zg1.GraphPane.GraphObjList.Clear();

zg1.GraphPane = New GraphPane();
Have you tried:
zg1.GraphPane.CurveList.Clear();
zg1.GraphPane.GraphObjList.Clear();
or
zg1.GraphPane = New GraphPane();


这篇关于如何使ZedGraph清晰!?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆