Page 1 of 1

Drawing vertical marks

Posted: Tue Dec 14, 2010 2:48 am
by 15657852
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

Re: Drawing vertical marks

Posted: Wed Dec 15, 2010 1:23 pm
by 10050769
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,

Re: Drawing vertical marks

Posted: Thu Feb 10, 2011 8:33 pm
by 15657852
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);
}
}

Re: Drawing vertical marks

Posted: Fri Feb 11, 2011 10:56 am
by 10050769
Hello Vladimir,

Thank you for your example of code. I am glad that your problem is solved :).

Thanks,