Jump to content
Software FX Community

Should I use data compacting to sum data? If so how?


silkcfx

Recommended Posts

Hi there,

I've just started using the control, have looked at the programmer's reference and samples on data compacting but am at a loss.

My requirement is to group data up by "any" field. I am considering using datasources to do this but was really curious about chart data compacting. I am writing in VB.net and don't really understand the sample provided in the programmer's reference as follows:

'This is assigning a new delegate of type CompactFormulaHandler      
Chart.Data.Y.CompactFormula = New CompactFormulaHandler(addressof SumFormula)         
 'This code is the handler for the delegate.
Private Function SumFormula(data As IDataArray, seriesIndex As Integer, startPoint As Integer, endPoint As Integer) As Double
    Dim sum As double
    Dim i As Integer
    For i = startPoint To endPoint
        sum += data(seriesIndex, i)
    Next i 
    Return sum
End Function
 
I've bolded the parts that were wrong in your example. I'm not sure "addressof" is the correct thing to do as I am new to delegates, but I know without anything specified it doesn't compile.
 With this code how do I go about actually creating my summed columns? Is there any sample code on this, as the only sample code I have seen uses the rather easier predefined forumlas.
 
 
 

 

 

 

Link to comment
Share on other sites

Looks like my post got really messed up after being verified. Here's the last bit again..

I've bolded the parts
that were wrong in your example. I'm not sure "addressof" is the
correct thing to do as I am new to delegates, but I know without anything
specified it doesn't compile
.

With this code how do
I go about actually creating my summed columns? Is there any sample code on
this, as the only sample code I have seen uses the rather easier predefined
forumlas
.

 

'This is assigning a new delegate of type CompactFormulaHandler	  
Chart.Data.Y.CompactFormula = New CompactFormulaHandler([b]addressof [/b]SumFormula)		 
 'This code is the handler for the delegate.
Private Function SumFormula(data As IDataArray, seriesIndex As Integer, startPoint As Integer, endPoint As Integer) As Double
    Dim sum As [b]double[/b]
    Dim i As Integer
    For i = startPoint To endPoint
	    sum += data(seriesIndex, i)
    Next i 
	Return sum
End Function
 
 
 

 

 

Link to comment
Share on other sites

  • 3 weeks later...

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...