Page 1 of 1
Individual Points marked by a square and clickable
Posted: Thu Mar 09, 2006 2:10 pm
by 9637396
Hi
I have a line series with about 1000 points.
I would like to have some of the points have a visible mark e.g. a square and then be able to click these points and act on the event. But I do not want the rest of the points to be marked and clickable.
Is that possible? How?
Thanks in advance
Lars Iversen
Posted: Thu Mar 09, 2006 3:02 pm
by narcis
Hi Lars,
Yes, this is possible. You need to do like this:
Code: Select all
private void Form1_Load(object sender, System.EventArgs e)
{
line1.FillSampleValues();
line1.Pointer.Visible=true;
}
private void line1_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventArgs e)
{
if ((series.YValues[e.ValueIndex]%2)==0)
e.Style=Steema.TeeChart.Styles.PointerStyles.Rectangle;
else
e.Style=Steema.TeeChart.Styles.PointerStyles.Nothing;
}
private void line1_ClickPointer(Steema.TeeChart.Styles.CustomPoint series, int valueIndex, int x, int y)
{
tChart1.Header.Text="Point "+valueIndex.ToString()+" clicked";
}
private void line1_Click(object sender, MouseEventArgs e)
{
//Trick to force ClickPointer event being raised
}
Please notice that you need to associate a series click event as well. This is because we detected that ClickPointer event is wrongly implemented and thus it wouldn't be raised. Now we are trying to implement a solution for future releases but, in the meantime, this trick is necessary.
Posted: Sun Mar 12, 2006 8:57 pm
by 9637396
Hi Narcís
Thanks that helps a lot.
But the unmarked points are still clickable and the click event gets fired. Is there a way to avoid that or do I have to keep track of which point-indexes I should react to clicks on?
Thanks
Lars
Posted: Mon Mar 13, 2006 11:49 am
by narcis
Hi Lars,
The event is raised because the pointer is also visible for those points but set to
Nothing. However, you can ignore them by using something like this:
Code: Select all
private void Form1_Load(object sender, System.EventArgs e)
{
line1.FillSampleValues();
line1.Pointer.Visible=true;
}
private void line1_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventArgs e)
{
if (Screenpoints(e.ValueIndex))
e.Style=Steema.TeeChart.Styles.PointerStyles.Rectangle;
else
e.Style=Steema.TeeChart.Styles.PointerStyles.Nothing;
}
private bool Screenpoints(int index)
{
return line1.YValues[index] % 2 == 0;
}
private void line1_ClickPointer(Steema.TeeChart.Styles.CustomPoint series, int valueIndex, int x, int y)
{
if (Screenpoints(valueIndex))
tChart1.Header.Text = "Point " + valueIndex.ToString() + " clicked";
}
private void line1_Click(object sender, MouseEventArgs e)
{
//Trick to force ClickPointer event being raised
}
Posted: Mon Mar 13, 2006 7:10 pm
by 9637396
Hi Narcís
But all thiss assumes that it is for the points with the value 0 that I want to be clickable. But that is not the case.
In my head it is like this:
I have many points.
Some of the points has a text-label others do not.
The points with the text label has to be clickable the rest may not be clickable.
Is it not possible to get like a "point-object" from a series and work on properties like label, yvalue, xvalue, pointerstyle etc and then when that point is clicked ask if it has a square mark as pointerstyle and work from there?
(Maybe this is real newbie question)
Thanks
Lars Iversen
Posted: Tue Mar 14, 2006 12:42 pm
by narcis
Hi Lars,
Screenpoints is true when the indexed point Y value is a multiple of 2. That's just an easy sample condition I used to make an example which you can change for something like this:
Code: Select all
private bool Screenpoints(int index)
{
return line1[index].Label!="";
}
to check wether a point has a text label or not. The "point-object" class you can use is
Steema.TeeChart.Styles.SeriesXYPoint which is what is used in the example above when doing
line1[index].
Posted: Tue Mar 14, 2006 1:09 pm
by 9637396
Ok. Thanks.
...and once again thatnks for answering so fast.
Br
Lars