Series marks do not resize properly

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
OMP
Newbie
Newbie
Posts: 21
Joined: Mon Dec 10, 2012 12:00 am

Series marks do not resize properly

Post by OMP » Tue Aug 13, 2013 7:37 am

Dear,

I have a line chart with series marks that contain 2 lines of text. When the first line is longer then the second one, the series marks are not resized correctly. This means that there is no space between the letters and the border of the series marks and sometimes the text even goes outside of the border.
If the second line is longer then the first one, everything works fine.
Is it possible to resize this properly?

My code is the following:

Code: Select all

void lineSeries_GetSeriesMark(Steema.TeeChart.Styles.Series series, Steema.TeeChart.Styles.GetSeriesMarkEventArgs e) 
        { 
            e.MarkText = "Mark text string \n value: " + e.ValueIndex; 
        }

public Form1()
        {
            InitializeComponent();

            tChart1.Aspect.View3D = false;
            Steema.TeeChart.Styles.Line line = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            Steema.TeeChart.Styles.SeriesMarks marks = new Steema.TeeChart.Styles.SeriesMarks();
            line.GetSeriesMark += new Steema.TeeChart.Styles.Series.GetSeriesMarkEventHandler(lineSeries_GetSeriesMark);
            for (int i = 0; i < 10; i++)
            {
               line.Add(i*i);
            }
        }
Attachments
Series marks issue.PNG
Series marks issue.PNG (17.76 KiB) Viewed 7404 times

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

Re: Series marks do not resize properly

Post by Sandra » Tue Aug 13, 2013 11:51 am

Hello OMP,

Isn't the Autosize problem, so, Autosize works in correct way. The behavior is produced when is calculated the position of string text that depends the size of string and the font type. I consider interesting create a property allows users control the margins of Marks and other TextShapes. I have added this idea as a feature request with number [TF02016687] to consider its inclusion to upcoming maintenance releases of TeeChartFor.Net.
On the other hand, to prevent o treat the problem appears in your mark shape, I give you some suggestions:

You can control the margin when you set AutoSize property to true, adding space before and after of the mark text. As is done in next simple code:

Code: Select all

 private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;
      Steema.TeeChart.Styles.Line line = new Steema.TeeChart.Styles.Line(tChart1.Chart);
      line.Marks.Visible = true;
     // line.Marks.TextAlign = StringAlignment.Center; 
      for (int i = 0; i < 10; i++)
      {
        line.Add(i * i);
      }
      tChart1.Draw();
      line.GetSeriesMark += line_GetSeriesMark;
      button1.Click += button1_Click;
      //tChart1.Axes.Left.MaxLabelsWidth(); 
    }
    void line_GetSeriesMark(Series series, GetSeriesMarkEventArgs e)
    {
      //Use AutoSize as true
      e.MarkText = "    Mark text string     \n value: " + e.ValueIndex;
     }
You can disable marks AutoSize property and after you can use custom size and calculate the size with MeasureString method of TeeChart Canvas as is done in next code:

Code: Select all

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;
      Steema.TeeChart.Styles.Line line = new Steema.TeeChart.Styles.Line(tChart1.Chart);
      line.Marks.Visible = true;
      for (int i = 0; i < 10; i++)
      {
        line.Add(i * i);
      }
      tChart1.Draw();
      //Disable AutoSize when use custom size
      line.Marks.AutoSize = false;
      line.GetSeriesMark += line_GetSeriesMark;
      button1.Click += button1_Click;
    }
    void line_GetSeriesMark(Series series, GetSeriesMarkEventArgs e)
    {
      //Use a custom size of marks.
      e.MarkText = "Mark text string \n value: " + e.ValueIndex;
      SizeF s = tChart1.Graphics3D.MeasureString(series.Marks.Font, e.MarkText);
      series.Marks.Width = ((int)s.Width) + 10;
      series.Marks.Height = ((int)s.Height) + 2; 
    }
Could you tell us if previous code works in your end?

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

OMP
Newbie
Newbie
Posts: 21
Joined: Mon Dec 10, 2012 12:00 am

Re: Series marks do not resize properly

Post by OMP » Thu Aug 22, 2013 3:48 pm

For our application it is not sufficient to use the workaround, so we will wait for the feature.

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

Re: Series marks do not resize properly

Post by Sandra » Fri Aug 23, 2013 8:20 am

Hello OMP,

Thanks for your information. On the other hand, If you think in my codes there are problems, would be very grateful if you tell us what doesn't like of the solutions

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