Jump to content
Software FX Community

Mixed line and scatter Chart Types


User (Legacy)
 Share

Recommended Posts

Apologies for the length of this posting.

I'm new to ChartFX and still trying to get my mind around the object model.

We bought the package because of it's publicised support for ADO resultsets

only to later find from ChartFX Support that any one chart can only accept

one Resultset. OK, so we can assign to arrays, no big deal. Maybe the

developers can look at supporting multiple recordsets in a future release.

I'm not finding the syntax intutive. Maybe it's me and I need to read the

manual and review the samples again.

We have a package that is heavily database intensive. Essentially it's a

statistical package, hence the need for a reliable and quality charting

package. Most of the charts are scatter with a line of best fit overlay.

I've tried to prototype with ChartFX and I'm at my wits end. Things don't

work properly. OK, so it's probably something I'm doing or not doing. Can

some helpful person show the light?

A general question :

In the help, OpenDataEx COD_VALUES, N1, N2. Does N1 refer to the number

of series in the data OR the series number being added? Subtle but very

important difference.

I want to create two series of Scatter Plots and one with a Line (Line of

Best Fit), all on the same Chart. The scatter chart series have a known

number of points, but these can change depending on what the user selected.

The line chart always consists of two points only. I use the term line chart

loosely, because it is essentially a scatter plot consisting of two points

connected by a line. All series are passed as arrays to a class method. When

I run this code without overlaying the line of best fit, the two scatter

series chart OK. If run with the line of best fit overlay, all series show

just two points each. What am I doing wrong? Any help much appreciate.

Paul

Here is a sample call :

'---------------------------------------------------------------------------

-----

Dim clsObj As New clsChart 'the Charting Class

Dim varData(1 To 2, 1 To 10) As Variant

Dim varLineData(1 To 2, 1 To 4) As Variant

..... code to populate varData() for first series

blnRet = clsObj.SetChart(Me.FX2, FXGALLERY_SCATTER, 1) 'Me.FX2 is ChartFX

Control, FXGALLERY_SCATTER = 4

blnRet = clsObj.SetDataArray(Me.FX2, XYDATA, varData(), 1)

..... code to populate varData() for second series

blnRet = clsObj.SetDataArray(Me.FX2, XYDATA, varData(), 2)

blnRet = clsObj.SetChart(Me.FX2, FXGALLERY_SCATTER, 2)

..... code to populate varLineData() for third series (line of best fit)

blnRet = clsObj.SetDataArray(Me.FX2, XYDATA, varData(), 3)

blnRet = clsObj.SetChart(Me.FX2, FXGALLERY_LINE, 3) 'FXGALLERY_LINE = 1

.... other code to set various chart properties

'-----------------------------------------------------------------

Here is the SetDataArrayMethod in clsChart :

Public Function SetDataArray(objChart As ChartFX, _

intDataType As Integer, pData() As Variant, pintSeries As Integer) As

Boolean

Dim intSeries As Integer

Dim intPoints As Integer

Dim intCount As Integer

' Set X/Y data

objChart.OpenDataEx COD_VALUES, pintSeries, UBound(pData, 2)

objChart.OpenDataEx COD_XVALUES, pintSeries, UBound(pData, 1)

For intCount = 0 To UBound(pData, 2) - 1

objChart.Series(pintSeries - 1).Yvalue(intCount) = pData(2, intCount

+ 1)

objChart.Series(pintSeries - 1).Xvalue(intCount) = pData(1, intCount

+ 1)

Next

objChart.CloseData COD_VALUES

objChart.CloseData COD_XVALUES

End If

objChart.RecalcScale

End Function

'--------------------------------------------------------------------------

Function SetChart(objChart As ChartFX, intChart As Integer, intSeries As

Integer, Optional intStacked) As Boolean

'CHART_NOSTACKED 0 No stacked chart.

'CHART_STACKED 1 Stacked.

'CHART_STACKED100 2 100% stacked.

With objChart

' Chart Type Settings

If .Series.Count = 1 Then

.BorderStyle = BORDER_RAISED

.Border = True

.AllowDrag = False

.AllowDrag = False

.Gallery = intChart

Else

.Series(intSeries - 1).Gallery = intChart

End If

.Chart3D = False

If intChart = BAR Then

.STACKED = intStacked

End If

.Zoom = False

End With

End Function

Link to comment
Share on other sites

1)

OpenDataEx COD_VALUES, N1, N2

N1 refers to the number of series in the chart, regardless of the CURRENT

number of series.

2) You are overriding the first OpenData call with the second, you see

calling OpenData is like assigning variables (Series and Points) calling

OpenData a second time will just override those values and the previous

settings will be lost.

What you need to do is only ONE call to OpenDataEx (well actually 2 calls,

one with COD_VALUES and one with COD_XVALUES, same N1 and N2 in both).You

are going to specify 2 series (Scatter and Line) and as many points as the

LARGEST series contains.

You then go ahead and set your data for the SCATTER (bigger) series and set

the first two points of the second (line), then you have to fill in the rest

of the data for the second series (smaller) with CHART_HIDDEN by assigning

it to the ValueEx property.

So you will end up with a chart with say 100 points, of which the second

series (line) contains only the first two points with data and the rest are

blank. You should see this if you display the data editor.

--

FP

Software FX, Inc.

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.

 Share

×
×
  • Create New...