0

Here is my base code. So far I'm showing my values in html table format like below.

    $pass=20
    $fail=5
    $reject=2
    $Body = -join("<table border=2>
     <tr><th>pass<td>$pass</td></th></tr>
       <tr><th>failFailed<td>$fail</td></th></tr>
    </table>", $myEmail)
    $SMTPMessage = New-Object System.Net.Mail.MailMessage($EmailFrom,$EmailTo,$Subject,$Body)

I added a rough image how do I need. expecting similar:

img

  • this seems to be a purely HTML/CSS question, really, maybe with some math through the powershell script. Do you know your way around HTML/CSS or do you need help with that extensively? – Plagiatus Apr 20 '23 at 06:23
  • with help of html & css i can achieve it normally. the biggest problem is embedding html& Css into Pshell is the big challenge – Kasi Raman Apr 20 '23 at 07:04
  • at the end of the day HTML is just text, so once you have the text content, you should be able to just add it in PS like you did already for your table. – Plagiatus Apr 20 '23 at 07:07

1 Answers1

0

Based on How to make a pie chart in CSS and https://www.w3schools.com/css//css3_gradients_conic.asp, here is a solution that should work for you.

First, calculate at how many degrees the various parts of the piechart need to start and end.

$pass=20
$fail=5
$reject=2
$total=$pass + $fail + $reject
$deg=360 / $total
$degpass = $deg * $pass
$degfail = $deg * $fail + $degpass

And now the HTML code for the pie chart the with the variables infused

<div style='width:100px; height:100px; border-radius:50%; background-image: conic-gradient(green ${degpass}deg, red ${degpass}deg, red ${degfail}deg, black ${degfail}deg);'></div>

of course you can then also add the text next to it.

<p>Pass: $pass</p>
<p>Fail: $fail</p>
<p>Reject: $reject</p>

Here is what the result should look like in your example:

<div style='width:100px; height:100px; border-radius:50%; background-image: conic-gradient(green 267deg, red 267deg, red 334deg, black 334deg);'></div>

<p>Pass: 20</p>
<p>Fail: 5</p>
<p>Reject: 2</p>

Any further stylistic improvements are just more HTML/CSS changes, not PS specific ones.

Plagiatus
  • 360
  • 2
  • 12