F#
HTML
Result
Hosted on
Try WebSharper
<
>
namespace Samples open WebSharper open WebSharper.JavaScript open WebSharper.JQuery open WebSharper.Highcharts [<JavaScript>] module HelloWorld = [<Require(typeof<Resources.Highcharts>)>] let MakeChart() = Highcharts.SetOptions( OptionsCfg(Global = GlobalCfg(UseUTC = false)) ) |> ignore Highcharts.Create(JQuery("#main"), HighchartsCfg( Chart = ChartCfg( Type = "spline", MarginRight = 10., Events = ChartEventsCfg( Load = FuncWithOnlyThis(fun (this: Chart) -> let series = this.Series.[0] JS.SetInterval (fun () -> let x = Date().GetTime() let y = Math.Random() series.AddPoint((x, y), true, true) ) 1000 |> ignore ) ) ), Title = TitleCfg(Text = "Live random data"), XAxis = [| XAxisCfg( Type = "datetime", TickPixelInterval = 150. ) |], YAxis = [| YAxisCfg( Title = YAxisTitleCfg(Text = "Value"), PlotLines = [| YAxisPlotLinesCfg( Value = 0., Width = 1., Color = "#808080" ) |] ) |], Tooltip = TooltipCfg( Formatter = FuncWithOnlyThis(fun (this: Point) -> "<b>" + this.Series.Name + "</b><br/>" + Highcharts.DateFormat("%Y-%m-%d %H:%M:%S", this.X) + "<br/>" + Highcharts.NumberFormat(this.Y, 2.) ) ), Legend = LegendCfg(Enabled = false), Exporting = ExportingCfg(Enabled = false), Series = [| SeriesCfg( Name = "Random data", Data = [| let time = Date().GetTime() for i in -19 .. 0 do yield New [ "x" => (time + i * 1000) "y" => Math.Random() ] |] ) |] ) ) |> ignore let Main = MakeChart()
<html> <head> <title></title> </head> <body> <div id="main"></div> <!--[BODY]--> </body> </html>