Page 1 of 2
Gradient
Posted: Wed Jun 19, 2013 11:39 am
by 15664465
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
Re: Gradient
Posted: Thu Jun 20, 2013 7:44 am
by 10050769
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,
Re: Gradient
Posted: Thu Jun 20, 2013 10:03 am
by 15664465
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
Re: Gradient
Posted: Thu Jun 20, 2013 1:23 pm
by narcis
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;
}
Re: Gradient
Posted: Fri Jun 21, 2013 9:53 am
by 15664465
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);
Re: Gradient
Posted: Fri Jun 21, 2013 10:15 am
by narcis
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.
Re: Gradient
Posted: Fri Jun 21, 2013 11:43 am
by 15664465
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);
Re: Gradient
Posted: Fri Jun 21, 2013 11:51 am
by narcis
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.
Re: Gradient
Posted: Fri Jun 21, 2013 12:10 pm
by 15664465
I want a function that passing a chart with the series, it sets the gradient and other features of the chart
Re: Gradient
Posted: Fri Jun 21, 2013 12:43 pm
by narcis
Hi Fulcrum,
That's what my example
here does. What do you need that it doesn't accomplish?
Thanks in advance.
Re: Gradient
Posted: Tue Jun 25, 2013 7:55 am
by 15664465
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
Re: Gradient
Posted: Tue Jun 25, 2013 7:59 am
by narcis
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;
}
Re: Gradient
Posted: Tue Jun 25, 2013 10:08 am
by 15664465
Ok the code work but what i want is to change the gradient of the bar
Re: Gradient
Posted: Tue Jun 25, 2013 10:34 am
by narcis
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.
Re: Gradient
Posted: Tue Jun 25, 2013 11:04 am
by 15664465
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
?