Welcome to the Xceed Community | Help
Community Search  

Function syntax

Sort Posts: Previous Next
  •  06-12-2008, 11:41 AM Post no. 12912

    Function syntax

    Hi,

     I want to calculate a standard deviation (stddev). Here is what I have done in vb.net and it give me an error...

    Here is the code :

    Dim calculateur As FunctionCalculator = New FunctionCalculator()

    Dim x

    Dim a(5) As Double

    a(0) = 2

    a(1) = 3

    a(2) = 2

    a(3) = 3

    a(4) = 2

    a(5) = 3

    calculateur.Expression = "stddev(a)"

    x = calculateur.Calculate()

     

    What is wrong with that ?

     thanks a lot,

     André_Mag

  •  06-13-2008, 2:36 PM Post no. 12953 in reply to 12912

    Re: Function syntax

    You need to use it in association with a chart series.

     e.g.

    bar.Values.Name = "values"

    bar.Add( 2 )

    bar.Add( 3 )

    bar.Add( 2 )

    bar.Add( 3 )

    calculateur.Arguments.Clear()

    calculateur.Arguments.Add( bar.Values )

    calculateur.Expression = "STDDEV( Values )"

    x = calculateur.Calculate()


    André
    Software Developer and Tech Support
    Xceed Software Inc.
  •  07-02-2008, 4:34 PM Post no. 13387 in reply to 12953

    Re: Function syntax

    Hi again,

     I see, I have 2 more questions, the first one is how do you declare the series. Is it like "

    Dim barC As New PointSeries "

     and my other question is when I run the program, I have an error message at the line

    calculateur.Expression = "STDDEV( Values )"

     It says that value ": Invalid argument name: Values"

    Thanks,

     André_Mag

  •  07-03-2008, 4:21 PM Post no. 13419 in reply to 13387

    Re: Function syntax

    This is because the parameter's first letter is uppercase (Values), and the name's one is lowercase (values), a mistake I made in the code snippet I provided earlier.

    To declare the bar series, you need to do it the following way, using a type cast

    Here is the code that works :

     Dim chart As Chart = ChartControl1.Charts(0)

    Dim barSeries As BarSeries = CType(chart.Series.Add(SeriesType.Bar), BarSeries)

    barSeries.Values.Name = "Values"

    barSeries.Add(2)

    barSeries.Add(3)

    barSeries.Add(2)

    barSeries.Add(3)

    Dim calculateur As FunctionCalculator = New FunctionCalculator()

    calculateur.Arguments.Clear()

    calculateur.Arguments.Add(barSeries.Values)

    calculateur.Expression = "STDDEV( Values )"

    Dim x = calculateur.Calculate()

     


    André
    Software Developer and Tech Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.