Page 1 of 1
Questions regarding MarksTip tool
Posted: Sat Aug 02, 2008 11:15 am
by 13046940
Hi I am currently using version 3.2.2945.19737 of the TeeChart library.
I have multiple line series in a graph and need to use MarksTip to display custom information about each point on mouseover.
1) When the marks tip label is about to appear on mouseover of a line between two points, it always shows the values of the previous point, even if the mouse is really close to the next point. How can you change this behaviour so that the text displayed uses the nearest point instead of the precedent point?
NOTE: I have found a way around this problem by combining a NearestPoint tool to the MarksTip tool and retrieving the nearest point in the marksTip1_GetText event. This works fine when you have only 1 series since the NearestPoint tool can only work on 1 series at the time, but this solution becomes very complex when you have multiple series (up to 20) in a graph, since you would need a NearestPoint tool for each.
2) I have a MarksTip tool configured to use ALL series in a graph. In the marksTip1_GetText event, how can you easily resolve which series the markstip is about to appear for?
3) Question/Suggestion: Following the last question, I believe the marksTip1_GetText event would be much easier to work with if the MarksTipGetTextEventArgs argument contained the actual series from which it was being triggered. Any reason why it does not appear in the argument?
Thanks an advance!
Re: Questions regarding MarksTip tool
Posted: Mon Aug 04, 2008 7:22 am
by Chris
Hello Sim,
Sim wrote:
1) When the marks tip label is about to appear on mouseover of a line between two points, it always shows the values of the previous point, even if the mouse is really close to the next point. How can you change this behaviour so that the text displayed uses the nearest point instead of the precedent point?
NOTE: I have found a way around this problem by combining a NearestPoint tool to the MarksTip tool and retrieving the nearest point in the marksTip1_GetText event. This works fine when you have only 1 series since the NearestPoint tool can only work on 1 series at the time, but this solution becomes very complex when you have multiple series (up to 20) in a graph, since you would need a NearestPoint tool for each.
I think this is the best way to work around the issue.
Sim wrote:
2) I have a MarksTip tool configured to use ALL series in a graph. In the marksTip1_GetText event, how can you easily resolve which series the markstip is about to appear for?
You could try something similar to the following:
Code: Select all
private Steema.TeeChart.Styles.Line series, series1;
private Steema.TeeChart.Tools.NearestPoint tool;
private Steema.TeeChart.Tools.MarksTip tool1;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Series.Add(series = new Line());
tChart1.Series.Add(series1 = new Line());
series.Pointer.Visible = true;
series1.Pointer.Visible = true;
series.FillSampleValues();
series1.FillSampleValues();
tChart1.Tools.Add(tool1 = new MarksTip());
tChart1.Tools.Add(tool = new NearestPoint());
tool.Series = series;
tool.Pen.Visible = false;
tChart1.BeforeDraw += new PaintChartEventHandler(tChart1_BeforeDraw);
tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
tool1.GetText += new MarksTipGetTextEventHandler(tool1_GetText);
tool.Change += new EventHandler(tool_Change);
}
void tChart1_BeforeDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
if (seriesIndex != -1)
{
tool.Series = tChart1[seriesIndex];
}
}
private string text = null;
private int seriesIndex = -1;
void tChart1_MouseMove(object sender, MouseEventArgs e)
{
int pointIndex;
for (int i = 0; i < tChart1.Series.Count; i++)
{
pointIndex = tChart1[i].Clicked(e.Location);
if (pointIndex != -1)
{
seriesIndex = i;
tChart1.Invalidate();
}
}
}
void tool_Change(object sender, EventArgs e)
{
if (tool.Point != -1)
{
text = tool.Series.YValues[tool.Point].ToString();
}
else
{
text = null;
}
}
void tool1_GetText(MarksTip sender, MarksTipGetTextEventArgs e)
{
if (text != null)
{
e.Text = text;
}
}
Sim wrote:
3) Question/Suggestion: Following the last question, I believe the marksTip1_GetText event would be much easier to work with if the MarksTipGetTextEventArgs argument contained the actual series from which it was being triggered. Any reason why it does not appear in the argument?
No, there is no particular reason. I have added the idea as a feature request.
Posted: Mon Aug 04, 2008 7:40 am
by 13046940
Hi, thank you for your quick reply!
Regarding question 1, do you have any other suggestion than the one I mentionned to resolve the nearest point when the MarksTip is displayed? As I wrote in the note, the solution I found works, but is very inconvenient when you have multiple line series, error series and point series in the same graph.
Any other suggestion?
Thanks again!
Posted: Mon Aug 04, 2008 7:53 am
by Chris
Hello Sim,
Sim wrote:
Regarding question 1, do you have any other suggestion than the one I mentionned to resolve the nearest point when the MarksTip is displayed? As I wrote in the note, the solution I found works, but is very inconvenient when you have multiple line series, error series and point series in the same graph.
No, I can't think of another solution at the moment, I'm afraid. Please be aware that the code I posted solves the problem of using one nearestpoint tool with more than one series. Of course, you might not want to use a nearestpoint tool with an error series, for example, in which case you can easily disable the nearestpoint tool and/or not write the text back within the GetText() event.