[英]How do I make XPlot work on Linux / Mono?
I have problems using the charting library XPlot for F# on Linux. 我在Linux上使用图表库XPlot for F#时遇到问题。 When I use the "fsharpi"-command to run a standard example script for the candlestick chart, for instance, the script itself runs without any complains but no browser is opened and nothing is shown.
例如,当我使用“ fsharpi”命令为烛台图表运行标准示例脚本时,该脚本本身运行时没有任何抱怨,但没有打开浏览器,也没有显示任何内容。
example-script: 例如脚本:
#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
If I run it via: 如果我通过以下方式运行它:
fsharpi "test.fsx"
nothing happens, after some time just another line of the command prompt appears, but also no error occurs. 什么也没发生,一段时间后,仅出现命令提示符的另一行,但也没有发生错误。 If I run it via:
如果我通过以下方式运行它:
fsharpi
#load "test.fsx";;
the following output is shown: 显示以下输出:
[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
I use VS Code and the Ionide-Extension. 我使用VS Code和Ionide-Extension。 I installed the FsLab-Package via Fake and generally works well (except for the charting).
我通过Fake安装了FsLab-Package,并且通常运行良好(图表除外)。 I created the project via the "new project"-command within VS Code, but I didn't find a way to also run it via a VS Code-command but used the (integrated) console instead.
我通过VS Code中的“新项目”命令创建了项目,但是我没有找到一种方法也可以通过VS Code命令来运行它,而是使用了(集成的)控制台。 I tried to use NetCore instead of Mono, but didn't find a way to make it work either.
我尝试使用NetCore代替Mono,但也没有找到一种使它工作的方法。 The F# Interactive version I use is 4.1, the latest as far as I know.
据我所知,我使用的F#Interactive版本是4.1。
I hope my question is now specific enough to meet the community guidelines. 我希望我的问题现在足够具体,可以满足社区准则的要求。
As it has been pointed out in the comments you have to pipe the chart to Chart.Show. 正如注释中指出的那样,您必须将图表通过管道发送到Chart.Show。 Thus the following script should work as intended:
因此,以下脚本应按预期工作:
#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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.