XPlot 中的选项和 WithSize 等是否仅特定于某些图表?

Are options and WithSize etc in XPlot specific to only certain charts?

我在 FSLab 教程中尝试了 Chart.WithSizedisplayZoomButtons = true,但似乎没有任何改变输出。

在其他直接使用 XPlot.GoogleCharts 的项目中也是如此。

我是不是漏掉了什么?

从 nuget 下载 Plotly 1.4.2 并替换 XPlotly 的 FSLab 包目录中的 dll(参见 )。然后就可以使用Xplotly的控件进行放大缩小,保存图表等。例如:

#load @"..\..\FSLAB\packages\FsLab\FsLab.fsx"
open XPlot.Plotly
open XPlot.Plotly.Graph
open XPlot.Plotly.Html
//open XPlot.GoogleCharts

let layout = Layout(title = "Basic Bar Chart")
["giraffes", 20; "orangutans", 14; "monkeys", 23]
    |> Chart.Bar
    |> Chart.WithLayout layout
    |> Chart.WithHeight 400
    |> Chart.WithWidth 700
    |> Chart.Show

使用 Plotly 的非常准系统的图表解决方案(并且有效):

open Newtonsoft.Json

let html = """<head>
  <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
  <div id="myDiv" style="width: 100%; height: 100%;"></div>
  <script>
    var data = __DATA__;
    var layout = __LAYOUT__;
    Plotly.newPlot('myDiv', data, layout);
  </script>
</body>"""

let (=>) k v = k, (v:>obj)

let doPlot data layout =
    let data = JsonConvert.SerializeObject data
    let layout = JsonConvert.SerializeObject layout
    let path = Path.GetTempPath() + DateTime.Now.Ticks.ToString() + ".html"
    File.WriteAllText(path, html.Replace("__DATA__", data).Replace("__LAYOUT__", layout))
    System.Diagnostics.Process.Start(path)

let layout =
    [ "title" => "Plot"
      "xaxis" => dict [
        "title" => "Ticks"
        "showgrid" => false
        "zeroline" => false
      ]
      "yaxis" => dict [
        "title" => "Price"
        "showline" => false
      ]
    ] |> dict

let data = [
    dict [ "x" => [1999; 2000; 2001; 2002]
           "y" => [16; 5; 11; 9]
         ]
    ]

doPlot data layout