Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3695

Creating linear chart from data from two Listboxes

$
0
0

Hello,

I have two single column list boxes. Each of them have 10 data points. The datawere created with calculations. Data in both listboxes are in string form.

ListBox1
ListBox2

I want the data in the first Listbox to be the ‘x’ value and data in the second listbox to be the ‘y’ value of a linear graph. I wanted the graph to be drawn when I press a button.

The method I coded was:

Var labels() As String
Var firstSetOfData() As Double

For i As Integer = 0 To ListBox1.LastRowIndex
Dim cellValue As String = ListBox1.Cell(i, 0)
labels.Add(cellValue)
Next

For i As Integer = 0 To ListBox2.LastRowIndex
Dim cellValue As string = ListBox2.Cell(i, 0)
If IsNumeric(cellValue) Then
Dim doubleValue As Double = Val(cellValue)
firstSetOfData.Add(doubleValue)
End If
Next

Chart1.mode = DesktopChart.Modes.Line
Chart1.Title = “Chart Example With Two Datasets”
Chart1.AddLabels labels

Var DS1 As New ChartLinearDataset(“DS1”, Color.Blue, True, firstSetOfData)
DS1.ChartType = ChartLinearDataset.ChartTypes.Line

Chart1.AddDatasets DS1

However, when I run I get the following error messages:

Window1.plotDraw line 8
“Type mismatch error. Expected String, but got Int32 Dim cellvalue As String=ListservBox1.Cells(i,0)”

Window1.plotDraw line 13
"Type mismatch error. Expected String, but got Int32 Dimcellvalue As String=ListservBox1.Cells(i,0)

Window1.plotDraw line 13
Type “DesktopListBox” has no member named “cell” Dimm cellValue As string = ListBox2.Cell(i,0)

Thank you in advance for any guidance!

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 3695

Trending Articles