Wrong color in bar series

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
jjbonastre
Newbie
Newbie
Posts: 4
Joined: Mon Oct 14, 2013 12:00 am

Wrong color in bar series

Post by jjbonastre » Wed Oct 16, 2013 9:13 am

Hi!

I'm using Steema TeeChart for .NET 2013 4.1.2013.07300 for Windows phone 7, iOS and Android (with Xamarin)

I'm drawing a bar chart with the following code (Windows phone 7 version):

Code: Select all

            var tChart = new TChart();
            tChart.Legend.LegendStyle = LegendStyles.Series;
            tChart.Legend.Alignment = LegendAlignments.Bottom;
            tChart.Header.Visible = false;
            tChart.Aspect.GestureOptions = Steema.TeeChart.Silverlight.Drawing.Aspect.Gestures.None;
            tChart.Aspect.GestureStyle = Steema.TeeChart.Silverlight.Drawing.Aspect.GestureStyles.InChart;
            tChart.Aspect.RenderSeriesAsImage = true;

            tChart.Series.Clear();
            tChart.Aspect.View3D = true;
            tChart.Aspect.Orthogonal = true;
            tChart.Header.Visible = true;

            tChart.Header.Text = Strings.RealTimeStatisticsByResource;
            tChart.Header.HorizontalAlignment = HorizontalAlignment.Center;
            tChart.Header.Font.Size = 14;

            //Alarms
            String subheader = "";
            foreach (var resourceStatData in data)
            {
                if (resourceStatData.Alarms.Count > 0)
                {
                    if (!string.IsNullOrEmpty(subheader))
                    {
                        subheader += " | ";
                    }
                    subheader += resourceStatData.Name + " : ";
                    int index = 0;
                    foreach (var alarmInfo in resourceStatData.Alarms)
                    {
                        if (index == 0)
                        {
                            subheader += ",";
                        }
                        subheader += alarmInfo.Name;
                        index++;
                    }
                }
            }

            if (!string.IsNullOrEmpty(subheader))
            {
                tChart.SubHeader.Visible = true;
                tChart.SubHeader.Font.Size = 8;
                tChart.SubHeader.Font.Color = Colors.Red;
                tChart.SubHeader.HorizontalAlignment = HorizontalAlignment.Center;
                tChart.SubHeader.Text = subheader;
            }
            else
            {
                tChart.SubHeader.Visible = false;
            }

            var registered = new Bar { Title = Strings.Registered, Color = Colors.Gray};
            registered.GetSeriesMark += GetSeriesMark;
            registered.BarStyle = BarStyles.RectGradient;
            if (stacked)
            {
                registered.MultiBar = MultiBars.Stacked;
                registered.MarksOnBar = true;
            }
            var busy = new Bar { Title = Strings.Busy, Color = Colors.Blue };
            busy.GetSeriesMark += GetSeriesMark;
            if (stacked)
            {
                busy.MultiBar = MultiBars.Stacked;
                busy.MarksOnBar = true;
            }
            var pause = new Bar { Title = Strings.Paused, Color = Colors.Yellow };
            pause.GetSeriesMark += GetSeriesMark;
            if (stacked)
            {
                pause.MultiBar = MultiBars.Stacked;
                pause.MarksOnBar = true;
            }
            var free = new Bar { Title = Strings.Free, Color = Colors.Green };
            free.GetSeriesMark += GetSeriesMark;
            if (stacked)
            {
                free.MultiBar = MultiBars.Stacked;
                free.MarksOnBar = true;
            }
            var deferred = new Bar { Title = Strings.Deferred, Color = Colors.Brown };
            deferred.GetSeriesMark += GetSeriesMark;
            if (stacked)
            {
                deferred.MultiBar = MultiBars.Stacked;
                deferred.MarksOnBar = true;
            }
            var other = new Bar { Title = Strings.OtherSkill, Color = Colors.Red };
            other.GetSeriesMark += GetSeriesMark;
            if (stacked)
            {
                other.MultiBar = MultiBars.Stacked;
                other.MarksOnBar = true;
            }

            if (stacked)
            {
                registered.Active = false;
            }

            tChart.Series.Add(registered);
            tChart.Series.Add(busy);
            tChart.Series.Add(pause);
            tChart.Series.Add(free);
            tChart.Series.Add(deferred);
            tChart.Series.Add(other);

            foreach (var item in data)
            {
                string name;
                if (item.IsLogicalResource())
                {
                    name = String.Format("{0}\nT: {1} s Q: {2}", item.Name, item.QueueMaxTime, item.QueueTotal);
                }
                else
                {
                    name = item.Name;
                }

                registered.Add(item.RegisteredTotal, name);
                busy.Add(item.BusyTotal, name);
                deferred.Add(item.DeferredTotal, name);
                free.Add(item.FreeTotal, name);
                other.Add(item.OtherskillTotal, name);
                pause.Add(item.PauseTotal, name);
            }
This results in a chart with the "Registered" bar and legend color in a wrong yellow color instead of a gray color.
chart1.png
Chart view
chart1.png (80.69 KiB) Viewed 5248 times
In android version only the legend color is wrong.

Is this a known bug?

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

Re: Wrong color in bar series

Post by Narcís » Thu Oct 17, 2013 10:34 am

Hello,

I could reproduce the same issue in Android using this code:

Code: Select all

      var tChart = new TChart(this);
      tChart.Legend.Alignment = LegendAlignments.Bottom;

      Steema.TeeChart.Themes.BlackIsBackTheme myTheme = new Steema.TeeChart.Themes.BlackIsBackTheme(tChart.Chart);
      myTheme.Apply();

      var registered = new Bar { Title = "Registered", Color = Color.Gray };
      var stacked = false;

      registered.BarStyle = BarStyles.RectGradient;
      //registered.Gradient.StartColor = registered.Color;
      //registered.Gradient.EndColor = Color.White;
      if (stacked)
      {
        registered.MultiBar = MultiBars.Stacked;
        registered.MarksOnBar = true;
      }
      var busy = new Bar { Title = "Busy", Color = Color.Blue };
      if (stacked)
      {
        busy.MultiBar = MultiBars.Stacked;
        busy.MarksOnBar = true;
      }
      var pause = new Bar { Title = "Paused", Color = Color.Yellow };
      if (stacked)
      {
        pause.MultiBar = MultiBars.Stacked;
        pause.MarksOnBar = true;
      }
      var free = new Bar { Title = "Free", Color = Color.Green };
      if (stacked)
      {
        free.MultiBar = MultiBars.Stacked;
        free.MarksOnBar = true;
      }
      var deferred = new Bar { Title = "Deferred", Color = Color.Brown };
      if (stacked)
      {
        deferred.MultiBar = MultiBars.Stacked;
        deferred.MarksOnBar = true;
      }
      var other = new Bar { Title = "OtherSkill", Color = Color.Red };
      if (stacked)
      {
        other.MultiBar = MultiBars.Stacked;
        other.MarksOnBar = true;
      }

      if (stacked)
      {
        registered.Active = false;
      }

      tChart.Series.Add(registered);
      tChart.Series.Add(busy);
      tChart.Series.Add(pause);
      tChart.Series.Add(free);
      tChart.Series.Add(deferred);
      tChart.Series.Add(other);

      registered.FillSampleValues(2);
      busy.FillSampleValues(2);
      deferred.FillSampleValues(2);
      free.FillSampleValues(2);
      other.FillSampleValues(2);
      pause.FillSampleValues(2);

      SetContentView(tChart);
Which produces this chart:
AndroidRectGradient.jpg
AndroidRectGradient.jpg (190.87 KiB) Viewed 5225 times
In my opinion, this is not a bug. This is caused by setting BarStyle to BarStyles.RectGradient. The Gradient setting prevails over the Series.Color. So the solution is either removing BarStyles.RectGradient or setting different Gradient colors, for example (see commented out code in my example):

Code: Select all

      registered.Gradient.StartColor = registered.Color;
      registered.Gradient.EndColor = Color.White;
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

jjbonastre
Newbie
Newbie
Posts: 4
Joined: Mon Oct 14, 2013 12:00 am

Re: Wrong color in bar series

Post by jjbonastre » Thu Oct 17, 2013 11:58 am

You are right, using Gradient solves the problem.

Thanks!

Post Reply