开发者

FSharpChart.Column with a label on easy column

开发者 https://www.devze.com 2023-03-14 17:27 出处:网络
I\'ve been using the F# charting library for a bit of interactive charting. It\'s really nice for showing charts of data really quickly but the lack of documentation is a little frustrating. For examp

I've been using the F# charting library for a bit of interactive charting. It's really nice for showing charts of data really quickly but the lack of documentation is a little frustrating. For exampl开发者_如何学Pythone labels seem to be placed on grid lines rather the points by default. I'm creating a columns chart using FSharpChart.Column and therefore makes more sense to have the labels on each columns grather than the grid lines, but I can find how to do this.


Specifying labels is not currently supported by the library - This is definitely an important thing that should be added, so I'll pass that feedback to people currently working on the library.

If you want to digg deeper, then this needs to be done when binding chart series to a data source, which is done in a setSeriesData function:

let internal setSeriesData resetSeries (series:Series) data 
                           (chart:Chart) setCustomProperty =
    match data with 
    // Single Y value 
    | ChartData.YValues ys ->
        series.Points.DataBindY [| ys |]
    | ChartData.XYValues(xs, ys) ->
        series.Points.DataBindXY(xs, [| ys |])
    // (...)

The function gets data in a discriminated union value ChartData that is created by all the different charting functions like FSharpChart.Column. I'm not sure what would be the best strategy - probably add option<seq<string>> that can specify additional labels. To display the labels, you'd probably have to change the call to DataBindY (or DataBindXY) to a call to DataBind that allows specifying additional properties (such as labels).

Regarding the documentation - I wrote some articles about the library that should be online (on MSDN actually) soon. It is not comprehensive documentation, but it should cover most of the supported features of the library.

0

精彩评论

暂无评论...
验证码 换一张
取 消