Working with the Marks.Item list

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
qcrnd
Advanced
Posts: 214
Joined: Mon Sep 04, 2006 12:00 am

Working with the Marks.Item list

Post by qcrnd » Sun May 31, 2009 5:49 am

Hi
I have a bar chart and for each bar series I tried to work with the Marks.Item list , but I dont see the marks I defined in the item list.
How exactly am I supposed to work with this .
Thanks.

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

Post by Sandra » Mon Jun 01, 2009 8:47 am

Hello gcrnd,


Please, you could explain exactly that you want do with marks in your application, so we can suggest a solution for your problem.


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

qcrnd
Advanced
Posts: 214
Joined: Mon Sep 04, 2006 12:00 am

Post by qcrnd » Tue Jun 02, 2009 9:18 am

Hi
I have a stacked bar chart and I want a mark on top of each stacked bar with the total . Until now I have used the Mark of the top most series and it worked ok ( bar.Mark.Visible = true) however because of problem that you have with 0 values, I was suggested by Yeray to use a workaround which involved working with the Marks.Items of each series. but I cant seem to see the Marks that are in the Items list . I think I am not working properly with the Marks.Items list and want to know what I should do.

Thanks.

Yeray
Site Admin
Site Admin
Posts: 9544
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Tue Jun 02, 2009 9:46 am

Hi qcrnd,

I'm still able to understand you. Could you change the following code to reproduce the problem?

Code: Select all

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

            //create ans populate 4 bar series
            for (int i = 0; i < 4; i++)
            {
                new Bar(tChart1.Chart);
                tChart1.Series[i].FillSampleValues(5);
                ((Bar)tChart1.Series[i]).MultiBar = MultiBars.Stacked;
            }

            //set some of the series values as 0
            tChart1.Series[1].YValues[2] = 0;
            tChart1.Series[2].YValues[2] = 0;
            tChart1.Series[3].YValues[4] = 0;
            tChart1.Series[0].YValues[3] = 0;

            //process of setting the 0 values as null to aviod drawing them
            for (int i = 0; i < tChart1.Series.Count; i++)
            {
                for (int j = 0; j < tChart1.Series[i].Count; j++)
                {
                    if (tChart1.Series[i].YValues[j] == 0)
                    {
                        tChart1.Series[i].SetNull(j);
                    }
                }
            }

            //process for show only the last mark on each series
            for (int ValueIndex = 0; ValueIndex < tChart1.Series[0].Count; ValueIndex++)
            {
                int SeriesIndex = tChart1.Series.Count - 1;
                while ((SeriesIndex > 0) && (tChart1.Series[SeriesIndex].IsNull(ValueIndex)))
                {
                    SeriesIndex--;
                }
                for (int k = 0; k < tChart1.Series.Count; k++)
                {
                    tChart1.Series[k].Marks.Items[ValueIndex].Visible = k == SeriesIndex;
                }
            }
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

qcrnd
Advanced
Posts: 214
Joined: Mon Sep 04, 2006 12:00 am

Post by qcrnd » Wed Jun 03, 2009 1:33 pm

Hi Yeray
Thanks. The only problem is ... HOW can I set the marks Items text to something else.
tChart1.Series[k].Marks.Items[ValueIndex].Text = MyString doesnt have any effect.

Thanks.

Yeray
Site Admin
Site Admin
Posts: 9544
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Wed Jun 03, 2009 2:22 pm

Hi qcrnd,

Oh, now I think I understood you. Excuse me.
To change your series marks text you have two options:

- Set your desired text as your series points labels. You could do it when you add the points with the Add() method or you could loop your series and their values to change its labels:

Code: Select all

for (int i = 0; i < tChart1.Series.Count; i++)
{
    for (int j = 0; j < tChart1.Series[i].Count; j++)
   {
      tChart1.Series[i].Labels[j] = "your text";
   }
}
- Use OnGetMarkText: You could assign the same method to all the series OnGetMarkText events:

Code: Select all

for (int i = 0; i < tChart1.Series.Count; i++)
{
    tChart1.Series[i].GetSeriesMark += new Series.GetSeriesMarkEventHandler(Form1_GetSeriesMark);
}
And then use the event call to change the text to show as you wish:

Code: Select all

void Form1_GetSeriesMark(Series series, GetSeriesMarkEventArgs e)
{
    e.MarkText = "Label number " + (e.ValueIndex+1).ToString();
}
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

qcrnd
Advanced
Posts: 214
Joined: Mon Sep 04, 2006 12:00 am

Post by qcrnd » Thu Jun 04, 2009 8:22 am

I Yeray
Thanks. I tried the Labels , and it seems OK Except for one problem which I also saw before in other charts.
Sometimes the Marks , and the Labels on the x Axis get mixed up. for example a label on the x Axis can suddenly change after resize to the same string as the mark , and visa versa.

Is this a defect that you know about.?

Yeray
Site Admin
Site Admin
Posts: 9544
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Thu Jun 04, 2009 11:58 am

Hi qcrnd,

Could you explain us how could we reproduce it here or could you send us a simple example project we can run "as-is" to reproduce the problem here?
You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

qcrnd
Advanced
Posts: 214
Joined: Mon Sep 04, 2006 12:00 am

Post by qcrnd » Thu Jun 04, 2009 12:24 pm

Hi Yeray
Its not easy to reproduce, it only happens sometimes in our application but I cant send you something so big. I will maybe try later on to build something small and see if it happens.
Thanks.

Post Reply