Drawing vertical marks

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
VladimirDenisov
Newbie
Newbie
Posts: 4
Joined: Mon Nov 15, 2010 12:00 am

Drawing vertical marks

Post by VladimirDenisov » Tue Dec 14, 2010 2:48 am

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
Attachments
Marks.JPG
Marks.JPG (27.01 KiB) Viewed 3665 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Drawing vertical marks

Post by Sandra » Wed Dec 15, 2010 1:23 pm

Hello Vladimir,

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();
            }
        }
I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

VladimirDenisov
Newbie
Newbie
Posts: 4
Joined: Mon Nov 15, 2010 12:00 am

Re: Drawing vertical marks

Post by VladimirDenisov » Thu Feb 10, 2011 8:33 pm

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);
}
}

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Drawing vertical marks

Post by Sandra » Fri Feb 11, 2011 10:56 am

Hello Vladimir,

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
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply