# ChartImage Powershell Module

#Static Website 👾
So I didn't think I would be making this many Powershell modules all in the month of July 2022. Guess it shows that if you are feeling productive you can be productive
As I think I mentioned it is really easy to put a decent looking documentation site together using Retype. It's quite old-skool 📼 but at the same time nicely presented. That got me thinking that the Retype template is ⭐ great looking out the box, and has enough easy-to-use components using simple markdown. I have also mentioned how much I miss Powershell Universal originally I got hooked on this program with the charts that it offered. They were just out of this world, and the fact you did it all in Powershell made it even better.
#Image-Charts.com 💡

I wasn't looking for a new challenge or module to release, but when I stumbled on the C# library for image-charts.com I thought this would make an excellent binary module. Although essentially this is just API calling which could have been done with Powershell and Invoke-WebRequest or something similar. I just fancied trying to improve my non-existent C# skills. Before I got deep-diving into this project, I thought it would make sense to first have a butchers at the powershellgallery.com to make sure there wasn't already an image-charts module, and there wasn't. To my knowledge there isn't a lot apart from Powershell Universal that have lots of super cool charts (I know as I built a good number of charting modules for this product) but again I knew I couldn't have dynamic charts running on a static website. However I thought it would still make a page look even nicer if you had some data displayed on the page.
#Building the project 👷

Originally I was thinking this was going to be super-easy to smash module. As I did a build and release and with the sample I found it just worked. Then the parameter list started to grow and grow 🌱 then me being me, I maybe had added these parameters without testing the build at each modification. So suddenly what I thought would work didn't quite work out as planned. Then all the parameters that I didn't specify as mandatory were expecting a value. I had to figure out how to pass a value to the variable for that parameter value should it be empty. I do not know C# so was happy when I got it all pretty much working to allow you as a potential end user to not be bombarded entering values for 13 different paramters. Instead I only made 3 mandatory paramters path
chartType
and dataPoints
to me these were the 3 fundamental things you needed to specify to produce a chart of your choice and the data in it, and finally the output path to store the image of the chart.
#Help 📣

Not sure why I didn't think about this in previous binary modules. Maybe it's because I only got building them this month, but I was thinking I should add as much help as I could to the parameters via the help message for each parameter. I did this as it wasn't super obvious to me how I could layout the data to the way I wanted it, or how to choose different colours or labels to be displayed. There were just so many possibilities to each chart you could make. The more parameters the more possibilities. So although I have not created all the possible parameters, depending on how popular this module becomes, will be the deciding factor on time spent developing it more.
#Two Commands 🧦 🧤
Maybe things are better in pairs, just like socks or maybe gloves. Originally I was thinking I just wanted to be able to save the image of the chart I was generating to a specific directory. I was really happy I had got it all working so I created a quick repository, got an icon, then posted it to the Powershell gallery. Then I was thinking 🤔 what if people just wanted the URL to be generated for there image? No problem I saw that this was one of the capabilities and as I had already done a namespace for the saving of the chart, it really was a case of copying and pasting that editing a few bits, then I suddenly had 2 commands to go with this module instead of just one. Allowing you to either save the image or to generate the automatic URL to view your image online.
#Code Time 🥁
I thought I would post the final .CS code that made up this binary module. So without further hold-up here it is:-
Hopefully you can see why it ended up taking longer than expected, with all the parameters I kept adding, after thinking damn that's a cool parameter to have. As mentioned before there is a lot more parameters I could add should this module be a popular one.
#Demo Time 📈
Okay I guess it's time to show you nice reader how the magic works. I cannot recommend enough that you take time to visit
To see what you can do with these charts, and how the parameters can affect the display of the chart.
I have not included the chartjs in this module
If I have not included enough documentation on this page or with the help in the parameters that I have included in the module this please check the documentation as well which is located here.
So the next time someone asks me how old all my daughters are... 😁


