I've tried to embed a .NET WinForms graph (Stephan Zimmermann's Graph Display) in a WPF window, under a WindowsFormsHost (I've referenced both System.Windows.Forms and WindowsFormsIntegration).
However, I can see the form panel but not the graph. I've ran the demo application on a windows form and it worked, but when I transfered the same code to the WPF window, I saw that the data is updated but not shown on the graph.
Thank everyone in advance,
Yaron.
Set the graph as the child of the WindowsFormsHost object.
Could you try the following code and see if you can get a graph to display and then work from there?
MainWindow.xaml.cs
MainWindow.xaml
making sure you have references to:
%ProgramFiles%\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Profile\Client\WindowsFormsIntegration.dll
%ProgramFiles%\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Profile\Client\System.Windows.Forms.DataVisualization.dll
%ProgramFiles%\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Profile\Client\System.Windows.Forms.dll
I have this running after shamelessly copying the following link
I had the same issue in WPF. Luckily I got the solution.
I observed that chart areas and series are being reset once the data source is set. It looks like a bug for me.
So, the workaround/solution is to set the data source at very first place before adding the things like chart areas and series.
Although the question is more than 6 years old I had a similar (if not the same issue), when trying to create and add the Chart object at runtime. Thanks to Bobwah's suggestion I could isolate the problem and found that I simply had to add a ChartArea to the Chart object to see the graph:
Hope it helps someone... ;)