Home Forums WinForms controls Xceed Chart for WinForms Function syntax

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #18940 |

    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

    Imported from legacy forums. Posted by Andre_Mag (had 1672 views)

    User (Old forums)
    Member
    Post count: 23064

    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()

    Imported from legacy forums. Posted by André (had 639 views)

    User (Old forums)
    Member
    Post count: 23064

    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

    Imported from legacy forums. Posted by Andre_Mag (had 511 views)

    User (Old forums)
    Member
    Post count: 23064

    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()

     

    Imported from legacy forums. Posted by André (had 1863 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.