Page 1 of 2

Marks on Stacked Bar Chart Do Not Show

Posted: Tue May 18, 2010 9:15 am
by 9092401
When using a Stack Bar Chart (MultiBar = Stacked) the marks of the bars do not show since those are being behind the next bar.
Thus seeing only the mark of the top most bar.
There is a solution to change the y-position of the mark (modify the arrow property), however I do not want to change the y-position, as the marks should be slightly above the bar they belong to.
Is there a way to make the marks visible in any other way?

see attached image:
Image

Thanks in advance
Elad

Re: Marks on Stacked Bar Chart Do Not Show

Posted: Tue May 18, 2010 9:54 am
by 10050769
Hello Elad,

Sorry, but for the moment it is not possible. I have added your suggestion as Feature request number [TF02014895] to the wish-list to be considered for inclusion in future releases.

Thanks,

Re: Marks on Stacked Bar Chart Do Not Show

Posted: Thu May 20, 2010 8:52 am
by 9092401
Hey Sandra
This request is not a suggestion, this is regression bug, and a critical bug on our side.
We've upgraded from the Delphi version where it used to work and in the .Net version it doesn't.
In addition in 3D charts the marks are visible as expected.

We would like your cooperation in supplying a workaround for this bug or a patch to fix this issue.

Thanks a lot
Elad

Re: Marks on Stacked Bar Chart Do Not Show

Posted: Thu May 20, 2010 9:29 am
by narcis
Hi Elad,
This request is not a suggestion, this is regression bug, and a critical bug on our side.
Actually, wish or bug/defect lists are internally the same list. What changes is the category of the issue but most important for us is the priority we give to each issue and this is quite an important one. Anyway, we changed issues category to "bug report" instead of "feature request".
We've upgraded from the Delphi version where it used to work and in the .Net version it doesn't.
Really? Which Delphi and TeeChart versions? Current TeeChart VCL versions also suffer from this problem in 2D charts. We have implemented Series.Marks.OnTop property for next TeeChart VCL releases to solve this.
In addition in 3D charts the marks are visible as expected.
Yes, we are aware of that. OnTop property will be only for 2D charts and false by default. Setting it to true will paint marks as you request.
We would like your cooperation in supplying a workaround for this bug or a patch to fix this issue.
A workaround would be replacing series marks with Annotation tools as shown here:

Code: Select all

		public Form1()
		{
			InitializeComponent();
      InitializeChart();
    }

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;

      for (int i = 0; i < 5; i++)
      {
        tChart1.Series.Add(new Steema.TeeChart.Styles.Bar());
        tChart1[i].FillSampleValues();
        ((Steema.TeeChart.Styles.Bar)tChart1[i]).MultiBar = Steema.TeeChart.Styles.MultiBars.Stacked;
      }

      tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);

      tChart1.Draw();
    }

    void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
      ReplaceMarks();
    }

    private void ReplaceMarks()
    {
      foreach (Steema.TeeChart.Styles.Series s in tChart1.Series)
      {
        for (int i = 0; i < s.Marks.Positions.Count; i++)
        {
          Steema.TeeChart.Tools.Annotation annotation1 = new Steema.TeeChart.Tools.Annotation(tChart1.Chart);
          Steema.TeeChart.Styles.SeriesMarks.Position pos = s.Marks.Positions[i];

          annotation1.Text = s.YValues[i].ToString();
          annotation1.Shape.CustomPosition = true;
          annotation1.Shape.Left = pos.LeftTop.X;
          annotation1.Shape.Top = pos.LeftTop.Y;
          annotation1.Shape.Width = pos.Width;
          annotation1.Shape.Height = pos.Height;
        }

        s.Marks.Visible = false;
      }
    }

Re: Marks on Stacked Bar Chart Do Not Show

Posted: Sun May 23, 2010 6:36 am
by 9092401
Thanks Narcís
I'll try your suggestion

Regards,
Elad

Re: Marks on Stacked Bar Chart Do Not Show

Posted: Tue May 25, 2010 9:48 am
by 9092401
Hey Narcís
I've tried working with your solution, I'm facing the following problems.
Whenever the chart size is changed the annotations position is given from the old marks positions (position prior to the resize).
I have tried adding code for the chart's BeforeDraw, BeforeDrawSeries or Resize events or GetSeriesMark (Bar's event).
But with no luck.

In addition it appears that GetSeriesMark is called after AfterDraw, which doesn't make sense, since in order to draw there's a need to know the marks position.

Any help would be appreciated,
Elad

Re: Marks on Stacked Bar Chart Do Not Show

Posted: Tue May 25, 2010 2:15 pm
by narcis
Hi Elad,

In that case you can do this:

Code: Select all

        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;

            for (int i = 0; i < 5; i++)
            {
                tChart1.Series.Add(new Steema.TeeChart.Styles.Bar());
                tChart1[i].FillSampleValues();
                ((Steema.TeeChart.Styles.Bar)tChart1[i]).MultiBar = Steema.TeeChart.Styles.MultiBars.Stacked;
            }

            tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
            tChart1.Resize += new EventHandler(tChart1_Resize);

            tChart1.Draw();
            tChart1.Dock = DockStyle.Fill;
        }

        void tChart1_Resize(object sender, EventArgs e)
        {
            RefreshMarksPosition();
        }

        private void RefreshMarksPosition()
        {
            foreach (Steema.TeeChart.Styles.Series s in tChart1.Series)
            {
                s.Marks.Visible = true;
            }

            tChart1.Draw();

            ReplaceMarks();
        }

        void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            ReplaceMarks();
        }

        private void ReplaceMarks()
        {
            tChart1.Tools.Clear();

            foreach (Steema.TeeChart.Styles.Series s in tChart1.Series)
            {
                for (int i = 0; i < s.Marks.Positions.Count; i++)
                {
                    Steema.TeeChart.Tools.Annotation annotation1 = new Steema.TeeChart.Tools.Annotation(tChart1.Chart);
                    Steema.TeeChart.Styles.SeriesMarks.Position pos = s.Marks.Positions[i];
                    
                    annotation1.Text = s.YValues[i].ToString();
                    annotation1.Shape.CustomPosition = true;
                    annotation1.Shape.Left = pos.LeftTop.X;
                    annotation1.Shape.Top = pos.LeftTop.Y;
                    annotation1.Shape.Width = pos.Width;
                    annotation1.Shape.Height = pos.Height;
                }

                s.Marks.Visible = false;
            }
        }
In addition it appears that GetSeriesMark is called after AfterDraw, which doesn't make sense, since in order to draw there's a need to know the marks position.
This event was designed to customize marks text, not its position.

Re: Marks on Stacked Bar Chart Do Not Show

Posted: Mon May 31, 2010 6:12 am
by 9092401
Hey Narcís
I've been working for the past few days on implementing this fix, and everything works fine except on some occasions when zooming in the chart.
using m_chart.Page.MaxPointsPerPage, where not all the marks should be visible.
calling the RefreshMarksPosition() does update the annotations positions as needed, except for the ones that should be off screen (or invisible)
I believe this is since the marks that shouldn't be visible do not get updated.
Is there a way to know which marks should be visible and which shouldn't?
s.Marks.Visible gives the visibility of all the marks in the current series.

Thanks
Elad

Re: Marks on Stacked Bar Chart Do Not Show

Posted: Tue Jun 01, 2010 1:24 pm
by narcis
Hi Elad,

To support Zoom and Scroll you need to use corresponding events and only paint marks for visible points as in this example:

Code: Select all

        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }

        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;

            for (int i = 0; i < 5; i++)
            {
                tChart1.Series.Add(new Steema.TeeChart.Styles.Bar());
                tChart1[i].FillSampleValues();
                ((Steema.TeeChart.Styles.Bar)tChart1[i]).MultiBar = Steema.TeeChart.Styles.MultiBars.Stacked;
            }

            tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
            tChart1.Resize += new EventHandler(tChart1_Resize);
            tChart1.Zoomed += new EventHandler(tChart1_Zoomed);
            tChart1.UndoneZoom += new EventHandler(tChart1_UndoneZoom);
            tChart1.Scroll += new EventHandler(tChart1_Scroll);

            tChart1.Draw();
            tChart1.Dock = DockStyle.Fill;
        }

        void tChart1_Scroll(object sender, EventArgs e)
        {
            RefreshMarksPosition();
        }

        void tChart1_UndoneZoom(object sender, EventArgs e)
        {
            RefreshMarksPosition();
        }

        void tChart1_Zoomed(object sender, EventArgs e)
        {
            RefreshMarksPosition();
        }

        void tChart1_Resize(object sender, EventArgs e)
        {
            RefreshMarksPosition();
        }

        private void RefreshMarksPosition()
        {
            foreach (Steema.TeeChart.Styles.Series s in tChart1.Series)
            {
                s.Marks.Visible = true;
            }

            tChart1.Draw();

            ReplaceMarks();
        }

        void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            ReplaceMarks();
        }

        private void ReplaceMarks()
        {
            tChart1.Tools.Clear();

            foreach (Steema.TeeChart.Styles.Series s in tChart1.Series)
            {
                //for (int i = 0; i < s.Marks.Positions.Count; i++)
                for (int i = s.FirstVisibleIndex; i <= s.LastVisibleIndex; i++)
                {
                    Steema.TeeChart.Tools.Annotation annotation1 = new Steema.TeeChart.Tools.Annotation(tChart1.Chart);
                    Steema.TeeChart.Styles.SeriesMarks.Position pos = s.Marks.Positions[i];

                    annotation1.Text = s.YValues[i].ToString();
                    annotation1.Shape.CustomPosition = true;
                    annotation1.Shape.Left = pos.LeftTop.X;
                    annotation1.Shape.Top = pos.LeftTop.Y;
                    annotation1.Shape.Width = pos.Width;
                    annotation1.Shape.Height = pos.Height;
                }

                s.Marks.Visible = false;
            }
        }

Re: Marks on Stacked Bar Chart Do Not Show

Posted: Tue Jun 01, 2010 3:03 pm
by 9092401
Thanks Narcis,
That's works fine except when there's only one column being shown.
In that case the first and last cover all the marks

Is this a known issue?

Thanks
Elad

Re: Marks on Stacked Bar Chart Do Not Show

Posted: Wed Jun 02, 2010 9:02 am
by narcis
Hi Elad,

I'm not sure about what do you mean here. Could you please attach a screen-shot of what you get and let us know the exact TeeChart version you are using?

Thanks in advance.

Re: Marks on Stacked Bar Chart Do Not Show

Posted: Wed Jun 02, 2010 12:19 pm
by 9092401
Hey Narcís,
TeeChart version is 3.5.3425.20244

Here is the chart before the zoom:
Image

And the chart after multiple zooms:
Image

This problem occurs only when there's a single bar shown, could that be the issue?
Whenever there's only one bar then FirstVisibleIndex = 0 LastVisibleIndex = series.Marks.Positions.Count - 1.

Thanks
Elad

Re: Marks on Stacked Bar Chart Do Not Show

Posted: Wed Jun 02, 2010 1:40 pm
by narcis
Hi Elad,
TeeChart version is 3.5.3425.20244
Please notice there are newer TeeChart for .NET v3 versions available. Yours is from May 2009.
This problem occurs only when there's a single bar shown, could that be the issue?
Using latest v3 release I can only reproduce something similar when zooming over the top of top-most bar. Can you reproduce this using latest v3 release? Should I perform any specific action? Could you attach a simple example project we can run "as-is" to reproduce this behaviour here?
Whenever there's only one bar then FirstVisibleIndex = 0 LastVisibleIndex = series.Marks.Positions.Count - 1.
I'm not able to reproduce this using latest v3 and v2010 releases.

Re: Marks on Stacked Bar Chart Do Not Show

Posted: Wed Jun 02, 2010 6:28 pm
by 9092401
Hey Narcis,
Using the latest TeeChart.DLL solved the last issue.

Thanks a lot for all your help on this issue
Elad

Re: Marks on Stacked Bar Chart Do Not Show

Posted: Thu Jun 03, 2010 5:58 am
by narcis
Hello Elad,

You're very welcome. I'm glad to hear that.