I don't understand how to create a chart control and place the chart in an existing form. All the examples I found on the web show the chart in a new form but I would like to add the chart to one of my existing forms.
I'm thinking of something like this:
let form = new Form(Text="My form")
let lbl = new Label(Text="my label")
let chart = Chart.Area ["a", 10; "b", 20]
form.Controls.Add lbl
form.Controls.Add chart
// ---> The type 'ChartTypes.GenericChart' is not compatible with the type 'Control'
Application.Run(form)
Thanks!
In order to achieve this you should wrap your chart into
FSharp.Charting.ChartTypes.ChartControl
and take care of correct docking. Also you should not mixChart
from FSharp.Charting withChart
fromSystem.Windows.Forms.DataVisualization.Charting
.A good staring point may be the following fully functional sample that works with the current FSharp.Charting v0.90.5; also references are required to
System.Drawing
andSystem.Windows.Forms
: