Jump to content
Software FX Community

Populating Chart with Two Seperate Queries


DangerRuss

Recommended Posts

I am trying to get the Chart to read in two seperate SQL queries from Access and put them onto the same chart for comparison.  I intend to in the future increase this to maybe 4-6 seperate queries.  Each Query should be only one line on the chart and occupy the same X-axis-points as the others. Right now it displays two seperate lines but the lines are on different X-axis.  You can see where the first series ends and the second one starts. :)  It looks funny but I do need to figure out how to make it look professional.

Sub ChartThis(ByVal Ind As Short, ByVal State As Short, ByVal charty As SoftwareFX.ChartFX.Lite.Chart)Dim BooCharted As Boolean = FalseDim myConnectionString As StringDim ds As New DataSet()Dim myConnection As New System.Data.OleDb.OleDbConnection()ds = New DataSet("EditedValue")

Dim adapter As New System.Data.OleDb.OleDbDataAdapter()

If BooGSP = True Then

'Specifics of the query performed

myConnectionString =

"Provider=Microsoft.Jet.OLEDB.4.0; Data Source= " & PathtoAdvanceDB & ";"

Dim mySelectQuery As String = "SELECT EditedValue FROM([" & GSPTable & "]) " & _"WHERE ((([" & GSPTable & "].Component_ID)=1) AND (([" & GSPTable & "].Industry_ID)=" & Ind & ") AND (([" & GSPTable & "].State_ID)=" & State & ") AND (([" & GSPTable & "].GenerationYear)=" & GenYr & "))"myConnection.ConnectionString = myConnectionStringmyConnection.Open()adapter.SelectCommand = New System.Data.OleDb.OleDbCommand(mySelectQuery, myConnection)

 

charty.DataType(0) = DataType.Value

adapter.Fill(ds)

BooCharted =

True

myConnection.Close()

End If

If BooRealGSP = True Then

'Specifics of the query performed

myConnectionString =

"Provider=Microsoft.Jet.OLEDB.4.0; Data Source= " & PathtoAdvanceDB & ";"

Dim mySelectQuery As String = "SELECT EditedValue AS Edited1 FROM([" & GSPTable & "]) " & _"WHERE ((([" & GSPTable & "].Component_ID)=9) AND (([" & GSPTable & "].Industry_ID)=" & Ind & ") AND (([" & GSPTable & "].State_ID)=" & State & ") AND (([" & GSPTable & "].GenerationYear)=" & GenYr & "))"myConnection.ConnectionString = myConnectionStringmyConnection.Open()adapter.SelectCommand = New System.Data.OleDb.OleDbCommand(mySelectQuery, myConnection)

charty.DataType(1) = DataType.Value

adapter.Fill(ds)

BooCharted =

True

myConnection.Close()

End If

charty.Titles(0).Text = "GDP by State"

If BooCharted = True Then

'adapter.Fill(ds)With charty

.LineWidth = 3.MarkerShape = MarkerShape.None.DataSource = ds.Tables(0).Gallery = Gallery.Lines

'It requires: Imports SoftwareFX.ChartFX.Lite.Gallery

End With

myConnection.Close()

End IfEnd Sub

 

______________________________

Thanks for any help you can give me,

Russ

 

P.S.  Sorry about the indenting seems like I do not know how to use copy and paste on this forum so it keeps the formatting.  If anyone could tell me how to do that I would be grateful.

Link to comment
Share on other sites

Chart FX's databinding performs a full read of the datasource. It is not cumulative. Existing data is removed when a new binding occurs.

If you are getting data from multiple sources, you need to loop through it and use the Data API to set it to the chart. Examples of using the Data API can be found in the programmer's guide.

Link to comment
Share on other sites

What do you mean loop through it?  Are you talking about individually feeding the observations through with a chart.value property?

 For instance:

Chart1.opendata(COD.Values, 1, COD.Unknown)

For i = 1 to COD.Unknown

chart1.Value[0,i] = recordset1

next i

Chart1.opendata(COD.Values, 2, COD.Unknown)

For i = 1 to COD.Unknown

chart1.Value[1,i] = recordset1

next i

is this right?

 

Russ

P.S.  I need a bit more help here Frank if I am going to be able to convince my boss that this is a program worth paying for.

Link to comment
Share on other sites

When I do that it underlines the

chart1.value[0,i] = integervalue(i) 

 

Error 102 Property access must assign to the property or use its value.

 I thought that was what I was doing by assigning the variable array

In regards to the program.  I think I would like to bring it to my boss to upgrade if this software does the trick.  We do a lot of analytical charting and right now we do it all with the GDI objects and while the current methods work, adding functionality is hard, so we just forget about it.  I am kinda testing this out right now for the future of our estimates.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...