Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27350

VS 2008 Charts and properties.

$
0
0
I have four fields in my db. I'm filing a dataset and then plotting the data on a graph. I have this code...

Code:

    Dim sqlProducts As String = "SELECT * FROM myTable"

        Dim da As System.Data.OleDb.OleDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter(sqlProducts, con)
        Dim ds As New DataSet()
        da.Fill(ds, "Products")

        Dim ChartArea1 As ChartArea = New ChartArea()
        Dim Legend1 As Legend = New Legend()
        Dim Series1 As Series = New Series()
        Dim series2 As Series = New Series()
        Dim series3 As Series = New Series()
        Dim series4 As Series = New Series()
        Dim Chart1 = New Chart()
        Me.Controls.Add(Chart1)


        ChartArea1.Name = "ChartArea1"
        Chart1.ChartAreas.Add(ChartArea1)
        Legend1.Name = "Legend1"
        Chart1.Legends.Add(Legend1)
        Chart1.Location = New System.Drawing.Point(150, 20)
        Chart1.Name = "Chart1"
        Series1.ChartArea = "ChartArea1"
        Series1.Legend = "Legend1"
        Series1.Name = "Series1"
        series2.Name = "Series2"
        series3.Name = "Series3"
        series4.Name = "Result"
        series2.ChartArea = "ChartArea1"

        Chart1.Series.Add(Series1)
        Chart1.Series.Add(series2)
        Chart1.Series.Add(series3)
        Chart1.Series.Add(series4)
        Chart1.Size = New System.Drawing.Size(600, 480)
        Chart1.TabIndex = 0
        Chart1.Text = "Chart1"
        Series1.ChartType = SeriesChartType.Fastline
        series2.ChartType = SeriesChartType.Fastline
        series3.ChartType = SeriesChartType.FastLine
        series4.ChartType = SeriesChartType.FastLine

        Chart1.Series("Series1").XValueMember = "ID"
        Chart1.Series("Series1").YValueMembers = "Upper"
        Chart1.Series("Series2").YValueMembers = "Lower"
        Chart1.Series("Series3").YValueMembers = "mean"
        Chart1.Series("Result").YValueMembers = "result"

        Chart1.DataSource = ds.Tables("Products")

It works well but I need to do a bit more. Upper and lower (fields in db) need to be error bars. (The T for upper and inverted T for lower) and I would like the lines to be thicker and to be able to change line/plot colours. As this chart isn't physically added to the form, I'm finding it difficult to work out the properties for lines and even whether I can or not change the upper and lower to an 'error bar'. I know it can't be an error bar chart but is there any way to change it? or is there a better chart for plotting four values?

Cheers.

Viewing all articles
Browse latest Browse all 27350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>