Select Page

Charts with PowerShell advance techniques

Charts with PowerShell advance techniques

Charts with PowerShell advance techniques

Charts with PowerShell advance techniques is all about visualizing your output data in the form of charts. If you are going to show disk space info, nothing more than a nice chart will worth looking at. If you are sending a report to your management, nothing will take their attention more than charts. I love getting charts as  a high level output, with more tables and data for extra details.

PowerShell charts are easy to produce if you know how. I had a previous blog post introducing PowerShell charts in great details. I recommend you look at that post before moving forward. What is new in this blog post is to extend the capabilities in the previous PowerShell charts script with new input data type [hash table] and new theme options.

Script Requirements

The machine that run the charts with PowerShell advance script should have:

What is different this time?

Compared to my previous PowerShell charts script, this charts with PowerShell advance script adds the following two features:

  1. The previous script  only accepts array of objects as an input data, and requires Obj_Key and Obj_Value parameters to identify X-axis and Y-axis. Now, with this new version of the script, you can have a hash table as an input as well.
  2. This new script contain a -Theme. This parameter can take a number from 1 to 7 as a theme choice, and the script will do predefined customization for you to generate highly customized charts with predefined options for each theme.

Script Data Input Types

The new charts with PowerShell advance script accepts two kind of input data:

  • Array Of objects: in this case, you have to supply the Obj_Key and Obj_Value parameters to tell the script which properties of the entered objects shall be mapped to the output chart X-axis and Y-axis. This is exactly the same input type of my previous PowerShell charts script.

Charts with PowerShell advance techniques

  • Hash Table: just supply a hash table without the need to enter the -Obj_Key and -Obj_Value parameters.

Charts with PowerShell advance techniques

Script Data Themes

A new addition in this wrapper is the -theme option. Instead of being expert on how to customize and play with your chart output, the script provides 7 themes that you chose from by using the -theme parameter. You cannot use the -type parameter when you use the -theme parameter.

Script Chart Types

Of course since your generating charts, you can use the -Type parameter to tell the script what type of charts you want to output.

Below is a small list of supported types in this .NET library:

“Point”, “FastPoint”, “Bubble”, “Line”,”Spline”, “StepLine”, “FastLine”, “Bar”,”StackedBar”, “StackedBar100”, “Column”,”StackedColumn”, “StackedColumn100”, “Area”,”SplineArea”,”StackedArea”, “StackedArea100″,”Pie”, “Doughnut”, “Stock”, “Candlestick”,”Range”,”SplineRange”, “RangeBar”, “RangeColumn”,”Radar”, “Polar”, “ErrorBar”, “BoxPlot”, “Renko”,”ThreeLineBreak”, “Kagi”, “PointAndFigure”, “Funnel”,”Pyramid”

Note: You cannot use the -Type parameter with the -Theme parameter.

Example

You can also specify the -Chart_color parameter to color the output chart

Script Data Sorting

You can use -Sort option with descending or ascending as shown in the below example

Script data decoration

Things like Chart Title, X-axis title, Y-axis title, legend and more, can be defined as shown below:

Pie/Doughnut Chart Customization

So if you are using this script with -Type Pie or -Type Doughnut , then you can use the -Show_percentage_pie  parameter to instruct the script to show percentages on the chart.

Also, sometimes the Pie/Doughnut charts get an ugly look when there is so much data to display, and overlapping text will make it hard to read text on the chart.

One clever solution is to use the -fix_label_alignment switch, which will make the chart appears in 3D and clean all overlapping text.

Also, if the chart type is pie or doughnut, you can specify a threshold (percentage) that all data values below it, will be shown as one data item called (Others). This is achieved by using the -CollectedThreshold  switch.

Download the script

You can Download the charts with PowerShell advance script from Microsoft TechNet Gallery.

Charts with PowerShell advance techniques

Charts with PowerShell advance techniques

Charts with PowerShell advance techniques

Charts with PowerShell advance techniques

Charts with PowerShell advance techniques

Charts with PowerShell advance techniques

About The Author

Ammar Hasayen

Ammar is a digital transformer, cloud architect, public speaker and blogger.
He is considered a trusted advisory with the ability to quickly navigate complex multi-cultural organizations and continuously improve and motivate cross-functional teams to achieve higher productivity, collaboration, revenue gain and cross-group knowledge sharing.

His contributions to the tech community helped him get awarded the Microsoft Most Valuable Professional.

Ammar appears in a lot of global conferences, and he has many publications about digital transformation and next generation technologies.

8 Comments

  1. ahmadak

    Gr8 effort here… im using this script to produce many internal charts for my infrastructure. Love it

    Reply
  2. Infinity Geek

    I tried this script and it works perfectly

    Reply
  3. Ravindra Pawar

    Great Script, i am using your old script, and need your advise to link your script with the sql database.

    Reply
  4. MarceloS

    HI
    Great solution!!
    question:
    I want to create a StackedColumn100. so I have an array with 3 columns (day,Up,Down) ,
    I have set -obj_key “day” -obj_value “Up” as a StackedColumn , and works fine
    but how do I specify the parameters to do a StackedColumn100 having the column composed by “Up ” and “down”

    thanks

    Reply
  5. Alex

    Good afternoon!

    When I run the script, as examples, nothing happens. It is not displayed error or generated graphic file.

    OS: Windows 10
    .Net3.5: Ok
    MSChart.exe: Ok

    Need help.

    Reply
    • ammar hasayen

      Well thats strange. Have u tried the light edition?

      Reply
      • Alex

        Não é possível localizar o tipo [system.drawing.fontstyle].
        No C:Get-Corpchart-LightEdition.ps1:222 caractere:127
        + … ect system.drawing.font(“ARIAL”,18,[system.drawing.fontstyle]::bold)) …
        + ~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo : InvalidOperation: (system.drawing.fontstyle:TypeName) [], RuntimeException
        + FullyQualifiedErrorId : TypeNotFound

        Não é possível localizar o tipo [system.drawing.fontstyle].
        No C:Get-Corpchart-LightEdition.ps1:224 caractere:129
        + … t system.drawing.font(“calibri”,16,[system.drawing.fontstyle]::italic …
        + ~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo : InvalidOperation: (system.drawing.fontstyle:TypeName) [], RuntimeException
        + FullyQualifiedErrorId : TypeNotFound

        Failed to save chart at c:chart.png
        No C:Get-Corpchart-LightEdition.ps1:592 caractere:29
        + Throw “Failed to save chart at $filepath”
        + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo : OperationStopped: (Failed to save chart at c:chart.png:String) [], RuntimeException
        + FullyQualifiedErrorId : Failed to save chart at c:chart.png

        Reply
  6. Alex

    PS C:> $cities = @{London=7556900; Berlin=3429900; Madrid=3213271; Rome=2726539;Paris=2188500}
    PS C:> .Get-Corpchart-LightEdition -data $cities -obj_key “Name” -obj_value “Population” -filepath “c:chart.png” -type pie

    PS: Removing the parameters:

    222, [system.drawing.fontstyle] :: bold
    224, [system.drawing.fontstyle] :: italic

    a png file blank is generated.

    Reply

Trackbacks/Pingbacks

  1. Charts and PowerShell !! PowerShell Wrapper “Light Edition” | Ammar Hasayen - Blog - […] Check Out the Light Edition of this PowerShell Wrapper : Get-CorpCharts-FulltEdition […]

Leave a reply

Your email address will not be published. Required fields are marked *

Ammar_Hasayen_MVP_1

About Ammar

Digital Transformation | Microsoft MVP | Cloud Architect | Azure | Microsoft 365 |Modern Workplace | Cyber-Security | Blockchain | Speaker | Blogger | IT Director @ Aramex| Jordan | http://me.ahasayen.com

Recent Posts

Pin It on Pinterest