如何在FSharp.Charting中设置不透明度和线型

时间:2016-07-15 09:21:43

标签: f# fsharpchart fslab

我知道如何在FSharp.Charting中控制颜色,字体大小和网格线。但是,有没有办法为线条颜色设置不透明度和/或将线条类型更改为虚线。

#load @"..\..\FSLAB\packages\FsLab\Fslab.fsx"

open FSharp.Charting
open System.Drawing

let rnd = System.Random()
rnd.NextDouble()
let rs = List.init 100 (fun _ -> rnd.NextDouble()-0.5)
let rs = rs |> List.scan (+) 0.

Chart.Line(rs) 
    .WithYAxis(MajorGrid = ChartTypes.Grid(Enabled=true,LineColor=Color.LightGray))
    .WithXAxis(MajorGrid = ChartTypes.Grid(Enabled=true,LineColor=Color.LightGray))

1 个答案:

答案 0 :(得分:2)

这样的事情:

.....
Chart.Line(rs,Name="randomwalk") 
    .WithYAxis(MajorGrid = ChartTypes.Grid(Enabled=true,LineColor=Color.LightGray))
    .WithXAxis(MajorGrid = ChartTypes.Grid(Enabled=true,LineColor=Color.LightGray))
    .ApplyToChart(fun x -> x.Series.["randomwalk"].BorderDashStyle <- System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash)
    .ApplyToChart(fun x -> x.Series.["randomwalk"].Color <- Color.FromArgb(127, Color.Red))

会将图表randomwalk线条样式设置为ChartDashStyle.Dash,并将颜色设置为半透明Color.Red