Project Description
FSChart is an F# functional wrapper over the Microsoft Chart Control. It allows the creation of complex charts in a compositional manner and with a fluent syntax, that makes it well suited for the interactive data exploration scenario.

It is based on a project previously hosted on the defunct code gallery : http://archive.msdn.microsoft.com/fschart and has been refactored for an increased ease of use.

let gauss2h rho =
    let k, x0, x1, n, sx = 10000, -4.0, 4.0, 32, 1.0
    let y1s, y2s, xs, h1, h2 = scatterhist rho k x0 x1 n
    
    let axVal  = axis  |> labels ( arialR 7 ) |> range ( x0, x1, sx )
    let axVal0 = axVal |> crossAt 0.0 false
    let axPdf  = axVal |> range (0.0, 0.5, 0.1)
    let area1  = areaF |> axisX ( setAs axVal  ) |> axisY ( setAs axPdf  )
    let area2  = areaF |> axisX ( setAs axVal0 ) |> axisY ( setAs axVal0 )
    let areaR  = areaF |> title ( arialR 14 >> color blue >> text (sprintf " \nRHO\n=\n%.2f" rho) >> inside )
                       |> axisX ( solid blue 1 ) |> axisY ( solid blue 1 ) |> border blue 1
    
    let chart  =
        C.create <|
        C.stackV [ 0.3; 0.7 ]
            [ C.stackH [ 0.7; 0.3 ]
                [ C.plot area1
                    [ bar 1.0 |> color blue |> border darkBlue 1,
                      SeriesData.XY (xs, h1) ] 
                  C.marginU 0.1 ( C.plot areaR [] ) ]
              C.stackH [ 0.7; 0.3 ]
                [ C.plot ( area2 |> alignV "A1" )
                    [ scatter |> marker (circle >> color (alpha 32 blue)),
                      SeriesData.XY (y1s, y2s) ]
                  C.plot area1
                    [ barH 1.0 |> color blue |> border darkBlue 1,
                      SeriesData.XY (xs, h2) ] ] ]
    
    MSChart.display true 600 600 chart |> ignore

gauss2h.png

Last edited Apr 28, 2011 at 11:57 PM by nchouk, version 7