Page 1 of 1
Fixed Point on a chart and Points Sereies
Posted: Fri Oct 24, 2008 6:53 am
by 13047002
Q1) I want to add a point to a Line Series chart. I have tried adding a annotation. But on reize when trying to move it with the line it fails.
m_seltool.Callout.XPosition = tChart.Series[0].CalcXPos(AIndex);
m_seltool.Callout.YPosition = tChart.Series[0].CalcYPos(AIndex);
I store AIndex which I assume to be index of value in series. have tried after redraw and resize but annotation is not moved correctly.
Even if I click on the line after resize at a similar position so AIndex is the same there is no update on the CalcXpos value. I have to click on different position so AIndex changes. I assume this is a bug
Q2) Point Series
Which property to I use to change the shape of the points from the default square?
Thx
Posted: Fri Oct 24, 2008 8:38 am
by narcis
Hi Luke,
1. For annotation's being updated you need to do something like this:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Tools.Annotation annotation1;
private int ValueIndex = 5;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.FillSampleValues();
annotation1 = new Steema.TeeChart.Tools.Annotation(tChart1.Chart);
annotation1.Text = "hello!";
annotation1.Callout.Visible = true;
tChart1.Dock = DockStyle.Fill;
tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
tChart1.Zoomed += new EventHandler(tChart1_Zoomed);
tChart1.Scroll += new EventHandler(tChart1_Scroll);
tChart1.UndoneZoom += new EventHandler(tChart1_UndoneZoom);
tChart1.Resize += new EventHandler(tChart1_Resize);
ChartInternalRepaint();
}
private void ChartInternalRepaint()
{
Bitmap bmp = tChart1.Bitmap;
}
void tChart1_Resize(object sender, EventArgs e)
{
ChartInternalRepaint();
}
void tChart1_UndoneZoom(object sender, EventArgs e)
{
ChartInternalRepaint();
}
void tChart1_Scroll(object sender, EventArgs e)
{
ChartInternalRepaint();
}
void tChart1_Zoomed(object sender, EventArgs e)
{
ChartInternalRepaint();
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
annotation1.Callout.XPosition = tChart1[0].CalcXPos(ValueIndex);
annotation1.Callout.YPosition = tChart1[0].CalcYPos(ValueIndex);
}
2. You need to use Pointer.Style:
Code: Select all
points1.Pointer.Style = Steema.TeeChart.Styles.PointerStyles.Circle;
Posted: Fri Oct 24, 2008 8:48 am
by 13047002
ChartInternalRepaint(); what is this? dont see it on chart object.
Posted: Fri Oct 24, 2008 8:51 am
by narcis
Hi Luke,
It doesn't exist in TeeChart. It actually is:
Since I needed to use it at several places in my example I implemented this:
Code: Select all
private void ChartInternalRepaint()
{
Bitmap bmp = tChart1.Bitmap;
}
Calling Bitmap method forces the chart being repainted internally and therefore all chart objects are repositioned.
Posted: Fri Oct 24, 2008 8:53 am
by 13047002
Considering doing these points as 1 point series instead. As annotations dont move on a resize, makes them quite painfull to use.
But shoundnt the afterredraw be enough alone, you would think after a resize, the calcX,Calcy should work ok.
Posted: Fri Oct 24, 2008 10:45 am
by narcis
Hi Luke,
Actually you can use Draw() method instead of Bitmap:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Tools.Annotation annotation1;
private int ValueIndex = 5;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.FillSampleValues();
annotation1 = new Steema.TeeChart.Tools.Annotation(tChart1.Chart);
annotation1.Text = "hello!";
annotation1.Callout.Visible = true;
tChart1.Dock = DockStyle.Fill;
tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
tChart1.Zoomed += new EventHandler(tChart1_Zoomed);
tChart1.Scroll += new EventHandler(tChart1_Scroll);
tChart1.UndoneZoom += new EventHandler(tChart1_UndoneZoom);
tChart1.Resize += new EventHandler(tChart1_Resize);
tChart1.Draw();
}
void tChart1_Resize(object sender, EventArgs e)
{
tChart1.Draw();
}
void tChart1_UndoneZoom(object sender, EventArgs e)
{
tChart1.Draw();
}
void tChart1_Scroll(object sender, EventArgs e)
{
tChart1.Draw();
}
void tChart1_Zoomed(object sender, EventArgs e)
{
tChart1.Draw();
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
annotation1.Callout.XPosition = tChart1[0].CalcXPos(ValueIndex);
annotation1.Callout.YPosition = tChart1[0].CalcYPos(ValueIndex);
}
Calling Draw() method is necessary for resetting internal variables when the size of the chart is changed. The only way to do this is to draw the chart first to reset them correctly.
Posted: Fri Oct 24, 2008 12:45 pm
by 13047002
Hi Narcis
I changed all to Point series with 1 point, then I dont have to worry about moving them manually. Thx