Page 1 of 1
View only active series in legend
Posted: Sun May 18, 2008 2:09 pm
by 14048025
Q1: I'd like to see in the legend only the currently active series, how could I accomplish that ?
Q2: when hovring the mouse over a fastline series (or line series) The MarksTip tool shows the value of the last point in the series before the location of the mouse instead of the actual calculated value at the position on the line series (eg. between 2 points). how can i show the actual value between the points ?
Regards,
Yair
Posted: Mon May 19, 2008 8:59 am
by narcis
Hi Yair,
1. You can do something like this:
Code: Select all
foreach (Steema.TeeChart.Styles.Series s in tChart1.Series)
{
s.ShowInLegend = s.Active;
}
2. You can achieve that as in the
All Features\Welcome !\Chart styles\Standard\Line(Strip)\Interpolating line series example at the features demo, available at TeeChart's program group.
Posted: Mon May 19, 2008 10:42 am
by 14048025
Excellent.
problem 1 - solved.
Regarding problem 2:
Using the MarksTip tool, is there a way I can get the x value between 2 of the series' points currently pointed to by the mouse, in order to use it in the interpolation of y ?
Also, how can i tell which is the series currently pointed to by the mouse ?
Thanks and best regards,
Yair
Posted: Mon May 19, 2008 1:19 pm
by narcis
Hi Yair,
In that case you can use something like code below.
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.FillSampleValues();
tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
Steema.TeeChart.Tools.MarksTip marksTip1 = new Steema.TeeChart.Tools.MarksTip(tChart1.Chart);
marksTip1.GetText += new Steema.TeeChart.Tools.MarksTipGetTextEventHandler(marksTip1_GetText);
}
void marksTip1_GetText(Steema.TeeChart.Tools.MarksTip sender, Steema.TeeChart.Tools.MarksTipGetTextEventArgs e)
{
if (index != -1)
{
e.Text = "Series" + i.ToString() + ": " + xVal.ToString() + " / " + yVal.ToString();
}
}
private double xVal, yVal;
private int index = -1;
private int i;
void tChart1_MouseMove(object sender, MouseEventArgs e)
{
index = -1;
for (i = 0; i < tChart1.Series.Count; i++)
{
index = tChart1[i].Clicked(e.X, e.Y);
if (index != -1)
{
xVal = tChart1.Axes.Left.CalcPosPoint(e.X);
yVal = tChart1.Axes.Left.CalcPosPoint(e.Y);
break;
}
}
}
Posted: Tue May 20, 2008 1:47 pm
by 14048025
Perfect !
Many Thanks.