Page 1 of 1

Series marks do not resize properly

Posted: Tue Aug 13, 2013 7:37 am
by 15664347
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);
            }
        }

Re: Series marks do not resize properly

Posted: Tue Aug 13, 2013 11:51 am
by 10050769
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,

Re: Series marks do not resize properly

Posted: Thu Aug 22, 2013 3:48 pm
by 15664347
For our application it is not sufficient to use the workaround, so we will wait for the feature.

Re: Series marks do not resize properly

Posted: Fri Aug 23, 2013 8:20 am
by 10050769
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,