Hello
Can we use Windows form chart with Eto?
Or is it possible to use this tool oxyplot with Eto in Rhino?
Well, you should be able to use it with Rhino. What does âuse with Etoâ mean?
â Dale
For example , i create eto form with button,
And than i want add windows chart to the eto form.
And how we can use oxyplot with Rhino?
I doubt anyone here (at McNeel) knows much (if anything) about this. But let us know what you find.
â Dale
Thanks , i try to load it and i will test if i success to create a plot
This is my try without success
import clr
clr.AddReferenceByName("Eto.OxyPlot")
clr.AddReferenceByName("Eto.OxyPlot.Wpf")
clr.AddReferenceByName("OxyPlot")
import Eto
import Eto.OxyPlot as plot
import OxyPlot as oxy
import Rhino.UI
import Eto.Drawing as drawing
import Eto.Forms as forms
import math
class SimpleEtoDialog(forms.Dialog):
def __init__(self):
self.Title = "Sample Eto Dialog"
self.ClientSize = drawing.Size(400, 400)
self.Padding = drawing.Padding(5)
self.Resizable = False
self.plotmodel = oxy.PlotModel()
self.plotmodel.LegendBorder = oxy.OxyColors.Black
self.plotmodel.LegendBackground = oxy.OxyColor.FromAColor(200, oxy.OxyColors.White)
self.plotmodel.LegendPosition = oxy.LegendPosition.TopRight
self.plotmodel.LegendPlacement = oxy.LegendPlacement.Outside
self.plotmodel.LegendOrientation = oxy.LegendOrientation.Horizontal
self.plotmodel.LegendTitle = "Legend"
self.datapoints = []
self.datapoints.Add(oxy.DataPoint(0,1))
self.datapoints.Add(oxy.DataPoint(1,4))
self.datapoints.Add(oxy.DataPoint(2,8))
self.datapoints.Add(oxy.DataPoint(3,12))
self.serie = oxy.Series.LineSeries()
self.serie.StrokeThickness = 1
self.serie.ItemsSource = self.datapoints
self.plotmodel.Series.Add(self.serie)
self.view = self.plotmodel.PlotView
layout = forms.DynamicLayout()
layout.Spacing = drawing.Size(5, 5)
layout.AddRow(self.view)
self.Content = layout
#self.Content = self.view
################################################################################
def TestSampleEtoDialog():
dialog = SimpleEtoDialog()
dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)
################################################################################
if __name__ == "__main__":
TestSampleEtoDialog()
I do use OxyPlot within a WPF app. But I donât know much about using Eto with IronPython.
There are a couple of things I noticed. And I donât know where to startâŚ. First, do you want to program platform independent? If you stick to windows, just create a library with WPF windows/controls inside, make use of the Visual Studio Designer, and just reference and open your window from there. Iâm not so sure if Oxyplot likes âdynamicâ layouts, I had issues with that in the past. Always set the width and height of the plotview. If you donât use MVVM, just directly assign points to a line series. Otherwise the collection must be an Observable collection instead of a List. You have not assigned a color to your series (âŚ)
Anyway I wonât setup anything to actually test. I would advise not to use Eto and IronPython, at least if you donât plan to distribute this as a plugin
Thanks Tom for explanation
I just learn and test if itâs really work wirh Ghpython, i donât find any example with python or ironpython,
all examples available for c#, c++, html , android âŚetc
I tried windows chart and it work fine but eto more flexible and have better support in Rhino, if i find a way to use windows form chart with eto form this will be better.
I will try your suggestion maybe i will get something .
nb: When i print self.view i got None, and when i print self.plotmodel i got empty line
Ah yeah, I see you donât initiate the Plotview. You just reference that from the plotmodel. But in there its null. Just call the constructor. And assign the plotmodel to it. The view comes first, and it requires a viewmodel (=plotmodel) to know how to operate.
Thats the problem with Eto and IronPython, itâs badly documented.
Can you try to include this code?
self.view = oxy.PlotView()
self.view.Width = 400
self.view.Height = 400
self.view.Model = self.plotmodel
Thanks but it is different here.
OxyPlot donât have PlotView and PlotView donât have anything like width, height âŚetc
No its in oxy not in oxy.PlotModel. Again read careful. There is a view and a view/plot model. The view is just the âlookâ, while the plotmodel contains all the logic. Have you tried to copy and paste the code from above at this location?
Yes but it is not available
That is strange, then you are missing a reference⌠Thats how I would do it in XAML
[...]
xmlns:oxy="http://oxyplot.org/wpf"
[...]
<oxy:PlotView Model="{Binding PlotModel}"
Width="400"
Height="400">
[...]
</oxy:PlotView>
You need that PlotView object. Maybe its in the Eto package?
I search and try many possibilities without success.
I donât know if the developer miss something or it canât work with ironpython
I just try i am not sure what is the right method to create it
I mean it makes sense. The Plotmodel is a general implementation. It works for any GUI toolkit. But the view itself is something which belongs to a given GUI framework, obviously. If you are using Eto, then you need to find the PlotView made for the Eto library.
Eto donât have anything for chart, this is a dll from Eto.oxyplot, and the developer donât share any tutorial or explanation how to use it
Have you tried to reference OxyPlot.WPF and OxyPlot.Core? You might also ship OxyPlot.Gtk for Mac user
In my bin folder there is a OxyPlot.dll and a OxyPlot.Wpf.dll.
Ahh you did, try this:
from Eto.OxyPlot.Wpf import PlotView
view = PlotView()
...