Gradient

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

Gradient

Post by Fulcrum » Wed Jun 19, 2013 11:39 am

Hello, I have defined a serie and put it in a variable series

Code: Select all

Dim barserieHormigonYAcero As New Steema.TeeChart.Styles.Bar()
and then add it to a chart

Code: Select all

chGraficoObrasFabrica.Series.Add(barserieHormigonYAcero)
what I want its a function that when you pass a chart chGraficoObrasFabrica it put the gradient to the chart
independently of the serie

Thanks

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

Re: Gradient

Post by Sandra » Thu Jun 20, 2013 7:44 am

Hello Fulcrum,

If you want change the gradient of chart you need do next:

Code: Select all

private void InitializeChart()
        {
          tChart1.Aspect.View3D = false;
          Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
          bar1.FillSampleValues();
          tChart1.Panel.Gradient.StartColor = Color.Black;
          tChart1.Panel.Gradient.EndColor = Color.White;
          tChart1.Walls.Back.Gradient.StartColor = tChart1.Panel.Gradient.StartColor;
          tChart1.Walls.Back.Gradient.EndColor = tChart1.Panel.Gradient.EndColor = Color.White;
         }
Could you tell us if previous code works in your end?

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: Gradient

Post by Fulcrum » Thu Jun 20, 2013 10:03 am

The code work but what i have are 3 chart( ch1,ch2,ch3) with his series inside and i want a
function that calling it and passing a chart it adds the gradient to that chart

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

Re: Gradient

Post by Narcís » Thu Jun 20, 2013 1:23 pm

Hi Fulcrum,

If I understood your question correctly, you only need to create a method to set the chart properties you like. To do so, this method will need either a TChart or Chart argument, for example:

Code: Select all

    public Form1()
    {
      InitializeComponent();
      InitializeChart();
    }
    
    private void InitializeChart()
    {
      for (int i = 0; i < 3; i++)
      {
        TChart ch1 = new TChart();
        ch1.Name = "ch" + (i + 1).ToString();
        SetChart(ch1);
        ch1.Top = ch1.Height * i;

        this.Controls.Add(ch1);      
      }

    }

    private void SetChart(TChart chart)
    {
      chart.Aspect.View3D = false;

      chart.Series.Add(new Bar()).FillSampleValues();
      chart.Panel.Gradient.StartColor = Color.Black;
      chart.Panel.Gradient.EndColor = Color.White;
      chart.Walls.Back.Gradient.StartColor = chart.Panel.Gradient.StartColor;
      chart.Walls.Back.Gradient.EndColor = chart.Panel.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

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

Re: Gradient

Post by Fulcrum » Fri Jun 21, 2013 9:53 am

what i want is a function that puts the format to the chart:

Code: Select all

Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
Steema.TeeChart.Styles.Bar bar2 = new Steema.TeeChart.Styles.Bar(tChart2.Chart);
Steema.TeeChart.Styles.Bar bar3 = new Steema.TeeChart.Styles.Bar(tChart3.Chart);
bar1.FillSampleValues();
bar2.FillSampleValues();
bar3.FillSampleValues();
SetChart(bar1);
SetChart(bar2);
SetChart(bar3);

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

Re: Gradient

Post by Narcís » Fri Jun 21, 2013 10:15 am

Hi Fulcrum,

Ok, change the method to use an argument of Steema.TeeChart.Styles.Bar type and change the argument variable format you like in the method.
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

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

Re: Gradient

Post by Fulcrum » Fri Jun 21, 2013 11:43 am

Sorry, the real code is

Code: Select all

Steema.TeeChart.Chart Chart1;
Steema.TeeChart.Chart Chart2;
Steema.TeeChart.Chart Chart3;
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
Steema.TeeChart.Styles.Bar bar2 = new Steema.TeeChart.Styles.Bar(tChart2.Chart);
Steema.TeeChart.Styles.Bar bar3 = new Steema.TeeChart.Styles.Bar(tChart3.Chart);
bar1.FillSampleValues();
bar2.FillSampleValues();
bar3.FillSampleValues();
Chart1.Series.Add(bar1);
Chart2.Series.Add(bar2);
Chart3.Series.Add(bar3);
SetChart(Chart1);
SetChart(Chart2);
SetChart(Chart3);

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

Re: Gradient

Post by Narcís » Fri Jun 21, 2013 11:51 am

Hi Fulcrum,

Sorry but I'm not sure about what would you like to achieve. Could you please provide more detailed information?

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

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

Re: Gradient

Post by Fulcrum » Fri Jun 21, 2013 12:10 pm

I want a function that passing a chart with the series, it sets the gradient and other features of the chart

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

Re: Gradient

Post by Narcís » Fri Jun 21, 2013 12:43 pm

Hi Fulcrum,

That's what my example here does. What do you need that it doesn't accomplish?

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

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

Re: Gradient

Post by Fulcrum » Tue Jun 25, 2013 7:55 am

In your example tou have the chart and you add the series in the function,
I want to have the series in the chart before you call the function

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

Re: Gradient

Post by Narcís » Tue Jun 25, 2013 7:59 am

Hello Fulcrum,

This is very simple, you just need to move the line creation series to the section of the code where you create the chart:

Code: Select all

    public Form1()
    {
      InitializeComponent();
      InitializeChart();
    }
    
    private void InitializeChart()
    {
      for (int i = 0; i < 3; i++)
      {
        TChart ch1 = new TChart();
        ch1.Name = "ch" + (i + 1).ToString();
        SetChart(ch1);
        ch1.Top = ch1.Height * i;

        ch1.Series.Add(new Bar()).FillSampleValues();

        this.Controls.Add(ch1);
      }
    }

    private void SetChart(TChart chart)
    {
      chart.Aspect.View3D = false;

      chart.Panel.Gradient.StartColor = Color.Black;
      chart.Panel.Gradient.EndColor = Color.White;
      chart.Walls.Back.Gradient.StartColor = chart.Panel.Gradient.StartColor;
      chart.Walls.Back.Gradient.EndColor = chart.Panel.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

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

Re: Gradient

Post by Fulcrum » Tue Jun 25, 2013 10:08 am

Ok the code work but what i want is to change the gradient of the bar

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

Re: Gradient

Post by Narcís » Tue Jun 25, 2013 10:34 am

Hi Fulcrum,

Ok, that's not what you said at the beginning. Anyway, you can do this:

Code: Select all

    public Form1()
    {
      InitializeComponent();
      InitializeChart();
    }
    
    private void InitializeChart()
    {
      for (int i = 0; i < 3; i++)
      {
        TChart ch1 = new TChart();
        ch1.Name = "ch" + (i + 1).ToString();
        ch1.Top = ch1.Height * i;

        ch1.Series.Add(new Bar()).FillSampleValues();

        SetChart(ch1);

        this.Controls.Add(ch1);
      }
    }

    private void SetChart(TChart chart)
    {
      chart.Aspect.View3D = false;

      chart.Panel.Gradient.StartColor = Color.Black;
      chart.Panel.Gradient.EndColor = Color.White;
      chart.Walls.Back.Gradient.StartColor = chart.Panel.Gradient.StartColor;
      chart.Walls.Back.Gradient.EndColor = chart.Panel.Gradient.EndColor = Color.White;

      Bar bar = (Bar)chart[0];
      bar.BarStyle = BarStyles.RectGradient;
      bar.Gradient.StartColor = Color.Red;
      bar.Gradient.MiddleColor = Color.Blue;
      bar.Gradient.EndColor = Color.Yellow;
    }
Looks like colors in gradient can not be changed now. It's a bug which I have added to the defect list (TF02016618) to be fixed for future releases.
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

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

Re: Gradient

Post by Fulcrum » Tue Jun 25, 2013 11:04 am

Maybe i didnt explain correctly.
The traslation to vb.net of this part of your code will be:

Code: Select all

Dim bar As Steema.TeeChart.Styles.Bar = DirectCast(Steema.TeeChart.Chart(0), Steema.TeeChart.Styles.Bar)
bar.BarStyle = Steema.TeeChart.Styles.BarStyles.RectGradient
bar.Gradient.StartColor = Color.Red
bar.Gradient.MiddleColor = Color.Blue
bar.Gradient.EndColor = Color.Yellow
?

Post Reply