问题涉及以下链接:
How do I generate data for Google Visualizations on the server using WebSharper
我想重新实现上述内容虽然使用最新版本的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来修复它。但是当我在谷歌浏览器中运行它时,我得到以下内容:
You called the draw() method with the wrong type of data rather than a DataTable or DataView
谢谢!