2

这些问题与以下链接有关:

如何使用 WebSharper 在服务器上为 Google 可视化生成数据

尽管使用最新版本的 Websharper(开源 alpha 版本),但我想重新实现上述内容,但收到以下错误:

无法反序列化以下的元数据:IntelliFactory.WebSharper.Google.Visualization,Version=3.0.0.0,Culture=neutral,PublicKeyToken=dcd983dec8f76a71

我打开了一个客户端-服务器 Web 应用程序;以下是各个文件的代码:

Remoting.fs中

namespace WebsiteX

open System
open IntelliFactory.WebSharper
open IntelliFactory.WebSharper.Html
open IntelliFactory.WebSharper.Google
open IntelliFactory.WebSharper.Google.Visualization
open IntelliFactory.WebSharper.Google.Visualization.Base
open IntelliFactory.WebSharper.EcmaScript
open IntelliFactory.WebSharper.Web


module Remoter =
[<Remote>]
let RandomData () =

    let random = new Random()
    let valueCount = 100
    let maxValue = 300
    let seriesCount = random.Next(5)

    let data = new Base.DataTable()
    data.addRows(valueCount)
    |> ignore        

    let addSeries index =
        let name = sprintf "Series %d" index
        data.addColumn(ColumnType.NumberType, name)
        |> ignore

        Seq.init valueCount (fun index -> random.Next(maxValue))
        |> Seq.iteri (fun valueIndex value -> data.setValue(index, valueIndex, value) |> ignore)

    [0 .. seriesCount]
    |> List.iter addSeries

    data

Client.fs 中:

namespace WebsiteX

open IntelliFactory.WebSharper
open IntelliFactory.WebSharper.Html
open IntelliFactory.WebSharper.Google
open IntelliFactory.WebSharper.Google.Visualization
open IntelliFactory.WebSharper.Google.Visualization.Base
open Remoting

[<JavaScript>]
module Client =

    [<Remote>]    
    let dd = Remoter.RandomData() 


    [<JavaScript>]
    let Main() =
        Div []
        |>! OnAfterRender(fun container ->
            let visualization = new LineChart(container.Body)
            let options =
                LineChartOptions(
                    width = 400,
                    height = 240,
                    legend = Legend(position = LegendPosition.Bottom),
                    title = "Title")
        visualization.draw(dd, options))

我没有更改 Main.fs 中的任何内容(它与提供的模板相同)。我对Web开发不太熟悉,所以可能有一个简单的答案。

为什么当我尝试构建它时,我收到以下信息:无法反序列化元数据:IntelliFactory.WebSharper.Google.Visualization,Version=3.0.0.0,Culture=neutral,PublicKeyToken=dcd983dec8f76a71

我下载了 Websharper 并从 Nuget 安装了预发布版本。使用 WebSharper.3.0.1.73-alpha 和 WebSharper.Google.Visualization.3.0.2.193-alpha

通过升级到 WebSharper.3.0.3.76-alpha 来修复它。但是当我在 Google Chrome 中运行它时,我得到以下信息:

You called the draw() method with the wrong type of data rather than a DataTable or DataView

谢谢!

4

0 回答 0