Search code examples
chartsf#fsharpchart

FSharp Charting change data point label font size


Using F# Charting I am able to change axis label font sizes with

    chart |> Chart.WithArea.AxisX(LabelStyle = myStyle)

however have not found a way to change data point label font sizes

    let myChart = Chart.Line prices |> Chart.WithDataPointLables(Label = "hello")

created as above.

Any know how to go about this?


Solution

  • This doesn't seem to be supported directly FSharp.Charting but the library does provide a hole through its abstraction so you can access the underlying chart representation and do whatever you want to it. Assuming that you're running this on Windows with System.Windows.Forms.DataVisualization, which the library uses by default, then you can do this:

    open FSharp.Charting
    
    Chart.Line [1; 2; 3]
    |> Chart.WithDataPointLabels(Label = "hello")
    |> fun c -> c.ApplyToChart(fun c ->
        c.Series.[0].Font <- System.Drawing.Font("Verdana", float32 28))