如何使XPlot在Linux/Mono上工作?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (1)
  • 关注 (0)
  • 查看 (66)

在Linux上使用图表库XPlot for F#时遇到问题。例如,当我使用“fsharpi”命令为烛台图表运行标准示例脚本时,脚本本身无任何抱怨地运行,但未打开任何浏览器并且不显示任何内容。

例如脚本:

#load "../packages/FsLab/FsLab.fsx" 
open XPlot.GoogleCharts

let data =
    [
        "Mon", 20, 28, 38, 45
        "Tue", 31, 38, 55, 66
        "Wed", 50, 55, 77, 80
        "Thu", 77, 77, 66, 50
        "Fri", 68, 66, 22, 15        
    ]

Chart.Candlestick data

如果我通过运行它:

fsharpi "test.fsx"

什么也没有发生,一段时间后只有另一行命令提示符出现,但也没有发生错误。如果我通过运行它:

fsharpi
#load "test.fsx";;

显示以下输出:

[Loading /home/flo/Copy/Mono/FSharp/FinalHashtagVisualizer/packages/FsLab/Shared/Server.fsx
 Loading /home/flo/Copy/Mono/FSharp/FinalHashtagVisualizer/packages/FsLab/Shared/Styles.fsx
 Loading /home/flo/Copy/Mono/FSharp/FinalHashtagVisualizer/packages/FsLab/Text/FsLab.fsx
 Loading /home/flo/Copy/Mono/FSharp/FinalHashtagVisualizer/packages/FsLab/FsLab.fsx
 Loading /home/flo/Copy/Mono/FSharp/FinalHashtagVisualizer/HashtagVisualizer/test.fsx]
namespace FSI_0003.FsLab.Formatters
  type SimpleServer =
    class
      new : unit -> SimpleServer
      member AddPage : page:string -> string
      member
        AddPart : part:(Suave.Http.HttpContext ->
                          Async<Suave.Http.HttpContext option>) -> string
      member Port : Suave.Sockets.Port
    end
  val instance : System.Lazy<SimpleServer>

namespace FSI_0003.FsLab.Formatters
  val private defaultStyles :
    System.Collections.Generic.IDictionary<string,string>

namespace FSI_0003.FsLab.Formatters
  val private displayHtml : html:string -> unit

namespace FSI_0003.FSharp.Charting
  type Chart with
    static member
      Line : data:Deedle.Series<'K,#FSharp.Charting.value> * ?Name:string *
             ?Title:string * ?Labels:#seq<string> *
             ?Color:System.Drawing.Color * ?XTitle:string * ?YTitle:string ->
               FSharp.Charting.ChartTypes.GenericChart
               when 'K : equality and 'K :> FSharp.Charting.key
  type Chart with
    static member
      Column : data:Deedle.Series<'K,#FSharp.Charting.value> * ?Name:string *
               ?Title:string * ?Labels:#seq<string> *
               ?Color:System.Drawing.Color * ?XTitle:string * ?YTitle:string ->
                 FSharp.Charting.ChartTypes.GenericChart
                 when 'K : equality and 'K :> FSharp.Charting.key
  type Chart with
    static member
      Pie : data:Deedle.Series<'K,#FSharp.Charting.value> * ?Name:string *
            ?Title:string * ?Labels:#seq<string> * ?Color:System.Drawing.Color *
            ?XTitle:string * ?YTitle:string ->
              FSharp.Charting.ChartTypes.PieChart
              when 'K : equality and 'K :> FSharp.Charting.key
  type Chart with
    static member
      Area : data:Deedle.Series<'K,#FSharp.Charting.value> * ?Name:string *
             ?Title:string * ?Labels:#seq<string> *
             ?Color:System.Drawing.Color * ?XTitle:string * ?YTitle:string ->
               FSharp.Charting.ChartTypes.GenericChart
               when 'K : equality and 'K :> FSharp.Charting.key
  type Chart with
    static member
      Bar : data:Deedle.Series<'K,#FSharp.Charting.value> * ?Name:string *
            ?Title:string * ?Labels:#seq<string> * ?Color:System.Drawing.Color *
            ?XTitle:string * ?YTitle:string ->
              FSharp.Charting.ChartTypes.GenericChart
              when 'K : equality and 'K :> FSharp.Charting.key
namespace FSI_0003.MathNet.Numerics.LinearAlgebra
  val inline toFrame :
    matrix:MathNet.Numerics.LinearAlgebra.Matrix<'a> -> Deedle.Frame<int,int>
      when 'a : (new : unit -> 'a) and 'a : struct and
           'a :> System.IEquatable<'a> and 'a :> System.IFormattable and
           'a :> System.ValueType
  val inline ofFrame :
    frame:Deedle.Frame<'a,'b> -> MathNet.Numerics.LinearAlgebra.Matrix<float>
      when 'a : equality and 'b : equality
  val inline ofFrame :
    frame:Deedle.Frame<'a,'b> -> MathNet.Numerics.LinearAlgebra.Matrix<float>
      when 'a : equality and 'b : equality
  val inline toSeries :
    vector:MathNet.Numerics.LinearAlgebra.Vector<'a> -> Deedle.Series<int,'a>
      when 'a : (new : unit -> 'a) and 'a : struct and
           'a :> System.IEquatable<'a> and 'a :> System.IFormattable and
           'a :> System.ValueType
  val inline ofSeries :
    series:Deedle.Series<'a, ^b> ->
      MathNet.Numerics.LinearAlgebra.Vector<float>
      when 'a : equality and  ^b : (static member op_Explicit :  ^b -> float)
  val inline ofSeries :
    series:Deedle.Series<'a, ^b> ->
      MathNet.Numerics.LinearAlgebra.Vector<float>
      when 'a : equality and  ^b : (static member op_Explicit :  ^b -> float)
namespace FSI_0003.Deedle
  val inline ofMatrix :
    matrix:MathNet.Numerics.LinearAlgebra.Matrix<'a> -> Deedle.Frame<int,int>
      when 'a : (new : unit -> 'a) and 'a : struct and
           'a :> System.IEquatable<'a> and 'a :> System.IFormattable and
           'a :> System.ValueType
  val inline toMatrix :
    frame:Deedle.Frame<'a,'b> -> MathNet.Numerics.LinearAlgebra.Matrix<float>
      when 'a : equality and 'b : equality
  val ofCsvRows :
    data:FSharp.Data.Runtime.CsvFile<'T> -> Deedle.Frame<int,string>
  val inline ofVector :
    vector:MathNet.Numerics.LinearAlgebra.Vector<'a> -> Deedle.Series<int,'a>
      when 'a : (new : unit -> 'a) and 'a : struct and
           'a :> System.IEquatable<'a> and 'a :> System.IFormattable and
           'a :> System.ValueType
  val inline toVector :
    series:Deedle.Series<'a, ^b> ->
      MathNet.Numerics.LinearAlgebra.Vector<float>
      when 'a : equality and  ^b : (static member op_Explicit :  ^b -> float)

namespace FSI_0003
  val data : (string * int * int * int * int) list

我使用VS Code和Ionide-Extension。我通过伪装安装了FsLab-Package,并且通常运行良好(除了图表)。我通过VS Code中的“new project”命令创建了这个项目,但是我没有找到一种方法来通过VS Code-command来运行它,而是使用(集成)控制台来代替它。我试图使用NetCore而不是Mono,但是没有找到使其工作的方法。据我所知,我使用的F#Interactive版本是4.1,是最新的。

提问于
用户回答回答于
#load "../packages/FsLab/FsLab.fsx"
open XPlot.GoogleCharts

let data =
    [
        "Mon", 20, 28, 38, 45
        "Tue", 31, 38, 55, 66
        "Wed", 50, 55, 77, 80
        "Thu", 77, 77, 66, 50
        "Fri", 68, 66, 22, 15        
    ]

Chart.Candlestick data |> Chart.Show

扫码关注云+社区

领取腾讯云代金券