strangelights.com

Main F# Site

Edit Edit
Print Print
Recent Changes Recent Changes
Subscriptions Subscriptions
Lost and Found Lost and Found
Find References Find References
Rename Rename
Search
List all versions List all versions
F Sharp Charting
.
Summary

There are many, many good free or pay-for-use charting libraries available for .NET - just look around and you will find them.

The F# distribution contains an example Automation\Excel showing how to create charts interactively using F#.

The example below uses a free library (commercial if use want to print or save your chart) available here : http://www.componentxtra.com (named XYgraph)

Usage example :

        #use "graphit.ml";;
        (Array.init 100 (fun x-> Math.Sin(Float.of_int x))) |> graph;;

File "graphit.ml":

        #r @"XYGraph.dll";;
        open System
        open System.Drawing
        open System.Collections
        open System.ComponentModel
        open System.Windows.Forms
        open System.Data
        open System.Drawing.Drawing2D
        open componentXtra
        open System.Console
        let graph my_data = 
                let f = new Form() in 
                f.Width  <- 400;
                f.Height <- 300;
                let xyGraph1 = new componentXtra.XYGraph() in 
                f.Controls.Add(xyGraph1);
                f.Controls.Add(xyGraph1);
                xyGraph1.BackColor <- Color.White;
                xyGraph1.Dock <- DockStyle.Fill;
                xyGraph1.ForeColor        <- SystemColors.ActiveCaption;
                xyGraph1.XtraLabelX <- "X";
                xyGraph1.XtraLabelY <- "Y";
                xyGraph1.Location <- new Point(0, 0);
                xyGraph1.Name <- "xyGraph1";
                xyGraph1.XtraShowGrid <- true;
                xyGraph1.XtraShowLegend <- true;
                xyGraph1.Size <- new System.Drawing.Size(720, 502);
                xyGraph1.TabIndex <- 0;
                xyGraph1.XtraTitle <- "My Chart"; 
                xyGraph1.Width  <- 400;
                xyGraph1.Height <- 300;
                xyGraph1.Visible<- true;
                xyGraph1.AddGraph("my_data", DashStyle.Solid, Color.Red,1,false);
                 Array.iteri (fun i x -> xyGraph1.AddValue(0,Float32.of_int i, x)) 
                   (Array.map Float32.of_float my_data) in
                 xyGraph1.Invalidate();
                 f.ShowDialog()
Welcome to F Sharp Wiki, view the HomePage

This site supports the new NoFollow anti-spam initiative.

Recent Topics

Copyright 2005, Robert Pickering (Others where credited) | Terms of Use