我製作了一個圖形,並且每次在任何點上移動光標時都會顯示該值。我使用zedGraphControl1.IsShowPointValues = true;
。點值保持閃爍(IsShowPointValues)
問題是顯示的工具提示閃爍。在互聯網上環顧四周,我發現這個論壇主題: http://sourceforge.net/p/zedgraph/patches/87/
有沒有人知道如何使用該補丁? 還是有其他解決方案嗎?
我製作了一個圖形,並且每次在任何點上移動光標時都會顯示該值。我使用zedGraphControl1.IsShowPointValues = true;
。點值保持閃爍(IsShowPointValues)
問題是顯示的工具提示閃爍。在互聯網上環顧四周,我發現這個論壇主題: http://sourceforge.net/p/zedgraph/patches/87/
有沒有人知道如何使用該補丁? 還是有其他解決方案嗎?
補丁是一個文本文件中的兩個版本的差異文件,你可以添加文件擴展名作爲Tooltip_Flicker.patch.cs
你可以用文本編輯打開它(eg.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
對不起,我還是不明白「修改文件作爲補丁文件,然後重建它。」 我已經下載它並將格式文件更改爲.cs,就像你說的。但是當我將它插入到我的項目資源管理器(Visual Studio 2010)中並重建它時。它顯示了很多錯誤。 –
'+'表示添加該行;'-'表示刪除該行。你需要自己修改文件。然後重建該項目。 – huoxudong125
'--- source/ZedGraph/ZedGraphControl.Events.cs(修訂版451) +++ source/ZedGraph/ZedGraphControl.Events.cs(工作副本) @@ -713,15 +713,19 @@'這些行只是你的附加信息。你可以刪除它們。 – huoxudong125
的修復有一個缺陷。回到同一點不會顯示工具提示。爲了解決這個問題我的代碼
this.pointToolTip.Active = false;
部分代替每個實例有
{ this.pointToolTip.Active = false; this.pointToolTip.SetToolTip(this, ""); }
這已被固定在掘金提供的最後ZedGraph版本。 – Larry
@Larry嗯,我不知道SourceForge(https://sourceforge.net/projects/zedgraph/files/zedgraph%20dll%20only/)中的一個與Nugget中的一個(https ://www.nuget.org/packages/ZedGraph/)。我會在下次嘗試。謝謝(你的)信息。 –