BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Introducing XPlot, a Chart Generation Library for F#

Introducing XPlot, a Chart Generation Library for F#

Bookmarks

XPlot is a cross-platform data visualization package for F# powered by JavaScript charting libraries Google Charts and Plotly. The XPlot library can be used interactively from F# Interactive, but charts can also be embedded in F# applications and in HTML reports.

XPlot acts as a F# wrapper around Javascript libraries. Using the API to generate a chart using Google Charts or Plotly as a provider, XPlot produces Html and Javascript code.

XPlot charts can be created dynamically and rendered in a web application.  For example, this code produces a bar chart displaying statuses with their respective occurrence:

open XPlot.GoogleCharts

let statusCount () =
  let series = [("Open",23); ("In Progress",5); ("Resolved", 58); ("Closed",5)]

  let options =
      Options(title = "Status", orientation = "horizontal")

  if series |> Seq.isEmpty then "no data" else
      let chart = 
        series
        |> Chart.Bar
        |> Chart.WithOptions options
        |> Chart.WithLabels ["Count"]
      chart.InlineHtml

The html output can then be embedded in a web application. The code above would produce this chart:

The charts generated by XPlot can be rendered from an F# application, but they can also be used from C#. This means a web or WPF application written in C# could use XPlot to generate a chart and then render the output.

Xplot is also available as part of the data science package FsLab. FsLab also contains librairies for data access and analysis, which can then be rendered using XPlot.

 

Rate this Article

Adoption
Style

BT