Render Plotters plot in iced

Hi All,
I’m trying to make a program which needs some plotting. Ideally I would like to use iced to take the input and then use plotters to plot the image. However, I can’t find a nice way to make the two work together.

If I use the image widget then I will need to change the path of the plot each time I re-render as iced’s caching system isn’t capable of realizing the image at the original path has changed and therefore continues to render the original image even after it has been updated.

My other thought would be to use the canvas widget as plotters is able to use a HTML5 back-end for plotting but I’m can’t find any particularly good documentation on how the canvas widget works.

Does anyone know if there is way to display plotters plots in iced?

Thanks

1 Like

GitHub - Joylei/plotters-iced: 📈 Iced backend for Plotters :slight_smile:

1 Like

there’s also the more recent but smaller GitHub - kunerd/pliced

Thanks, I had a look.
However, there’s a bit of a snag there. I’m wanting to make multiple plots and (as far as I can tell) there’s no way to do that without cloning all the data into each plot widget. I’m not crazy about having to clone/apply updates to a copy of the data for each plot every time anything updates. I opened an issue on the github asking about it but have yet to hear back.

Their performance also seems to be horrifically bad for some reason. I with their CPU monitor example causing around 60% CPU usage (yes that was compiled in release mode).

P.S. How are you able to send links? the system on here won’t allow me to link to stuff

1 Like

Yeah, ideally you’d just be borrowing data when displaying widgets. I have 1-2 things on my todo list before tackling charts hopefully next week or so, at which point I might just write my own implementation. I’ll try to remember to post it here :sweat_smile:

As for links, you’ll need the “Basic” badge at which point the link (and other) restrictions are lifted. I think it’s a pretty low threshold to hit that so it should be soon. On that note, if you have Discord, that community is remarkably more active than this one, so I always encourage people to consider joining that too.

You definitely want to store the data in your app state and only borrow it in your chart. Admittedly I didn’t look at the CPU monitor example in detail but it looks like it does this – can you share any of your code? You may be able to avoid the cloning

I’d have a look at that pliced thing. I’ve only used it a bit but it’s surprisingly easy to use, performant and well integrated into the iced system (even down to theming everything correctly). It might be small and recent but it’s a really slick piece of work.

1 Like