我正在尝试将 LiveCharts 示例转换为 Basic Line Chart与 Elmish.Wpf 一起使用
除了“YFormatter”之外,我对所有东西都有绑定(bind)。我应该使用哪种绑定(bind)?
type Model = {
AllSeries: SeriesCollection
Labels: string[]
Formatter: ???
}
let init() = (
AllSeries =
let series = new SeriesCollection()
series.Add(new LineSeries(Title="S1", Values=new ChartVAlues<int>(seq {4; 6; 5})))
series
Labels = [| "Jan"; "Feb"; "Mar" |]
Formatter = ???
}
let bindings () : Binding<Model, MessageType> list = [
"AllSeries" |> Binding.oneWay(fun m -> m.AllSeries)
"Labels" |> Binding.oneWay(fun m-> m.Labels)
"YFormatter" |> ?????
]
xaml 按照基本折线图示例
<lvc:CartesianChart Series="{Binding AllSeries}">
<lvc:CartesianChart.AxisY>
<lvc:Axis Title="Sales" LabelFormatter="{Binding YFormatter}"></lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis Title="Month" Labels="{Binding Labels}"></lvc:Axis>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
最佳答案
成功了
模型根本不需要“格式化程序”
所以,init 无关
绑定(bind)有
"YFormatter" |> Binding.oneWay(fun m -> Func<Double,_> (fun d -> d.ToString("C")))
关于f# - LiveCharts LabelFormatter 的 Elmish.Wpf 绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67053789/