【问题标题】:The Point values keep blinking (IsShowPointValues)点值不断闪烁 (IsShowPointValues)
【发布时间】:2023-04-02 17:24:01
【问题描述】:

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

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

有谁知道如何使用该补丁? 还是有其他解决办法?

【问题讨论】:

标签: c# graph patch zedgraph


【解决方案1】:

补丁是一个文本文件,两个版本的差异文件,你可以添加一个文件扩展名Tooltip_Flicker.patch.cs你可以用文本编辑器打开它(例如记事本++,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

【讨论】:

  • 对不起,我还是不明白“将文件修改为补丁文件然后重建它”。我已经下载了它并将格式文件更改为.cs,就像你说的那样。但是当我将它插入我的项目资源管理器(visual studio 2010)并重建它时。它显示了许多错误。
  • + 表示添加行;-表示删除行。您需要自己修改文件。然后重建项目。
  • --- source/ZedGraph/ZedGraphControl.Events.cs (revision 451) +++ source/ZedGraph/ZedGraphControl.Events.cs (working copy) @@ -713,15 +713,19 @@ 这些行只是您的附加信息。你可以删除它们。
  • 那么,这意味着它已经在zedgraph中实现了,不是吗?
  • @YusrilMaulidanRaji 这是 zedgraphic 的错误。所以现在你需要自己修复这个错误。补丁文件仅供参考。
【解决方案2】:

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

this.pointToolTip.Active = false; 

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

【讨论】:

    猜你喜欢
    • 2021-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-03
    • 2016-08-25
    • 1970-01-01
    相关资源
    最近更新 更多