Page 1 of 1
Using a personal icon as Point Style of a Series
Posted: Wed May 24, 2006 11:23 pm
by 9790845
Hi,
I would like to use a personal icon as a point style shape of a series, and similar icon should be able to display in Legend also.
Currently, TeeChart offers some internal Style type like Circle, Triangle and so on.
The tutorial has a chapter "using Custom drawing on the Chart Panel" to draw special shape on Chart, but can It draw similar icon at Legend.
Thanks for any help in advance.
Lewis
Posted: Thu May 25, 2006 8:53 am
by narcis
Hi Lewis,
I would like to use a personal icon as a point style shape of a series, and similar icon should be able to display in Legend also.
Currently, TeeChart offers some internal Style type like Circle, Triangle and so on.
You can easily do it by implementing a custom series where you can set the image you want as pointer as shown in this example:
Code: Select all
namespace ChartSamples
{
public partial class ChartSamples : Form
{
public ChartSamples()
{
InitializeComponent();
ImagePoint imagePoint = new ImagePoint(tChart1.Chart);
imagePoint.Image = pictureBox1.Image;
imagePoint.FillSampleValues(100);
}
private void tChart1_Click(object sender, EventArgs e)
{
tChart1.ShowEditor();
}
}
public class ImagePoint : Steema.TeeChart.Styles.CustomPoint
{
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);
Graphics3D g = Chart.Graphics3D;
g.Draw(R, image, true);
//g.TextOut(R.Left, R.Top, "A");
}
}
}
}
The tutorial has a chapter "using Custom drawing on the Chart Panel" to draw special shape on Chart, but can It draw similar icon at Legend.
This can also be done as shown in the
What's New?\Welcome !\New in Legend\OnDrawSymbol Event example at TeeChart features demo. You'll find the demo at TeeChart's program group.