Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion docs/content/FurtherSamples.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,17 @@ Chart.Line(data,Name="SomeData").WithDataPointLabels(PointToolTip="Hello, I am #
Chart.Stock(timeHighLowOpenClose)
Chart.ThreeLineBreak(data,Name="SomeData").WithDataPointLabels(PointToolTip="Hello, I am #SERIESNAME")

Chart.Histogram([for x in 1 .. 100 -> rand()*10.],LowerBound=0.,UpperBound=10.,Intervals=10.)
Chart.Histogram([for x in 1 .. 100 -> rand()*10.],LowerBound=0.,UpperBound=10.,Intervals=10.)

// Example of .ApplyToChart() used to alter the settings on the window chart and to access the chart child objects.
// This can normally be done manually, in the chart property grid (right click the chart, then "Show Property Grid").
// This is useful when you want to try out carious settings first. But once you know what you want, .ApplyToChart()
// allows programmatic access to the window properties. The two examples below are: IsUserSelectionEnabled essentially
// allows zooming in and out along the given axes, and the longer fiddly example below does the same work as .WithDataPointLabels()
// but across all series objects.
[ Chart.Column(data);
Chart.Column(data2) |> Chart.WithSeries.AxisType( YAxisType = Windows.Forms.DataVisualization.Charting.AxisType.Secondary ) ]
|> Chart.Combine
|> fun c -> c.WithLegend()
.ApplyToChart( fun c -> c.ChartAreas.[0].CursorX.IsUserSelectionEnabled <- true )
.ApplyToChart( fun c -> let _ = [0 .. c.Series.Count-1] |> List.map ( fun s -> c.Series.[ s ].ToolTip <- "#SERIESNAME (#VALX, #VAL{0:00000})" ) in () )
2 changes: 1 addition & 1 deletion docs/content/fsharpcharting.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The following methods are used to style chart objects:
* `WithTitle`
* `WithXAxis`
* `WithYAxis`

* `ApplyToChart`

Please [contribute](contributing.html) more documentation on the following topics:

Expand Down
7 changes: 7 additions & 0 deletions src/FSharp.Charting.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,7 @@ namespace FSharp.Charting

let mutable data = ChartData.Values (NotifySeq.ignoreReset (NotifySeq.notifyOrOnce []), ChartValueType.Auto, "Item1", "Item2", "")
let mutable margin = DefaultMarginForEachChart
let mutable customizationFunctions : (Chart -> unit) list = []

[<Obsolete("This type does not support GetHashCode()")>]
override x.GetHashCode() = 0
Expand All @@ -1165,6 +1166,11 @@ namespace FSharp.Charting
member internal x.Chart with get() = chart.Value and set v = chart <- evalLazy v
member internal x.Margin with get() = margin and set v = margin <- v
member internal x.Name with get() = name and set v = name <- v
member internal x.CustomizationFunctions with get() = customizationFunctions

member x.ApplyToChart ( fn : Chart -> unit ) =
customizationFunctions <- ( fn :: customizationFunctions )
x

/// Ensure the chart has a Title
member internal x.ForceTitle() =
Expand Down Expand Up @@ -3950,6 +3956,7 @@ namespace FSharp.Charting
frm.Text <- ProvideTitle ch
frm.Controls.Add(ctl)
frm.Show()
ch.CustomizationFunctions |> List.rev |> List.map (fun fn -> fn ch.Chart) |> ignore
ctl.Focus() |> ignore
frm

Expand Down