3
comments
on 10/1/2015 6:09 AM

We are happy to announce the release of WebSharper.Suave, an adapter to run WebSharper applications on Suave.

With WebSharper.Suave, creating a Suave WebPart from a WebSharper Sitelet is as simple as a single function call.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
module Main

open WebSharper
open WebSharper.UI.Next.Html

[<JavaScript>]
module Client =
    open WebSharper.JavaScript
    open WebSharper.UI.Next.Client
    open WebSharper.Charting

    let RadarChart () =
        let labels =    
            [| "Eating"; "Drinking"; "Sleeping";
               "Designing"; "Coding"; "Cycling"; "Running" |]
        let data1 = [|28.0; 48.0; 40.0; 19.0; 96.0; 27.0; 100.0|]
        let data2 = [|65.0; 59.0; 90.0; 81.0; 56.0; 55.0; 40.0|]

        let ch =
            Chart.Combine [
                Chart.Radar(Seq.zip labels data1)
                    .WithFillColor(Color.Rgba(151, 187, 205, 0.2))
                    .WithStrokeColor(Color.Rgba(151, 187, 205, 1.))
                    .WithPointColor(Color.Rgba(151, 187, 205, 1.))

                Chart.Radar(Seq.zip labels data2)
                    .WithFillColor(Color.Rgba(220, 220, 220, 0.2))
                    .WithStrokeColor(Color.Rgba(220, 220, 220, 1.))
                    .WithPointColor(Color.Rgba(220, 220, 220, 1.))
            ]
        Renderers.ChartJs.Render(ch, Size = Size(400, 400))

open WebSharper.Sitelets
open WebSharper.UI.Next.Server

let MySite =
    Application.SinglePage (fun ctx ->
        Content.Page(
            Body = [
                h1 [text "Charting on Suave is easy with WebSharper!"]
                div [client <@ Client.RadarChart() @>]
            ])
    )

open Suave.Web
open WebSharper.Suave

startWebServer defaultConfig (WebSharperAdapter.ToWebPart MySite)

This opens up awesome ways to combine Suave and WebSharper applications, and we are excited about the synergies this will bring to the F# web programming community.

Happy coding!

.

If you're interested, it would probably take minutes to convert this adapter to something that makes websharper runnable on DNX (Asp.NET v5).

By on 10/4/2015 7:36 PM ()

Badd ass

By on 1/28/2016 10:47 AM ()

Happy to announce that there is now a template for bootstrapping an app with this on linux at https://github.com/fsprojects/generator-fsharp.

By on 2/6/2016 9:46 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper