Axis Legend

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Fulcrum
Newbie
Newbie
Posts: 35
Joined: Fri Dec 21, 2012 12:00 am

Axis Legend

Post by Fulcrum » Thu Jun 27, 2013 7:43 am

Hello,
I have a Bar Chart and i wanted to put in the Y axis the values with the € simbol.
Is this posible?

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

Re: Axis Legend

Post by Sandra » Thu Jun 27, 2013 2:04 pm

Hello Fulcrum,

I think you can use CustomLabels to add "€" in the Y axis, you can do something as next:

Code: Select all

  Steema.TeeChart.Styles.FastLine line1;
    private void InitializeChart()
    {
      //Chart
      tChart1.Aspect.View3D = false;
      //Series
      line1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
      Random rnd = new Random();
      for (int i = 0; i < 10; i++)
      {
        line1.Add(i, rnd.Next(10));
      }
      AddCustomLabels();     
    }
    private void AddCustomLabels()
    {
      tChart1.Axes.Left.Labels.Items.Clear();
      for (int i = 0; i < tChart1[0].Count; i++)
      {
        tChart1.Axes.Left.Labels.Items.Add(tChart1[0].YValues[i], (tChart1[0].YValues[i] + 1 + "€").ToString()); 
      }
    }
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

Fulcrum
Newbie
Newbie
Posts: 35
Joined: Fri Dec 21, 2012 12:00 am

Re: Axis Legend

Post by Fulcrum » Fri Jun 28, 2013 8:29 am

Thank for the code, it Works. But i want that the values of the axe that not always is the same as the bars to be with the €

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

Re: Axis Legend

Post by Sandra » Fri Jun 28, 2013 11:59 am

Hello Fulcrum,

I suggest you two different alternative to achieve as you want:

First, changing labels valueFormat property as do in next lines of code:

Code: Select all

   public Form1()
    {
      InitializeComponent();
      InitializeChart();
    }
    Steema.TeeChart.Styles.FastLine line1;
    private void InitializeChart()
    {
      //Chart
      tChart1.Aspect.View3D = false;
      //Series
      line1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
      Random rnd = new Random();
      for (int i = 0; i < 10; i  )
      {
        line1.Add(i, rnd.Next(10));
      }
      tChart1.Axes.Left.Labels.ValueFormat = "0.#€";
}
Second, using GetAxisLabels event where you can add "€" for each labels as do in next code:

Code: Select all

    public Form1()
    {
      InitializeComponent();
      InitializeChart();
    }
    Steema.TeeChart.Styles.FastLine line1;
    private void InitializeChart()
    {
      //Chart
      tChart1.Aspect.View3D = false;
      //Series
      line1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
      Random rnd = new Random();
      for (int i = 0; i < 10; i  )
      {
        line1.Add(i, rnd.Next(10));
      }
      tChart1.GetAxisLabel  = tChart1_GetAxisLabel;
   }

    void tChart1_GetAxisLabel(object sender, GetAxisLabelEventArgs e)
    {
      e.LabelText = e.LabelText "€"; 
    }
At any rate, we aren't sure as you want, therefore, we would be very grateful if my suggestion code, isn't as you want, explain exactly what are you want achieve. On the other hand, if is easier for you, explain your request in Spanish you can do it.

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

Fulcrum
Newbie
Newbie
Posts: 35
Joined: Fri Dec 21, 2012 12:00 am

Re: Axis Legend

Post by Fulcrum » Mon Jul 01, 2013 11:11 am

thanks Sandra, the 1st solution made what I want

Post Reply