2016-07-15 45 views
2

我知道如何控制FSharp.Charting中的顏色,字體大小和網格線。但是有沒有辦法爲線條顏色設置不透明度和/或將線條類型改爲虛線。如何在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)) 

回答

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

+0

這非常整齊。我真的需要升級我的FSLAB。看來這是最近添加的(0.90.14?)到[FSharp.Charting](https://github.com/fslaborg/FSharp.Charting/commit/b70b4a6be13cba4c9ec80de19e641ba4b5ed8fe9)。謝謝! – s952163

+2

對,上面的代碼片段使用'FSharp.Charting 0.90.14'。 –