Drawing XY Scatter Graph With OWC11

D

Darryn Lavery

Reposting from
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=140001&SiteID=1

Hi everyone,

i need to draw a graph from the "chChartTypeScatterSmoothLine" type. I use
Visual Basic .Net to do so. On my form there is a Button and a Chart. I want
the chart to be drawn when I click on the button. I tried the following
approach, a graph is plotted, but the data I provided as source isn't
respected... Please help me out...

Thank in advance

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'Create arrays for the x-values and the y-values
Dim i As Integer
Dim XValue() As Integer = {1, 2, 3, 4, 5, 6, 7}
Dim YValue() As Integer = {2, 4, 6, 8, 6, 4, 2}

'Create a new chart
Dim oChart As OWC11.ChChart
MyChart.Clear()
MyChart.Refresh()
oChart = MyChart.Charts.Add

'Add a title to the chart
oChart.HasTitle = True
oChart.Title.Caption = "(T,S)-Graph"
oChart.Type = OWC11.ChartChartTypeEnum.chChartTypeScatterSmoothLine

'Add a series to the chart with the x-values and y-values
'from the arrays and set the series type to a column chart
Dim oSeries As OWC11.ChSeries
oSeries = oChart.SeriesCollection.Add
oSeries.SetData(OWC11.ChartDimensionsEnum.chDimXValues,
OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, XValue)
oSeries.SetData(OWC11.ChartDimensionsEnum.chDimYValues,
OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, YValue)

Dim oAxis As OWC11.ChAxis
'Horizontal Axis
oAxis = oChart.Axes(OWC11.ChartAxisPositionEnum.chAxisPositionBottom)
oAxis.Scaling.Orientation =
OWC11.ChartScaleOrientationEnum.chScaleOrientationMinMax
oAxis.HasTitle = True
oAxis.Title.Caption = "T"

'Vertical Axis
oAxis = oChart.Axes(OWC11.ChartAxisPositionEnum.chAxisPositionLeft)
oAxis.HasTitle = True
oAxis.Title.Caption = "S"

MyChart.Refresh()
End Sub
 
A

Alvin Bruney - ASP.NET MVP

search this newsgroup, there are a lots of examples posted in here about
drawing charts

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top