Different colours for each of the labels/marks of a series

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Reg Bust
Newbie
Newbie
Posts: 3
Joined: Fri Oct 21, 2005 4:00 am

Different colours for each of the labels/marks of a series

Post by Reg Bust » Mon Mar 13, 2006 12:51 pm

Hi

I have a point series to which I add points.

I want to be able to set the colour for the label/mark/text for each of the points in the series.

That is, I want to be able to say that the label/name for this point is Green, that this point is Blue, etc.

I know that by setting

.ColorEach = True
and by specifying using the Series.Add that allows a color as in
.Series(1).Add(2,3, "Label",Color.Blue)

that I can set the color for the markers (little colored icons) for each point.

But I want to be able to colour the Text/Label/Mark that appears next to each point.

Please help.

Regards
Reg Bust

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 14, 2006 1:30 pm

Hi Reg Bust,

Yes, you can do something like this:

Code: Select all

    private void Form1_Load(object sender, EventArgs e)
    {
      line1.FillSampleValues();

      for (int i = 0; i < line1.Count; ++i)
      {
        if (line1.YValues[i] % 2 == 0)
        {
          line1.Marks.Items[i].Font.Color = Color.Blue;
          line1.Marks.Items[i].Color = Color.White;
        }
        else
        {
          line1.Marks.Items[i].Font.Color = Color.Red;
          line1.Marks.Items[i].Font.Bold = true;
          line1.Marks.Items[i].Font.Size = 10;
          line1.Marks.Items[i].Color = Color.Yellow;
        }
      }
    }
Or you can implement that code in the series GetSeriesMark event:

Code: Select all

    private void line1_GetSeriesMark(Steema.TeeChart.Styles.Series series, Steema.TeeChart.Styles.GetSeriesMarkEventArgs e)
    {
      if (line1.YValues[e.ValueIndex] % 2 == 0)
      {
        line1.Marks.Items[e.ValueIndex].Font.Color = Color.Blue;
        line1.Marks.Items[e.ValueIndex].Color = Color.White;
      }
      else
      {
        line1.Marks.Items[e.ValueIndex].Font.Color = Color.Red;
        line1.Marks.Items[e.ValueIndex].Font.Bold = true;
        line1.Marks.Items[e.ValueIndex].Font.Size = 10;
        line1.Marks.Items[e.ValueIndex].Color = Color.Yellow;
      }
    }
Best Regards,
Narcís Calvet / 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

Reg Bust
Newbie
Newbie
Posts: 3
Joined: Fri Oct 21, 2005 4:00 am

Setting the colour of Marks.Items

Post by Reg Bust » Wed Mar 15, 2006 2:24 pm

Hi Narcis

Thank you for this.

I implemented your first approach and set

line1.Marks.Items(i).Font.Color = myColor

After I had added the point.

It works, but ....

Just that single change in the code causes other changes to my chart.

Now each of the text labels for my points have little boxes around them, with black labels, and these boxes are not transparent so that one blocks the view of the other.

(I wish I could include exported pictures of the chart before and after.)

I tried evey option I could in the TeeChart Editor (called from within my application) to get rid of these boxes but they remain stubbornly there.

Note that in my application I start by loading a "template" (just a tee chart which has the series, colours, etc. previously saved). My application then just adds points to my pre-defined series. I suspect that my template that I start with is responsible for this.

How can I send it (the template) to you? (I can't send attachments in this forum).

Regards
Reg Bust

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Mar 15, 2006 2:38 pm

Hi Reg Bust,

Could you please post your files at news://www.steema.net/steema.public.attachments newsgroup?

Thanks in advance.
Best Regards,
Narcís Calvet / 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

Reg Bust
Newbie
Newbie
Posts: 3
Joined: Fri Oct 21, 2005 4:00 am

Charts sent via newsgroup

Post by Reg Bust » Wed Mar 15, 2006 3:07 pm

Hi

I've sent the attachments via the newsgroup.

Thank you.

Regards
Reg Bust

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Mar 15, 2006 3:31 pm

Hi Reg Bust,

Thanks for the files.

Then you can make the marks transparent:

Code: Select all

    private void Form1_Load(object sender, EventArgs e)
    {
      line1.FillSampleValues();

      for (int i = 0; i < line1.Count; ++i)
      {
        if (line1.YValues[i] % 2 == 0)
        {
          line1.Marks.Items[i].Font.Color = Color.Blue;
          line1.Marks.Items[i].Color = Color.White;
        }
        else
        {
          line1.Marks.Items[i].Font.Color = Color.Red;
          line1.Marks.Items[i].Font.Bold = true;
          line1.Marks.Items[i].Font.Size = 10;
          line1.Marks.Items[i].Color = Color.Yellow;
        }

        line1.Marks.Items[i].Transparent = true;
      }
    }
Best Regards,
Narcís Calvet / 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

I-Maps
Newbie
Newbie
Posts: 15
Joined: Fri Oct 21, 2005 4:00 am
Location: South Africa

Border around chart and clipping

Post by I-Maps » Thu Mar 16, 2006 7:02 am

Hi

I have sent a chart (in .ten and .png format) via the newsgroup (the .NET v2 newsgroup).

Please tell me how to:

1. Remove the space at the left, right and bottom of the chart. (The space that is not part of the grid.)

2. Currently some of my labels (e.g. "Zaptronix" on the extreme left) extend into that space. I still want those to be visible. If necessary I can do this with code as I manually set the axis min and max.

3. Extend the minor tick marks on both axes so that they are on both sides of the axis (as the major tick marks are).

4. Get rid of the outermost blue border especially the rounded corners.


In all instances I really want to be able to do this via the TeeCharts Editor and not via code (if possible).

Thank you.

Kind regards
Reg Bust

I-Maps
Newbie
Newbie
Posts: 15
Joined: Fri Oct 21, 2005 4:00 am
Location: South Africa

Thank you

Post by I-Maps » Thu Mar 16, 2006 7:06 am

Thank you for the help with setting the colours and making the marks transparent.

All working now.

I have sent another request in a different topic.

Regards
Reg Bust

Post Reply