Advertisement
mariussm

Charting module demo 1

Jun 18th, 2014
3,638
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Import-Module .\GoodWorkaroundCharts-v0.1.psm1 -Force
  2.  
  3. # Create simple dataset
  4. $simpleDataset = @{
  5.     "Microsoft" = 800
  6.     "Apple" = 250
  7.     "Google" = 400
  8.     "RIM" = 0
  9. }
  10.  
  11. # Create chart and show it
  12. New-Chart -Dataset $simpleDataset | Show-Chart
  13.  
  14.  
  15.  
  16. # Create ordered hashmap
  17. $osloTemperature = [ordered]@{}
  18.  
  19. # Request weather data for Oslo, and put into dataset
  20. [xml]$weather = (Invoke-WebRequest -Uri http://www.yr.no/place/Norway/Oslo/Oslo/Oslo/varsel.xml).Content
  21. $weather.weatherdata.forecast.tabular.time | foreach {
  22.     $osloTemperature[$_.from] = $_.temperature.value  
  23. }
  24.  
  25. # Create chart, add dataset and show
  26. New-Chart -Title "Temperature in Oslo" -XInterval 4 -YInterval 2 -Width 1200 |
  27.     Add-ChartDataset -Dataset $osloTemperature -DatasetName "Temperature" -SeriesChartType Spline -OutVariable tempChart |
  28.     Show-Chart
  29.  
  30. # Save the chart as a PNG to the desktop
  31. $tempChart.SaveImage($Env:USERPROFILE + "\Desktop\Chart.png", "PNG")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement