Page 1 of 1
Unable to get Series Click event to fire
Posted: Wed Jan 21, 2009 5:51 pm
by 8739068
I have a derived class that derives off of Steema.TeeChart.Styles.Points class. I call my new class DragPiontsSeries.
I create an instance of this class
I add it to the TeeChart.Series collection and make sure it is visible
I wire up to the click event
Then when I click on a point in the series, I never see the click event fire.
Ultimately I would like to capture a double click on this point series. I was thinking that I could detect a double click by the MouseEventArgs that are passed by the event.
Is there a better way to try to implement this?
Why is the click event never firing?
Posted: Thu Jan 22, 2009 10:46 am
by narcis
Hi Mike,
This works fine for me here using latest TeeChart for .NET v3 release and code below which creates a custom series. Does this code work fine for you?
Code: Select all
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
ImagePoint imagePoint = new ImagePoint(tChart1.Chart);
imagePoint.Image = pictureBox1.Image;
imagePoint.FillSampleValues(10);
imagePoint.Click += new MouseEventHandler(imagePoint_Click);
}
void imagePoint_Click(object sender, MouseEventArgs e)
{
this.Text = tChart1[0].Clicked(e.X, e.Y).ToString();
}
}
public class ImagePoint : Steema.TeeChart.Styles.Points
{
private Image image;
public ImagePoint(Steema.TeeChart.Chart c)
: base(c)
{
}
public Image Image
{
get { return image; }
set { image = value; }
}
public override string Description
{
get
{
return "ImagePoint";
}
}
public override void DrawValue(int index)
{
Rectangle R;
if (image == null) base.DrawValue(index);
else
{
Pointer.HorizSize = image.Width;
Pointer.VertSize = image.Height;
int left = CalcXPos(index) - (Pointer.HorizSize / 2);
int top = CalcYPos(index) - (Pointer.VertSize / 2);
R = Rectangle.FromLTRB(left,
top,
left + Pointer.HorizSize,
top + Pointer.VertSize);
Steema.TeeChart.Drawing.Graphics3D g = Chart.Graphics3D;
g.Draw(R, image, true);
}
}
}
Thanks in advance.
Additional Details
Posted: Thu Jan 22, 2009 5:05 pm
by 8739068
your code above works for me. Can you take a look at some code in a project I just uploaded and tell me why the Click event is not firing?
See the SeriesClickEventNotFiring.zip I just uploaded.
Posted: Fri Jan 23, 2009 10:03 am
by narcis
Hi Mike,
The problem here is the DragPoint tool as it masks series' Click event. Commenting in tool's code makes Click event work fine.
Code: Select all
private void InitializeChart()
{
//ImagePoint imagePoint = new ImagePoint(tChart1.Chart);
//imagePoint.Image = pictureBox1.Image;
TccDragPointsSeries imagePoint = new TccDragPointsSeries(tChart1.Chart);
imagePoint.FillSampleValues(10);
imagePoint.Click += new MouseEventHandler(imagePoint_Click);
//tChart1.Tools.Add(new Steema.TeeChart.Tools.DragPoint());
}
If you want to use series click with DragPoint tool you may use tool's Drag event:
Code: Select all
private void InitializeChart()
{
//ImagePoint imagePoint = new ImagePoint(tChart1.Chart);
//imagePoint.Image = pictureBox1.Image;
TccDragPointsSeries imagePoint = new TccDragPointsSeries(tChart1.Chart);
imagePoint.FillSampleValues(10);
imagePoint.Click += new MouseEventHandler(imagePoint_Click);
tChart1.Tools.Add(new Steema.TeeChart.Tools.DragPoint());
(tChart1.Tools[0] as Steema.TeeChart.Tools.DragPoint).Drag += new Steema.TeeChart.Tools.DragPointEventHandler(Form1_Drag);
}
void Form1_Drag(Steema.TeeChart.Tools.DragPoint sender, int index)
{
Debug.WriteLine("series clicked at " + index.ToString());
}
Hope this helps!
Bug?
Posted: Wed Feb 04, 2009 10:05 pm
by 8739068
So if the DragTool masks the click event, isn't that a bug?
Posted: Thu Feb 05, 2009 11:36 am
by narcis
Hi Mike,
I've checked that when you have Click event assigned to a TChart and you zoom it, zoom is performend and event fired. So most consistent behavior would be what you suggest. So I've added the issue (TF02013836) to the list to be fixed.
can we specify double click event
Posted: Thu Feb 05, 2009 1:06 pm
by 8739068
My need is for a double click event. Is it possible to add this as well? I know the chart supports a double click.
Posted: Thu Feb 05, 2009 1:11 pm
by narcis
Hi Mike,
Ok, I'll add this to the list too. TChart's DoubleClick event already works fine in those circumstances:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
Steema.TeeChart.Styles.Points points1 = new Steema.TeeChart.Styles.Points(tChart1.Chart);
points1.FillSampleValues();
Steema.TeeChart.Tools.DragPoint dragPoint1 = new Steema.TeeChart.Tools.DragPoint(tChart1.Chart);
points1.DblClick += new MouseEventHandler(points1_DblClick);
tChart1.DoubleClick += new EventHandler(tChart1_DoubleClick);
}
void tChart1_DoubleClick(object sender, EventArgs e)
{
tChart1.Header.Text = "Chart double-clicked";
}
void points1_DblClick(object sender, MouseEventArgs e)
{
this.Text = "Series double-clicked";
}