-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathChartWindow.fs
67 lines (53 loc) · 2.02 KB
/
ChartWindow.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
namespace global
open System.Drawing
open System.IO
open System.Windows
open System.Windows.Forms.Integration
open FSharp.Charting
open FSharp.Charting.ChartTypes
type ChartWindow(chart:GenericChart, ?title) as this =
inherit Window()
let chartHost = new WindowsFormsHost()
let mutable chart = chart |> Chart.WithXAxis(MajorGrid = Grid(LineColor = Color.LightGray))
|> Chart.WithYAxis(MajorGrid = Grid(LineColor = Color.LightGray))
|> Chart.WithMargin(5.0, 5.0, 5.0, 5.0)
let setChart() =
let chartControl = new ChartControl(chart)
chartHost.Child <- chartControl
chartControl
let mutable chartControl = setChart()
do
this.Width <- 600.0
this.Height <- 600.0
this.Content <- chartHost
//TODO broken with new FSharp.Charting
//this.Title <- defaultArg title (ChartFormUtilities.ProvideTitle chart)
this.Title <- defaultArg title "Untitled"
setChart |> ignore
member x.Reset(newChart) =
chart <- newChart
chartControl.Dispose()
chartControl <- setChart()
x.Activate() |> ignore
//TODO broken with new FSharp.Charting: combining looses axis setup
member x.Combine(newChart) =
chart <- Chart.Combine [chart; newChart]
chartControl.Dispose()
chartControl <- setChart()
x.Activate() |> ignore
static member showWithTitle title chart =
let chartWindow = new ChartWindow(chart, title)
chartWindow.Show()
chartWindow.Activate() |> ignore
chartWindow
static member show chart =
let chartWindow = new ChartWindow(chart)
chartWindow.Show()
chartWindow.Activate() |> ignore
chartWindow
static member runWithTitle title chart =
let chartWindow = new ChartWindow(chart, title)
chartWindow.ShowDialog() |> ignore
static member run chart =
let chartWindow = new ChartWindow(chart)
chartWindow.ShowDialog() |> ignore