2014-11-04 93 views
1

我對WebSharper的Google Visualization庫有疑問。當鼠標懸停在地理海圖上的國家時,我試圖格式化數據。WebSharper中的數字格式化Google Visualization

然而,對於Legendhttps://github.com/intellifactory/websharper.google.visualization/blob/master/IntelliFactory.WebSharper.Google.Visualization/Base.fs

type Legend [<Inline "{}">]() = 
    [<DefaultValue>] 
    val mutable position : LegendPosition 
    [<DefaultValue>] 
    val mutable alignment : LegendAlignment 
    [<DefaultValue>] 
    val mutable textStyle : TextStyle 

以下定義這並沒有考慮到這是在這樣的圖表作爲GeoChart https://developers.google.com/chart/interactive/docs/gallery/geochart

numberFormat有沒有辦法規避這(格式化工具提示/傳說)?

非常感謝

回答

2

的一般解決方法:x?y <- z動態分配可以在WebSharper的代碼被用於獲取x.y = z在JavaScript翻譯。所以在你的情況下,例如legend?numberFormat <- ".##"

您也可以擴大與一個輔助方法傳說類型是:

type Legend with 
    [<JavaScript; Inline>] 
    member this.WithNumberFormat(format: string) = 
     this?numberFormat <- format 
     this 

或者您也可以通過New [ "numberformat" => ".##" ]創建一個JavaScript對象表達式就像把Legend對象使用。

WebSharper的Google.Visualization類型綁定有點過時。我們會在某一天徹底檢查它,但如果遇到任何缺少的API功能,請隨時創建拉取請求。