TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
-
Sandra
- Site Admin
- Posts: 3132
- Joined: Fri Nov 07, 2008 12:00 am
Post
by Sandra » Tue Jun 25, 2013 2:39 pm
Hello Fulcrum,
I have attached the code that Narcís suggested you, in VB:
Code: Select all
Public Sub New()
' This call is required by the designer.
InitializeComponent()
InitializeChart()
' Add any initialization after the InitializeComponent() call.
End Sub
Private Sub InitializeChart()
For i As Integer = 0 To 2
Dim ch1 As New Steema.TeeChart.TChart()
ch1.Name = "ch" & (i + 1).ToString()
ch1.Series.Add(New Bar()).FillSampleValues()
Me.Controls.Add(ch1)
SetChart(ch1)
ch1.Top = ch1.Height * i
Next
End Sub
Private Sub SetChart(chart As Steema.TeeChart.TChart)
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.Panel.Gradient.EndColor = Color.White
chart.Walls.Back.Gradient.EndColor = chart.Panel.Gradient.EndColor
Dim bar As New Steema.TeeChart.Styles.Bar()
bar = DirectCast(chart(0), Steema.TeeChart.Styles.Bar)
bar.BarStyle = Steema.TeeChart.Styles.BarStyles.RectGradient
bar.Gradient.Visible = True
bar.Gradient.StartColor = Color.Red
bar.Gradient.MiddleColor = Color.Blue
bar.Gradient.EndColor = Color.Yellow
End Sub
Please check previous code if works in your end.
Thanks,
-
Fulcrum
- Newbie
- Posts: 35
- Joined: Fri Dec 21, 2012 12:00 am
Post
by Fulcrum » Wed Jun 26, 2013 8:36 am
Code: Select all
Dim bar As Steema.TeeChart.Styles.Bar = DirectCast(Chart(0), Steema.TeeChart.Styles.Bar)
says that chart isnt declared
-
Sandra
- Site Admin
- Posts: 3132
- Joined: Fri Nov 07, 2008 12:00 am
Post
by Sandra » Wed Jun 26, 2013 11:21 am
Hello Fulcrum,
If it says is null is because you doesn't have any series before to call SetChart(TChart chart) method. If you want your code works correctly you must do as next:
Check if SetChart is called after created series, you should have a similar code as next:
Code: Select all
Private Sub InitializeChart()
For i As Integer = 0 To 2
Dim ch1 As New Steema.TeeChart.TChart()
ch1.Name = "ch" & (i 1).ToString()
ch1.Series.Add(New Bar()).FillSampleValues()
Me.Controls.Add(ch1)
SetChart(ch1)<--//After add series
ch1.Top = ch1.Height * i
Next
End Sub
After SetChart method should work without problems:
Code: Select all
Private Sub SetChart(chart As Steema.TeeChart.TChart)
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.Panel.Gradient.EndColor = Color.White
chart.Walls.Back.Gradient.EndColor = chart.Panel.Gradient.EndColor
Dim bar As Steema.TeeChart.Styles.Bar = DirectCast(chart(0), Steema.TeeChart.Styles.Bar)
bar.BarStyle = Steema.TeeChart.Styles.BarStyles.RectGradient
bar.Gradient.Visible = True
bar.Gradient.StartColor = Color.Red
bar.Gradient.MiddleColor = Color.Blue
bar.Gradient.EndColor = Color.Yellow
End Sub
Thanks,
-
Fulcrum
- Newbie
- Posts: 35
- Joined: Fri Dec 21, 2012 12:00 am
Post
by Fulcrum » Wed Jun 26, 2013 12:04 pm
Ok, it Works now.
Thanks for the help.