Point值保持闪烁(IsShowPointValues)

时间:2015-10-20 14:01:10

标签: c# graph patch zedgraph

我制作了一个图表,每次我将光标移动到任何一点时都会显示该值。我使用zedGraphControl1.IsShowPointValues = true;

问题是显示的工具提示是否闪烁。在网上浏览后,我找到了这个论坛帖子: http://sourceforge.net/p/zedgraph/patches/87/

有没有人知道如何使用该补丁? 或者还有其他解决方案吗?

2 个答案:

答案 0 :(得分:0)

补丁是一个文本文件,两个版本的差异文件,你可以添加一个文件扩展名Tooltip_Flicker.patch.cs你可以用texteditor打开它(例如.Notepad ++,Visual studio)

所以你需要下载源代码并将文件修改为补丁文件然后重建它。祝你好运!

内容如下:

     Index: source/ZedGraph/ZedGraphControl.Events.cs
 ===================================================================
 --- source/ZedGraph/ZedGraphControl.Events.cs  (revision 451)
 +++ source/ZedGraph/ZedGraphControl.Events.cs  (working copy)
 @@ -713,15 +713,19 @@
                {
                    if ( nearestObj is CurveItem && iPt >= 0 )
                    {
 -                      CurveItem curve = (CurveItem)nearestObj;
 +                      CurveItem curve = (CurveItem)nearestObj;
 +                        string label = "";
                        // Provide Callback for User to customize the tooltips
                        if ( this.PointValueEvent != null )
                        {
 -                          string label = this.PointValueEvent( this, pane, curve, iPt );
 +                          label = this.PointValueEvent( this, pane, curve, iPt );
                            if ( label != null && label.Length > 0 )
 -                          {
 -                              this.pointToolTip.SetToolTip( this, label );
 -                              this.pointToolTip.Active = true;
 +                          {
 +                                if ( this.pointToolTip.GetToolTip( this ) != label )
 +                                {
 +                                    this.pointToolTip.SetToolTip( this, label );
 +                                    this.pointToolTip.Active = true;
 +                                }
                            }
                            else
                                this.pointToolTip.Active = false;
 @@ -730,9 +734,8 @@
                        {

                            if ( curve is PieItem )
 -                          {
 -                              this.pointToolTip.SetToolTip( this,
 -                                  ( (PieItem)curve ).Value.ToString( _pointValueFormat ) );
 +                          {
 +                                label = ( (PieItem)curve ).Value.ToString( _pointValueFormat );
                            }
                            //                          else if ( curve is OHLCBarItem || curve is JapaneseCandleStickItem )
                            //                          {
 @@ -750,7 +753,7 @@
                                PointPair pt = curve.Points[iPt];

                                if ( pt.Tag is string )
 -                                  this.pointToolTip.SetToolTip( this, (string)pt.Tag );
 +                                  label = (string)pt.Tag;
                                else
                                {
                                    double xVal, yVal, lowVal;
 @@ -766,14 +769,18 @@
                                    string yStr = MakeValueLabel( curve.GetYAxis( pane ), yVal, iPt,
                                        curve.IsOverrideOrdinal );

 -                                  this.pointToolTip.SetToolTip( this, "( " + xStr + ", " + yStr + " )" );
 +                                  label = string.Format( "( {0}, {1} )", xStr, yStr );

                                    //this.pointToolTip.SetToolTip( this,
                                    //  curve.Points[iPt].ToString( this.pointValueFormat ) );
                                }
 -                          }
 -
 -                          this.pointToolTip.Active = true;
 +                          }
 +
 +                            if ( this.pointToolTip.GetToolTip( this ) != label )
 +                            {
 +                                this.pointToolTip.SetToolTip( this, label );
 +                                this.pointToolTip.Active = true;
 +                            }
                        }
                    }
                    else
 @@ -791,15 +798,19 @@
        {
            GraphPane pane = _masterPane.FindPane( mousePt );
            if ( pane != null && pane.Chart._rect.Contains( mousePt ) )
 -          {
 +          {
 +                string label = "";
                // Provide Callback for User to customize the tooltips
                if ( this.CursorValueEvent != null )
                {
 -                  string label = this.CursorValueEvent( this, pane, mousePt );
 +                  label = this.CursorValueEvent( this, pane, mousePt );
                    if ( label != null && label.Length > 0 )
 -                  {
 -                      this.pointToolTip.SetToolTip( this, label );
 -                      this.pointToolTip.Active = true;
 +                  {
 +                        if ( this.pointToolTip.GetToolTip( this ) != label )
 +                        {
 +                            this.pointToolTip.SetToolTip( this, label );
 +                            this.pointToolTip.Active = true;
 +                        }
                    }
                    else
                        this.pointToolTip.Active = false;
 @@ -812,8 +823,12 @@
                    string yStr = MakeValueLabel( pane.YAxis, y, -1, true );
                    string y2Str = MakeValueLabel( pane.Y2Axis, y2, -1, true );

 -                  this.pointToolTip.SetToolTip( this, "( " + xStr + ", " + yStr + ", " + y2Str + " )" );
 -                  this.pointToolTip.Active = true;
 +                    label = string.Format(  "( {0}, {1}, {2} )", xStr, yStr, y2Str );
 +                  if ( this.pointToolTip.GetToolTip( this ) != label )
 +                    {
 +                        this.pointToolTip.SetToolTip( this, "( " + xStr + ", " + yStr + ", " + y2Str + " )" );
 +                      this.pointToolTip.Active = true;
 +                    }
                }
            }
            else

答案 1 :(得分:0)

修复有一个缺陷。返回到同一点并不显示工具提示。为了解决这个问题,我替换了代码部分中的每个实例

this.pointToolTip.Active = false; 

{ this.pointToolTip.Active = false; this.pointToolTip.SetToolTip(this, ""); }