Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Access to the underlying .NET chart object (#102)
* Exposed access to the underlying System.Windows.Forms.DataVisualization.Charting.Chart object via a "visitor"-esque member method ApplyToChart(...), in order to enable programmatic control over the chart form window (which is already accessible to the user manually via the Properties tab of the chart form). This enables us to use charting with the following example pattern: let inputData = [1;2;3] inputData |> Chart.Line |> fun c -> c.WithLegend() // add legend using the existing method |> fun c -> ( c, c.ShowChart() ) // create the chart form |> fun (c, _) -> (c, c.ApplyToChart( fun c -> c.ChartAreas.[0].CursorX.IsUserSelectionEnabled <- true ) ) // can now modify chart form using all of the available .NET Chart API by chaining lines like this one |> ignore // avoid displaying the chart twice * ApplyToChart() now returns the Chart object, enabling us to chain calls, like in the example below: inputData |> Chart.Line // do things necessary before chart is rendered |> fun c -> c.WithLegend( FontSize = 5.0 ) .WithStyling( Color = System.Drawing.Color.Red ) // create the chart form and render the chart |> fun c -> ( c, c.ShowChart() ) // do things that can only be done after the chart is rendered |> fun ( c, _ ) -> c.ApplyToChart( fun c -> c.ChartAreas.[0].CursorX.IsUserSelectionEnabled <- true ) .ApplyToChart( fun c -> c.ChartAreas.[0].CursorY.IsUserSelectionEnabled <- true ) |> ignore // avoid displaying the chart twice * Implemented the "caching" of functions applid using ApplytoChart() until the point of drawing of the actual chart, as discussed in #102 (comment). ApplyToChart() is now usable with the existing simple dot-notation. * Added ApplyToChart to the documentation. * CustomizationFunctions need to be applied in the order they were added, if only for the sake of clarity. This was noticed by @simra.
- Loading branch information