EvotecIT / PSWriteHTML

PSWriteHTML is PowerShell Module to generate beautiful HTML reports, pages, emails without any knowledge of HTML, CSS or JavaScript. To get started basics PowerShell knowledge is required.
MIT License
828 stars 106 forks source link

Dump chart to image for email #272

Open tomerikko opened 3 years ago

tomerikko commented 3 years ago

Hi @PrzemyslawKlys , i am trying to find a way to create a graph > convert it to an image > and use the image in an email Body. that is to avoid any issues with different email clients. Any idea on how to do that would be grateful :)

i looked in New-ChartPie couldn't see any option to dump to file, so i am assuming some piping and functions magic is needed.

if you have any simple idea i would appreciate that.

thanks again! Tomer.

PrzemyslawKlys commented 3 years ago

Won't work. Similar to diagrams https://github.com/EvotecIT/PSWriteHTML/discussions/271 it's all generated on the fly.

I've started some tests on how to create charts in simple CSS that would work in email but it wasn't any good, giving mixed results. I have to find library that would be generating charts straight to images and then try to make it usable in PSWriteHTML.

tomerikko commented 3 years ago

Got it, thanks @PrzemyslawKlys , your work and help is truly appreciated.

tomerikko commented 3 years ago

not sure if it helps with your project @PrzemyslawKlys or not. but also for the rest, i found a way to create a chart and dump it to an image. https://www.alkanesolutions.co.uk/2019/03/13/charting-with-powershell/ take this example above, and in the end instead of showdialog to open a page, just dump it to image, with this command: $chart.SaveImage("c:\chartimage.png","png")

PrzemyslawKlys commented 3 years ago

Yes it's helpful. I saw this before and was playing with it - but https://github.com/dotnet/winforms-datavisualization is deprecated.

But I have an idea for it. Probably need to create a new PowerShell module - there goes my free time.

PrzemyslawKlys commented 3 years ago

Actually, you can find the module using what you proposed https://github.com/iainbrighton/PScriboCharts