Results 1 to 2 of 2

Thread: Plotting a 2D Array into a chart control as a polynomial, VB 2010

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2012
    Posts
    7

    Plotting a 2D Array into a chart control as a polynomial, VB 2010

    (VB 2010 Express)
    Hi all,

    So I have a 2D array of data, specifically, one "Cv" value for every 10% increment. I have been able to get the Cv's plotted vs % open with the following method:

    Code:
        Private Sub btnPlot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlot.Click
            Dim tempString As String
            Dim tempByte As Byte
            Dim i As Byte = 1
    
            tempString = listValveSuggestions.SelectedItem
            tempByte = CByte(tempString.Split(", ")(1))
            MsgBox(tempString & vbCrLf & tempByte, , "Plotting")
    
            Dim dTest As New DataTable
            dTest.Columns.Add("% Open", GetType(Byte))
            dTest.Columns.Add("Cv", GetType(Decimal))
    
            dTest.Rows.Add(0, 0)
            dTest.Rows.Add(10, CvArray(tempByte, 10))
            dTest.Rows.Add(20, CvArray(tempByte, 9))
            dTest.Rows.Add(30, CvArray(tempByte, 8))
            dTest.Rows.Add(40, CvArray(tempByte, 7))
            dTest.Rows.Add(50, CvArray(tempByte, 6))
            dTest.Rows.Add(60, CvArray(tempByte, 5))
            dTest.Rows.Add(70, CvArray(tempByte, 4))
            dTest.Rows.Add(80, CvArray(tempByte, 3))
            dTest.Rows.Add(90, CvArray(tempByte, 2))
            dTest.Rows.Add(100, CvArray(tempByte, 1))
    
    
            With CvVSPercentOpen.ChartAreas(0)
                .AxisX.Minimum = 0
                .AxisX.Maximum = 100
                .AxisY.Minimum = 0
                .AxisY.Maximum = CvArray(tempByte, 1)
                .AxisY.Interval = 10 ' for now
                .AxisX.Title = "% Open"
                .AxisY.Title = "Cv"
            End With
            With CvVSPercentOpen.Series(0)
                .Points.DataBind(dTest.DefaultView, "% Open", "Cv", Nothing)
                .ChartType = DataVisualization.Charting.SeriesChartType.Spline '<--- I'd like to change this, but there is no polynomial option
                .BorderWidth = 2
            End With
    End Sub
    Which produces the attached graph. I need this code to be able to produce a smooth curve of best fit like Excel would.

    Part 2
    I haven't yet looked into this, but if there's any way to also export this graph as an image into an excel spreadsheet, I would also appreciate code related to that. We will be creating several spec sheets as excel workbooks and we will need to be outputting standardized sheets, which is why I'm trying to make this an application instead of directly implementing the code in Excel with VBA.

    Any help with this issue would be appreciated.

    Thanks in advance.
    Attached Images Attached Images  

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Plotting a 2D Array into a chart control as a polynomial, VB 2010

    Moved To VB.NET

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width