change color of labels in circular gauge

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Cozmos
Newbie
Newbie
Posts: 7
Joined: Mon Nov 09, 2015 12:00 am

change color of labels in circular gauge

Post by Cozmos » Wed Sep 07, 2016 1:27 pm

Hi,

I'm creating a circular gauge in Xamarin forms, and I'm trying to change the label's color. I tried setting every property I could find, but it won't change... Can anyone help me?

this is my code: (just setting the property of the axis labels color here, because that's the one I think needs to be set... I also tried it with many other properties I found, but none are working).

Code: Select all

	Chart CreateView ()
		{
			var c = new Chart (this);
			c.Header.Visible = false;
			c.Panel.Visible = false;
			var gauge = new CustomChart (c.Chart);
			gauge.Frame.Visible = false;
			gauge.FaceBrush.Visible = false;
			gauge.DisplayTotalAngle = 180;
			gauge.TotalAngle = 180;
			gauge.Value = GetCurrentValue ();
			gauge.Ticks.Visible = false;
			gauge.Minimum = 0;
			gauge.Maximum = GetMonths ();
			gauge.Axis.Increment = GetMonths () / 4;
			gauge.RedLine.Visible = false;
			gauge.GreenLineStartValue = 0;
			gauge.GreenLineEndValue = GetMonths ();
			gauge.GreenLine.Gradient.Direction = Steema.TeeChart.Drawing.GradientDirection.LeftRight;
			gauge.GreenLine.Gradient.StartColor = Color.FromRgb (6, 64, 137);
			gauge.GreenLine.Gradient.EndColor = Color.FromHex ("#159DFB");
			gauge.GreenLine.Pen.Visible = true;
			gauge.Axis.Labels.Color = Color.Red;
			return c;
		}
In attachment the screenshot of my gauge, I want to change the color of the numbers on the axis

Thanks!
Screen Shot 2016-09-07 at 15.26.10.png
Screen Shot 2016-09-07 at 15.26.10.png (28.68 KiB) Viewed 18121 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: change color of labels in circular gauge

Post by Christopher » Wed Sep 07, 2016 3:37 pm

Hello,

Rather than Labels.Color, which is the color of the shape around the label (the shape is invisible by default), you should change the Label.Font characteristics, e.g.

Code: Select all

gauge.Axis.Labels.Font.Color = Color.Red;
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Cozmos
Newbie
Newbie
Posts: 7
Joined: Mon Nov 09, 2015 12:00 am

Re: change color of labels in circular gauge

Post by Cozmos » Thu Sep 08, 2016 9:50 am

I tried that too, and it isn't working either...

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: change color of labels in circular gauge

Post by Christopher » Thu Sep 08, 2016 10:36 am

Hello,

The following code works as expected with TeeChart.dll, the Windows Forms version:

Code: Select all

    private void InitializeChart()
    {
      Func<int> GetCurrentValue = () =>
      {
        return 40;
      };

      Func<int> GetMonths = () =>
      {
        return 80;
      };

      CircularGauge gauge = new CircularGauge(tChart1.Chart);
      gauge.Frame.Visible = false;
      gauge.FaceBrush.Visible = false;
      gauge.DisplayTotalAngle = 180;
      gauge.TotalAngle = 180;
      gauge.Value = GetCurrentValue();
      gauge.Ticks.Visible = false;
      gauge.Minimum = 0;
      gauge.Maximum = GetMonths();
      gauge.Axis.Increment = GetMonths() / 4;
      gauge.RedLine.Visible = false;
      gauge.GreenLineStartValue = 0;
      gauge.GreenLineEndValue = GetMonths();
      gauge.GreenLine.Gradient.Direction = LinearGradientMode.ForwardDiagonal;
      gauge.GreenLine.Gradient.StartColor = Color.FromArgb(255, 6, 64, 137);
      gauge.GreenLine.Gradient.EndColor = Utils.HexToColor("FF159DFB");
      gauge.GreenLine.Pen.Visible = true;
      gauge.Axis.Labels.Font.Color = Color.Red;
    }
gives me this:
636089349153306325.jpg
636089349153306325.jpg (33.34 KiB) Viewed 18105 times
Which version of TeeChart are you using?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Cozmos
Newbie
Newbie
Posts: 7
Joined: Mon Nov 09, 2015 12:00 am

Re: change color of labels in circular gauge

Post by Cozmos » Thu Sep 08, 2016 10:50 am

I'm using the Xamarin Forms version: TeeChartXamarinFormsSource-4.0.2016.05310-osx (the newest release)

I tried it with your code, but still no success.

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Re: change color of labels in circular gauge

Post by Pep » Thu Sep 08, 2016 4:26 pm

Hello,

it's strange, I've just tested it here with the same version and it's working fine using :

Code: Select all

gauge.Axis.Labels.Font.Color = Color.Blue;
or with another color.
Does this happens on both iOS and Android ?

Post Reply