Skip to content

Commit

Permalink
Save using a ChartControl without creating a form.
Browse files Browse the repository at this point in the history
  • Loading branch information
simra committed Apr 10, 2016
1 parent 1bff0e1 commit bbbc9bd
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/FSharp.Charting.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3160,16 +3160,10 @@ namespace FSharp.Charting
f.ShowDialog() |> ignore

/// Save a chart to a file in png format
static member Save filename (chart:GenericChart) =
use cc = new ChartControl(chart)
cc.Dock <- DockStyle.Fill
use f = new Form()
f.Size <- System.Drawing.Size(800, 600)
f.Controls.Add cc
f.Load |> Event.add (fun _ -> chart.SaveChartAs(filename, ChartImageFormat.Png); f.Close())
// Removed Application.Run: Triggers exception in fsi.exe. See issue https://github.com/fslaborg/FSharp.Charting/issues/38
// Application.Run f
f.ShowDialog() |> ignore
static member Save (filename:string) (chart:GenericChart) =
use cc = new ChartControl(chart, Dock=DockStyle.Fill,Width=800,Height=600)
chart.CopyAsBitmap().Save(filename, System.Drawing.Imaging.ImageFormat.Png);



/// Contains static methods to construct charts whose data source is an event or observable which
Expand Down

0 comments on commit bbbc9bd

Please sign in to comment.