We are using ImagePoint seriesto display data on TeeChart. We are performing some operations when each of the points are clicked, based on the index of the clicked point. We are using the ImagePoint.ClickPointer event to handle this and using the 'valueIndex' parameter. But when the points are placed a bit closer (or when there is a slight overlap), the valueIndex returned by the ClickPointer event is not so accurate.
Same problem happens with the TChart.ClickSeries event as well.
Here is the sample code for your reference:
Code: Select all
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Steema.TeeChart.Styles;
namespace SampleTrend
{
public partial class Form8 : Form
{
public Form8()
{
InitializeComponent();
}
private void Form8_Load(object sender, EventArgs e)
{
ImagePoint points = new ImagePoint(tChart1.Chart);
points.Pointer.HorizSize = 16;
points.Pointer.VertSize = 16;
points.Add(1, 1);
points.Add(2, 1);
points.Add(3, 1);
points.ClickPointer += new CustomPoint.ClickPointerEventHandler(points_ClickPointer);
tChart1.ClickSeries += new Steema.TeeChart.TChart.SeriesEventHandler(tChart1_ClickSeries);
tChart1.Axes.Bottom.SetMinMax(0, 30);
}
void tChart1_ClickSeries(object sender, Series s, int valueIndex, MouseEventArgs e)
{
//valueIndex is not always accurate; try clicking on the center of each point
MessageBox.Show(valueIndex.ToString());
}
void points_ClickPointer(CustomPoint series, int valueIndex, int x, int y)
{
//valueIndex is not always accurate; try clicking on the center of each point
MessageBox.Show(valueIndex.ToString());
}
}
}