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?
Unable to get Series Click event to fire
-
- Advanced
- Posts: 192
- Joined: Thu Feb 01, 2007 12:00 am
- Contact:
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
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?
Thanks in advance.
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);
}
}
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Advanced
- Posts: 192
- Joined: Thu Feb 01, 2007 12:00 am
- Contact:
Additional Details
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.
See the SeriesClickEventNotFiring.zip I just uploaded.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
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.
If you want to use series click with DragPoint tool you may use tool's Drag event:
Hope this helps!
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());
}
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());
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Advanced
- Posts: 192
- Joined: Thu Feb 01, 2007 12:00 am
- Contact:
Bug?
So if the DragTool masks the click event, isn't that a bug?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
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.
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.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Advanced
- Posts: 192
- Joined: Thu Feb 01, 2007 12:00 am
- Contact:
can we specify double click event
My need is for a double click event. Is it possible to add this as well? I know the chart supports a double click.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Mike,
Ok, I'll add this to the list too. TChart's DoubleClick event already works fine in those circumstances:
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";
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |