Hi,
Could you please help me with the following:
I need to show marks oriented vertically at some fixed distance from data points.
It seems that Points series with Marks oriented vertically would satisfy my needs.
However, text lengths in the marks might vary significantly for different marks.
I tried to use Marks.Arrow to define the distance between the points and the marks, but the distance is calculated from a point to the middle of the mark rectangle. Hence, with vertical orientation the distance between a point and the beginning of the text varies from point to point depending on the lengths of the text. The picture attached illustrates the problem.
Is there any way to define distance from points to the beginning of the text, not to the middle of the text? Or maybe some other ways to get the behavior I need?
I would appreciate your help.
Thanks
Vladimir
Drawing vertical marks
-
- Newbie
- Posts: 4
- Joined: Mon Nov 15, 2010 12:00 am
Drawing vertical marks
- Attachments
-
- Marks.JPG (27.01 KiB) Viewed 3665 times
Re: Drawing vertical marks
Hello Vladimir,
I have made a simple solution, using Marks custom position. Could you please check if next code works as you want?
I hope will helps.
Thanks,
I have made a simple solution, using Marks custom position. Could you please check if next code works as you want?
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
Steema.TeeChart.Styles.Points points = new Steema.TeeChart.Styles.Points(tChart1.Chart);
points.FillSampleValues(5);
points.Marks.Visible = true;
points.Marks.Angle = 90;
points.GetSeriesMark += new Steema.TeeChart.Styles.Series.GetSeriesMarkEventHandler(points_GetSeriesMark);
tChart1.Draw();
for (int i = 0; i < points.Marks.Positions.Count; i++)
{
points.Marks.Positions[i].Custom = true;
points.Marks.Positions[i].LeftTop.Y = points.Marks.Positions[i].LeftTop.Y - (points.Marks.Positions[i].Width - 5);
points.Marks.Positions[i].ArrowTo.X = points.CalcXPos(i);
points.Marks.Positions[i].ArrowTo.Y = points.CalcYPos(i);
}
}
void points_GetSeriesMark(Steema.TeeChart.Styles.Series series, Steema.TeeChart.Styles.GetSeriesMarkEventArgs e)
{
if (series.XValues[e.ValueIndex]%2==0)
{
e.MarkText = "Significantly longer Text --"+e.ValueIndex.ToString();
}
else
{
e.MarkText = "Text --"+e.ValueIndex.ToString();
}
}
Thanks,
Best Regards,
Sandra Pazos / 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 |
-
- Newbie
- Posts: 4
- Joined: Mon Nov 15, 2010 12:00 am
Re: Drawing vertical marks
Hi Sandra,
That worked, thanks.
Here is my solution for that:
internal class PointsEx : Steema.TeeChart.Styles.Points
{
public PointsEx(Steema.TeeChart.Chart c) : base(c) {}
protected override void DrawMark(int index, string s, SeriesMarks.Position position)
{
Graphics3D g = Chart.Graphics3D;
SizeF size = g.MeasureString(g.Font, s);
position.LeftTop = new Point(position.LeftTop.X, position.LeftTop.Y - (int)(size.Width / 2));
base.DrawMark(index, s, position);
}
}
That worked, thanks.
Here is my solution for that:
internal class PointsEx : Steema.TeeChart.Styles.Points
{
public PointsEx(Steema.TeeChart.Chart c) : base(c) {}
protected override void DrawMark(int index, string s, SeriesMarks.Position position)
{
Graphics3D g = Chart.Graphics3D;
SizeF size = g.MeasureString(g.Font, s);
position.LeftTop = new Point(position.LeftTop.X, position.LeftTop.Y - (int)(size.Width / 2));
base.DrawMark(index, s, position);
}
}
Re: Drawing vertical marks
Hello Vladimir,
Thank you for your example of code. I am glad that your problem is solved .
Thanks,
Thank you for your example of code. I am glad that your problem is solved .
Thanks,
Best Regards,
Sandra Pazos / 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 |