<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Huddled Masses &#187; Charts</title>
	<atom:link href="http://huddledmasses.org/tag/charts/feed/" rel="self" type="application/rss+xml" />
	<link>http://huddledmasses.org</link>
	<description>You can do more than breathe for free...</description>
	<lastBuildDate>Sat, 28 Jan 2012 21:37:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<cloud domain='huddledmasses.org' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>PowerBoots &#8211; Output Graphs to Images from PowerShell</title>
		<link>http://huddledmasses.org/powerboots-output-graphs-to-images-from-powershell/</link>
		<comments>http://huddledmasses.org/powerboots-output-graphs-to-images-from-powershell/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 06:01:08 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Charting]]></category>
		<category><![CDATA[Charts]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[PowerBoots]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Visifire]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/?p=1019</guid>
		<description><![CDATA[Once I started playing with the new ability, introduced in PowerBoots 0.0.4 to easily add support for new graphical controls to PowerBoots, I found all sorts of fun widgets out there in open-source land. I&#8217;ll write about a few of them in the future, but for now I&#8217;m just going to stick with Visifire. After [...]]]></description>
			<content:encoded><![CDATA[	<p>Once I started playing with the new ability, introduced in <a href="http://huddledmasses.org/PowerBoots/">PowerBoots</a> 0.0.4 to easily add support for new graphical controls to PowerBoots, I found all sorts of fun widgets out there in open-source land.  I&#8217;ll write about a few of them in the future, but for now I&#8217;m just going to stick with Visifire.  After playing with a few examples, I finally got around to actually trying to create the graphs I needed at work which were the main source of motivation for trying to do Visifire from PowerShell anyway &#8230;</p>

	<p>The problem was, half of the need we have for graphs is to throw them up on a web-server &#8230; so I needed a way to take the <span class="caps">WPF</span> window, and capture the controls and visuals as an image. Basically, render the <span class="caps">WPF</span> control to a bitmap image, instead of to the screen.  To cut a long story short, I figured it out of course &#8212; why else would I be writing this? (<a href="http://huddledmasses.org/PowerBoots/">get it here</a>).</p>

	<h2>Out-BootsImage</h2>

	<p>So the new version of PowerBoots includes the Out-BootsImage function (aliased as BootsImage and &#8220;obi&#8221;), which basically is designed to take the filename of an image, and a boots visual element, and create a screenshot.  It can generate bmp, gif, jpg, png, tiff, and even Microsoft&#8217;s new <a href="http://www.microsoft.com/windows/windowsmedia/wmphoto" title="HD Photo">wdp</a> format, or it can output to clipboard.</p>

	<p><img src="http://huddledmasses.org/images/PowerBoots/VisiFire-BootsImage.jpg" align="right" alt="" width="200" height="150" /></p>

	<p>It&#8217;s late, so I&#8217;m not going to write any more about this &#8230; the bottom line is, if you have been looking for a (free) way to generate graphs and charts to image files in PowerShell, this will work for you: go grab <a href="http://www.visifire.com/">Visifire</a>, check out their <a href="http://www.visifire.com/silverlight_charts_gallery.php">gallery</a> for inspiration, and start churning out graphs! Just for fun, here are the samples from the help documentation (except, this is the actual script I ran, including the upload code) with screen-shots &#8230;  </p>

	<h3>Important note</h3>

	<p>When producing images of Visifire charts using this method, it is absolutely critical that <strong>you must specify <code>-Animation $false</code></strong> because otherwise you will consistenly produce images of empty charts (since by default Visifire animates all of the bars onto the screen right <em>after</em> the <code>SourceInitialized</code> event that I use to capture the image). Oh, and if you need to remove the Visifire.com watermark, there is a <code>-watermark $false</code> parameter on the <code>Chart</code> element, which turns it off.</p>

	<p><img src="http://huddledmasses.org/images/PowerBoots/VisiFire-OutImage.jpg" alt="" width="200" height="150" /></p>

	<div class="posh code posh" style="font-family:monospace;"><br />
<span style="color: #660033; font-weight: bold;">$credential</span> <span style="color: #66cc66;">=</span> <span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">Credential</span></span><br />
<br />
Chart <span style="color: #000066;">-Width</span> <span style="color: #cc66cc;">200</span> <span style="color: #000066;">-Height</span> <span style="color: #cc66cc;">150</span> <span style="color: #000066;">-Theme</span> Theme3 <span style="color: #000066;">-Watermark</span> <span style="color: #660033; font-weight: bold;">$false</span> <span style="color: #000066;">-Animation</span> <span style="color: #660033; font-weight: bold;">$false</span> <span style="color: #333;">&#40;</span><br />
&nbsp; &nbsp;DataSeries $<span style="color: #333;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; 1..<span style="color: #333;">&#40;</span><span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">Random</span></span> <span style="color: #000066;">-min</span> <span style="color: #cc66cc;">3</span> <span style="color: #000066;">-max</span> <span style="color: #cc66cc;">6</span><span style="color: #333;">&#41;</span> <span style="color: #66cc66;">|</span> ForEach<span style="color: #66cc66;">-</span>Object &nbsp;<span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DataPoint <span style="color: #000066;">-YValue</span> <span style="color: #333;">&#40;</span><span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">Random</span></span> <span style="color: #cc66cc;">100</span><span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #333;">&#41;</span><br />
<span style="color: #333;">&#41;</span> <span style="color: #66cc66;">|</span> <span style="color: #0066cc; font-style: italic;">Out-<span style="font-style: normal;">BootsImage</span></span> VisiFire<span style="color: #66cc66;">-</span>BootsImage.<span style="color: #003366;">jpg</span> <span style="color: #66cc66;">|</span>ForEach<span style="color: #66cc66;">-</span>Object <span style="color: #333;">&#123;</span> <br />
&nbsp; &nbsp;<span style="color: #0066cc; font-style: italic;">Send-<span style="font-style: normal;">FTP</span></span> HuddledMasses.<span style="color: #003366;">org</span> <span style="color: #660033; font-weight: bold;">$credential</span> <span style="color: #000066;">-LocalFile</span> <span style="color: #660033; font-weight: bold;">$_</span> <span style="color: #000066;">-Remotefile</span> <span style="color: #009900;">&quot;$imgPath/$($_.Name)&quot;</span> <br />
&nbsp; &nbsp;<span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>Windows.<span style="color: #003366;">Clipboard</span><span style="color: #333;">&#93;</span></span>::<span style="color: #003366;">SetText</span><span style="color: #333;">&#40;</span> <span style="color: #009900;">&quot;!http://huddledmasses.org/images/PowerBoots/$($_.Name)!&quot;</span> <span style="color: #333;">&#41;</span><br />
<span style="color: #333;">&#125;</span><br />
<br />
StackPanel <span style="color: #000066;">-Margin</span> <span style="color: #009900;">&quot;10,5,10,5&quot;</span> $<span style="color: #333;">&#40;</span> <br />
&nbsp; &nbsp;Label <span style="color: #009900;">&quot;Please enter your name:&quot;</span><br />
&nbsp; &nbsp;StackPanel <span style="color: #000066;">-Orientation</span> Horizontal $<span style="color: #333;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; TextBox <span style="color: #000066;">-OutVariable</span> global:textbox <span style="color: #000066;">-Width</span> <span style="color: #cc66cc;">150</span> <span style="color: #000066;">-On_KeyDown</span> <span style="color: #333;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666699; font-weight: bold;">if</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$_</span>.<span style="color: #003366;">Key</span> <span style="color: #000066;">-eq</span> <span style="color: #009900;">&quot;Return&quot;</span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066cc; font-style: italic;">Write-<span style="font-style: normal;">Output</span></span> <span style="color: #660033; font-weight: bold;">$textbox</span><span style="color: #333;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #333;">&#93;</span>.<span style="color: #003366;">Text</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #660033; font-weight: bold;">$BootsWindow</span>.<span style="color: #003366;">Close</span><span style="color: #333;">&#40;</span><span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; Button <span style="color: #009900;">&quot;Ok&quot;</span> <span style="color: #000066;">-Padding</span> <span style="color: #009900;">&quot;5,0,5,0&quot;</span> <span style="color: #000066;">-Margin</span> <span style="color: #009900;">&quot;2,0,0,0&quot;</span> <span style="color: #000066;">-On_Click</span> <span style="color: #333;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0066cc; font-style: italic;">Write-<span style="font-style: normal;">Output</span></span> <span style="color: #660033; font-weight: bold;">$textbox</span><span style="color: #333;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #333;">&#93;</span>.<span style="color: #003366;">Text</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #660033; font-weight: bold;">$BootsWindow</span>.<span style="color: #003366;">Close</span><span style="color: #333;">&#40;</span><span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #333;">&#41;</span><br />
<span style="color: #333;">&#41;</span> <span style="color: #66cc66;">|</span> <span style="color: #0066cc; font-style: italic;">Out-<span style="font-style: normal;">BootsImage</span></span> BootsImage<span style="color: #66cc66;">-</span>Screenshot.<span style="color: #003366;">jpg</span> <span style="color: #66cc66;">|</span> ForEach<span style="color: #66cc66;">-</span>Object <span style="color: #333;">&#123;</span> <br />
&nbsp; &nbsp;<span style="color: #0066cc; font-style: italic;">Send-<span style="font-style: normal;">FTP</span></span> HuddledMasses.<span style="color: #003366;">org</span> <span style="color: #660033; font-weight: bold;">$credential</span> <span style="color: #000066;">-LocalFile</span> <span style="color: #660033; font-weight: bold;">$_</span> <span style="color: #000066;">-Remotefile</span> <span style="color: #009900;">&quot;$imgPath/$($_.Name)&quot;</span> <br />
&nbsp; &nbsp;<span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>Windows.<span style="color: #003366;">Clipboard</span><span style="color: #333;">&#93;</span></span>::<span style="color: #003366;">SetText</span><span style="color: #333;">&#40;</span> <span style="color: #009900;">&quot;!http://huddledmasses.org/images/PowerBoots/$($_.Name)!&quot;</span> <span style="color: #333;">&#41;</span><br />
<span style="color: #333;">&#125;</span><br />
&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/powerboots-output-graphs-to-images-from-powershell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PowerBoots 0.0.4 &#8211; Tab Completion &#8211; Visifire</title>
		<link>http://huddledmasses.org/powerboots-tab-completion-visifire/</link>
		<comments>http://huddledmasses.org/powerboots-tab-completion-visifire/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 03:47:25 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Charts]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[PowerBoots]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Visifire]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/?p=1008</guid>
		<description><![CDATA[This is the fourth release of the PowerBoots module for PowerShell 2 (Download &#8211; 7z). PowerBoots is a framework for creating WPF GUIs from PowerShell, and this latest release brings a couple of bug fixes and two new features. Now with tab completion The biggest change in PowerBoots 0.0.4 is that tab-completion for parameters works [...]]]></description>
			<content:encoded><![CDATA[	<p>This is the fourth release of the <a href="http://huddledmasses.org/powerboots/">PowerBoots module</a> for PowerShell 2 (<a href="http://HuddledMasses.org/downloads/PowerBoots/PowerBoots.0.0.4.0.zip">Download</a> &#8211; <a href="http://HuddledMasses.org/downloads/PowerBoots/PowerBoots.0.0.4.0.7z">7z</a>).  PowerBoots is a framework for creating <span class="caps">WPF</span> GUIs from PowerShell, and this latest release brings a couple of bug fixes and two new features.</p>

	<h3>Now with tab completion</h3>

	<p>The biggest change in PowerBoots 0.0.4 is that tab-completion for parameters works in the shell. </p>

	<p class="dem1">Behind the scenes what has happened is that I&#8217;ve discovered that in the current CTP3 release of PowerShell 2, Dynamic Parameter sets are not handled correctly for aliases, and the Get-Command for aliases of functions doesn&#8217;t return the same set of parameters as it does on the function itself.  The result is that Tab-Completion for dynamic parameters doesn&#8217;t work on aliases (neither the built-in tab completion, nor <a href="http://thepowershellguy.com/blogs/posh/pages/powertab-v2-alpha-1.aspx">MoW&#8217;s PowerTab</a>).  I <a href="https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=397832&#38;SiteID=99" title="please vote">wrote up a bug</a> against that, but I also found that I can work around it by creating hundreds of functions (all pointed at the same script-block), instead of hundreds of aliases (all pointed at the same function).</p>

	<h4>PowerBoots produces functions instead aliases</h4>

	<p>This means the PowerBoots commands show up by default when you run Get-Command. Incidentally, this means that the <em>first</em> time you run Get-Command after you <code>Import-Module PowerBoots</code> you incur a huge penalty (17 seconds on my machine) while Get-Command caches all the dynamic parameter information about the functions. <strong>NOTE:</strong> because of the DynamicParam bug, I&#8217;ve ditched aliases altogether for this particular project and am generating two functions for each element/type in PowerBoots: the full New-Namespace.Type version, and a &#8220;Type&#8221; alias when possible.  Trust me when I say: &#8220;it&#8217;s worth it&#8221; ... with the backing scriptblock, there&#8217;s virtually no difference between the two approches in terms of resources (other than the aforementions hit on Get-Command).</p>

	<h3>Now with more controls</h3>

	<p>The second big change (and the one which I hope will have the biggest long-term impact) is that you can now import your own <span class="caps">WPF</span> control libraries into PowerBoots. This means that you can, for example, go get the open source <a href="http://www.visifire.com/">Visifire</a> charting library, extract their WPFVisifire.Charts library into your PowerShell folder, and use it like so: </p>

	<div class="posh code posh" style="font-family:monospace;"><br />
<span style="color: #0066cc; font-style: italic;">Add-<span style="font-style: normal;">BootsContentProperty</span></span> <span style="color: #009900;">'DataPoints'</span>, <span style="color: #009900;">'Series'</span><br />
<span style="color: #0066cc; font-style: italic;">Add-<span style="font-style: normal;">BootsFunction</span></span> <span style="color: #000066;">-Assembly</span> <span style="color: #009900;">&quot;~\Documents\WindowsPowershell\Libraries\WPFVisifire.Charts.dll&quot;</span><br />
<br />
Chart <span style="color: #000066;">-Width</span> <span style="color: #cc66cc;">200</span> <span style="color: #000066;">-Height</span> <span style="color: #cc66cc;">150</span> <span style="color: #000066;">-Theme</span> Theme3 <span style="color: #333;">&#40;</span><br />
&nbsp; DataSeries $<span style="color: #333;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; DataPoint <span style="color: #000066;">-YValue</span> <span style="color: #333;">&#40;</span><span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">Random</span></span> <span style="color: #cc66cc;">100</span><span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; DataPoint <span style="color: #000066;">-YValue</span> <span style="color: #333;">&#40;</span><span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">Random</span></span> <span style="color: #cc66cc;">100</span><span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; DataPoint <span style="color: #000066;">-YValue</span> <span style="color: #333;">&#40;</span><span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">Random</span></span> <span style="color: #cc66cc;">100</span><span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; DataPoint <span style="color: #000066;">-YValue</span> <span style="color: #333;">&#40;</span><span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">Random</span></span> <span style="color: #cc66cc;">100</span><span style="color: #333;">&#41;</span><br />
&nbsp; <span style="color: #333;">&#41;</span><br />
<span style="color: #333;">&#41;</span> <span style="color: #66cc66;">|</span> Boots <span style="color: #000066;">-Title</span> <span style="color: #009900;">&quot;Sample, Theme 3&quot;</span><br />
&nbsp;</div>

<span id="more-1008"></span>

	<p><img src="http://huddledmasses.org/images/PowerBoots/Visifire3.png" align="right" alt="" width="230" height="206" /></p>

	<p>The main thing required to add new types to PowerBoots is to call Add-BootsFunction and pass it a Type or an Assembly &#8230; however, in order to get the nice clean syntax, and pipeline support for the &#8220;content&#8221; property (without having to specify the parameter name), we have to know which properties should be the default. PowerBoots has special handling for &#8216;Content&#8217;, &#8216;Child&#8217;, &#8216;Children&#8217;, &#8216;Items&#8217;, &#8216;Blocks&#8217; and &#8216;Inlines&#8217; which are the properties used by the various content models of the built-in <span class="caps">WPF</span> controls. I also added &#8216;GradientStops&#8217; to make it easier to work with the GradientBrushes. But Visifire (and other third-party controls) may not follow this very well, so in order to get the simple syntax for Visifire that you see here, I modified PowerBoots so that &#8216;DataPoints&#8217; and &#8216;Series&#8217; would be added as Content properties.  </p>

	<p><img src="http://huddledmasses.org/images/PowerBoots/Visifire2.png" align="left" alt="" width="232" height="208" /></p>

	<p>Now, I&#8217;ve added functions to allow you to Get, Add, or Remove from the collection of these default property names &#8230; so you can call <code>Add-BootsContentProperty</code> to add to the list of property names which should be treated as default properties.  You can also list them, and remove from the list. You should use these features with care, because if you have two default properties on the same object, you&#8217;ll probably have problems.  <img src='http://huddledmasses.org/wordpress/wp-includes/' alt=';)' class='wp-smiley' />   There&#8217;s no need to worry about adding duplicate names though, so if you want to write a PowerBoots-based module to, say, make charting easier &#8230; you could just require PowerBoots, and then call <code>Add-BootsContentProperty</code> and add the types you wanted functions for &#8230; and <strong>then</strong> add your customized functions.</p>

	<h2>Visifire &#8230; Slick Charting!</h2>

	<p>I&#8217;ve been meaning to write a whole post dedicated to Visifire and what it can do &#8212; even the screenshots you&#8217;re seeing here don&#8217;t really do it justice. It has very nice configureable mouse-over tooltips, all the chart elements are interactive, you can add hyperlinks to data points, or manually handle events like MouseEnter, and MouseDown/Up/Click with a simple scriptblock, and you can even add context menus, text input, etc.  <img src="http://huddledmasses.org/images/PowerBoots/Visifire-BootsIsNew.png" align="right" alt="" width="176" height="194" /> There&#8217;s a <a href="http://www.visifire.com/silverlight_charts_gallery.php">really good silverlight graph gallery</a> on their site &#8212; pretty much anything you see there, you can do in Visifire &#8212; And now, you can do it all from PowerShell, easily.  This is actually why I&#8217;ve been holding off writing about it, because their default syntax is a bit of a pain to work with, especially from PowerShell, with all the <code>New-Object</code> calls, over and over.</p>

	<p>PowerBoots makes working with Visifire charts from PowerShell <strong>much</strong> easier, but you still have to specifically create the DataSeries and DataPoints, even if you don&#8217;t want to specify any parameters for them.  If I keep using the Visifire stuff, I&#8217;ll eventually have to create a New-DataSeries function along the lines of Select-Object: taking a hashtable to define the values for the DataPoint, like <code>ls | New-DataSeries @{YValue={$_.Length}; AxisXLabel={$_.Name}}</code> or something.  In the meantime, to create the graph on the right, you need to do something like this:</p>

	<div class="posh code posh" style="font-family:monospace;"><br />
<span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$tk</span> &nbsp; &nbsp;<span style="color: #66cc66;">=</span> <span style="color: #0066cc; font-style: italic;">Invoke-<span style="font-style: normal;">Http</span></span> get http:<span style="color: #66cc66;">//</span>google.<span style="color: #003366;">com</span><span style="color: #66cc66;">/</span>search <span style="color: #000066;">-with</span> @<span style="color: #333;">&#123;</span>q<span style="color: #66cc66;">=</span><span style="color: #009900;">&quot;TCL Tk&quot;</span><span style="color: #333;">&#125;</span> <span style="color: #66cc66;">|</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066cc; font-style: italic;">Receive-<span style="font-style: normal;">Http</span></span> Text <span style="color: #009900;">&quot;//div[@id='ssb']//b[3]&quot;</span><br />
<span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$shoes</span> <span style="color: #66cc66;">=</span> <span style="color: #0066cc; font-style: italic;">Invoke-<span style="font-style: normal;">Http</span></span> get http:<span style="color: #66cc66;">//</span>google.<span style="color: #003366;">com</span><span style="color: #66cc66;">/</span>search <span style="color: #000066;">-with</span> @<span style="color: #333;">&#123;</span>q<span style="color: #66cc66;">=</span><span style="color: #009900;">&quot;Ruby Shoes&quot;</span><span style="color: #333;">&#125;</span> <span style="color: #66cc66;">|</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066cc; font-style: italic;">Receive-<span style="font-style: normal;">Http</span></span> Text <span style="color: #009900;">&quot;//div[@id='ssb']//b[3]&quot;</span><br />
<span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$boots</span> <span style="color: #66cc66;">=</span> <span style="color: #0066cc; font-style: italic;">Invoke-<span style="font-style: normal;">Http</span></span> get http:<span style="color: #66cc66;">//</span>google.<span style="color: #003366;">com</span><span style="color: #66cc66;">/</span>search <span style="color: #000066;">-with</span> @<span style="color: #333;">&#123;</span>q<span style="color: #66cc66;">=</span><span style="color: #009900;">&quot;PowerShell PowerBoots&quot;</span><span style="color: #333;">&#125;</span> <span style="color: #66cc66;">|</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066cc; font-style: italic;">Receive-<span style="font-style: normal;">Http</span></span> Text <span style="color: #009900;">&quot;//div[@id='ssb']//b[3]&quot;</span><br />
<br />
Chart <span style="color: #000066;">-MinHeight</span> <span style="color: #cc66cc;">100</span> <span style="color: #000066;">-MinWidth</span> <span style="color: #cc66cc;">100</span> <span style="color: #333;">&#40;</span><br />
&nbsp; &nbsp;DataSeries <span style="color: #000066;">-RenderAs</span> Bar $<span style="color: #333;">&#40;</span> <br />
&nbsp; &nbsp; &nbsp; DataPoint <span style="color: #000066;">-YValue</span> <span style="color: #660033; font-weight: bold;">$tk</span> &nbsp; &nbsp;<span style="color: #000066;">-AxisXLabel</span> Tk &nbsp; &nbsp;<span style="color: #000066;">-Href</span> http:<span style="color: #66cc66;">//</span>google.<span style="color: #003366;">com</span><span style="color: #66cc66;">/</span>search?q<span style="color: #66cc66;">=</span>TCL<span style="color: #66cc66;">+</span>Tk<br />
&nbsp; &nbsp; &nbsp; DataPoint <span style="color: #000066;">-YValue</span> <span style="color: #660033; font-weight: bold;">$shoes</span> <span style="color: #000066;">-AxisXLabel</span> Shoes <span style="color: #000066;">-Href</span> http:<span style="color: #66cc66;">//</span>google.<span style="color: #003366;">com</span><span style="color: #66cc66;">/</span>search?q<span style="color: #66cc66;">=</span>Ruby<span style="color: #66cc66;">+</span>Shoes<br />
&nbsp; &nbsp; &nbsp; DataPoint <span style="color: #000066;">-YValue</span> <span style="color: #660033; font-weight: bold;">$boots</span> <span style="color: #000066;">-AxisXLabel</span> Boots <span style="color: #000066;">-Href</span> http:<span style="color: #66cc66;">//</span>google.<span style="color: #003366;">com</span><span style="color: #66cc66;">/</span>search?q<span style="color: #66cc66;">=</span><span style="color: #003366; font-weight: bold;">PowerSHell</span><span style="color: #66cc66;">+</span>PowerBoots<br />
&nbsp; &nbsp;<span style="color: #333;">&#41;</span><br />
<span style="color: #333;">&#41;</span> <span style="color: #66cc66;">|</span> Boots<br />
&nbsp;</div>

	<p>The Invoke-Http and Receive-Http commands here are courtesy of <a href="http://poshcode.org/787">HttpRest</a>, and in this case, the XPath I&#8217;m using returns the total number of hits on Google for each search term&#8230;</p>

	<h4>What sorts of graphs and charts do you need?</h4>

	<p>Obviously Visifire lets you create all sorts of charts.  Everything from stock tracking, to computer uptimes, to file sizes &#8230; I&#8217;ve got a few examples here, but really I need a few more real-world ones.</p>

	<h4>How about a graph of your active directory structure?</h4>

	<p>We can show the number of users at each location (or in each group, or whatever) fairly easily from ActiveDirectory.  The interesting thing about this task, however, is that it lends itself to piping the data, instead of getting the data inside. If you don&#8217;t like this syntax (it <em>is</em> a little harder to read, I think) you can always write the whole AD stuff inside a $(evaluation) block for the content (the <code>-DataPoints</code> parameter) of the DataSeries function.</p>

	<p><img src="http://huddledmasses.org/images/PowerBoots/Visifire-Doughnut.png" alt="" width="332" height="354" /></p>

	<div class="posh code posh" style="font-family:monospace;"><br />
<span style="color: #660033; font-weight: bold;">$ad</span><span style="color: #66cc66;">=</span><span style="color: #0066cc; font-style: italic;">New-<span style="font-style: normal;">Object</span></span> DirectoryServices.<span style="color: #003366;">DirectorySearcher</span> <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">ADSI</span><span style="color: #333;">&#93;</span></span><span style="color: #009900;">''</span><br />
<span style="color: #666666; font-style: italic;"># Set a limit or TimeOut, PageSize lets us get more later</span><br />
<span style="color: #660033; font-weight: bold;">$ad</span>.<span style="color: #003366;">PageSize</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">200</span><br />
<br />
<span style="color: #666666; font-style: italic;"># ADSI field names are awful.</span><br />
<span style="color: #666666; font-style: italic;"># l = location, l=* returns only users with locations set</span><br />
<span style="color: #660033; font-weight: bold;">$ad</span>.<span style="color: #666699; font-weight: bold;">Filter</span> <span style="color: #66cc66;">=</span> <span style="color: #009900;">&quot;(&amp;(objectClass=Person)(l=*))&quot;</span> &nbsp;<br />
<span style="color: #660033; font-weight: bold;">$results</span> <span style="color: #66cc66;">=</span> <span style="color: #660033; font-weight: bold;">$ad</span>.<span style="color: #003366;">FindAll</span><span style="color: #333;">&#40;</span><span style="color: #333;">&#41;</span>.<span style="color: #003366;">GetEnumerator</span><span style="color: #333;">&#40;</span><span style="color: #333;">&#41;</span> <span style="color: #66cc66;">|</span> <span style="color: #666699; font-weight: bold;">ForEach</span> <span style="color: #333;">&#123;</span> <span style="color: #660033; font-weight: bold;">$_</span> <span style="color: #333;">&#125;</span><br />
<span style="color: #660033; font-weight: bold;">$users</span> &nbsp; <span style="color: #66cc66;">=</span> <span style="color: #660033; font-weight: bold;">$results</span> <span style="color: #66cc66;">|</span> <span style="color: #666699; font-weight: bold;">ForEach</span> <span style="color: #333;">&#123;</span> <span style="color: #660033; font-weight: bold;">$_</span>.<span style="color: #003366;">GetDirectoryEntry</span><span style="color: #333;">&#40;</span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># &quot;l&quot; is a PropertyValueCollection, use the first value</span><br />
<span style="color: #660033; font-weight: bold;">$users</span> <span style="color: #66cc66;">|</span> <span style="color: #0066cc; font-style: italic;">Group-<span style="font-style: normal;">Object</span></span> <span style="color: #333;">&#123;</span><span style="color: #660033; font-weight: bold;">$_</span>.<span style="color: #003366;">l</span><span style="color: #333;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #333;">&#93;</span><span style="color: #333;">&#125;</span> &nbsp;<span style="color: #66cc66;">|</span> <span style="color: #666699; font-weight: bold;">ForEach</span> <span style="color: #333;">&#123;</span> <br />
&nbsp; &nbsp;DataPoint <span style="color: #000066;">-YValue</span> <span style="color: #333;">&#40;</span><span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$_</span>.<span style="color: #003366;">Count</span><span style="color: #333;">&#41;</span> <span style="color: #000066;">-AxisXLabel</span> <span style="color: #660033; font-weight: bold;">$_</span>.<span style="color: #003366;">Name</span> <br />
<span style="color: #333;">&#125;</span><span style="color: #66cc66;">|</span> DataSeries <span style="color: #000066;">-RenderAs</span> Doughnut <span style="color: #66cc66;">|</span> <br />
&nbsp; &nbsp;Chart <span style="color: #000066;">-Height</span> <span style="color: #cc66cc;">300</span> <span style="color: #000066;">-Width</span> <span style="color: #cc66cc;">300</span> &nbsp;<span style="color: #66cc66;">|</span> <br />
&nbsp; &nbsp;Boots <span style="color: #000066;">-Title</span> <span style="color: #009900;">&quot;AD Users by Location&quot;</span><br />
&nbsp;</div>

	<h4>Or perhaps a graph showing the relative age and size of the files in a directory &#8230;</h4>

	<p>Bubble charts are a bit more complicated, just because there&#8217;s more stuff to set.  You should really have a look at the <a href="http://www.visifire.com/learn_silverlight_charts.php">Visifire Documentation</a>, because there are a metric boatload of options and parameters, and a lot of the parameters that are present on the DataPoint element are only used for certain charts (like ZValue, which is only for bubble charts).  </p>

	<p>In this example I also set the ToolTip text so you can see how to do it, and I store the DataSeries so that I can remove things from it later on&#8230; thought that would be a useful example  <img src='http://huddledmasses.org/wordpress/wp-includes/' alt=':)' class='wp-smiley' />  </p>

	<p><img src="http://huddledmasses.org/images/PowerBoots/Visifire-Bubble.png" alt="" width="580" height="581" /></p>

	<p>We handle clicks by writing the selected objects out (in this case, to the Remove-Item cmdlet), and then removing them from the graph so they can&#8217;t be selected again. If you run this script an play with it, you&#8217;ll notice that VisiFire charts automatically redraw when you remove an item, so if you click on the largest file(s), the rest of the files bubbles will grow&#8230;</p>

	<div class="posh code posh" style="font-family:monospace;"><br />
<span style="color: #660033;">ls</span> <span style="color: #66cc66;">|</span> <span style="color: #666699; font-weight: bold;">ForEach</span> <span style="color: #333;">&#123;</span> <br />
&nbsp; &nbsp;DataPoint <span style="color: #000066;">-YValue</span> <span style="color: #333;">&#40;</span><span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>DateTime<span style="color: #333;">&#93;</span></span>::<span style="color: #003366;">Now</span> <span style="color: #66cc66;">-</span> <span style="color: #660033; font-weight: bold;">$_</span>.<span style="color: #003366;">LastWriteTime</span><span style="color: #333;">&#41;</span>.<span style="color: #003366;">TotalDays</span> `<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">-ZValue</span> <span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$_</span>.<span style="color: #003366;">Length</span><span style="color: #66cc66;">/</span>1KB<span style="color: #333;">&#41;</span> `<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">-AxisXLabel</span> <span style="color: #660033; font-weight: bold;">$_</span>.<span style="color: #003366;">Name</span> <span style="color: #000066;">-Tag</span> <span style="color: #660033; font-weight: bold;">$_</span> `<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">-On_MouseLeftButtonUp</span> <span style="color: #333;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666699; font-weight: bold;">if</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$this</span>.<span style="color: #003366;">Tag</span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066cc; font-style: italic;">Write-<span style="font-style: normal;">Output</span></span> <span style="color: #660033; font-weight: bold;">$this</span>.<span style="color: #003366;">Tag</span>; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #660033; font-weight: bold;">$series</span><span style="color: #333;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #333;">&#93;</span>.<span style="color: #003366;">DataPoints</span>.<span style="color: #003366;">Remove</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$this</span><span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #333;">&#125;</span><br />
<span style="color: #333;">&#125;</span> <span style="color: #66cc66;">|</span> DataSeries <span style="color: #000066;">-RenderAs</span> Bubble <span style="color: #000066;">-OutVariable</span> series `<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">-ToolTipText</span> <span style="color: #009900;">&quot;#AxisXLabel<span style="color: #000099; font-weight: bold;">`n</span>Age: #YValue days, Size: #ZValue Kb&quot;</span> <span style="color: #66cc66;">|</span> <br />
&nbsp; &nbsp;Chart <span style="color: #000066;">-MinHeight</span> <span style="color: #cc66cc;">250</span> <span style="color: #000066;">-MinWidth</span> <span style="color: #cc66cc;">500</span> <span style="color: #000066;">-Theme</span> Theme3 <span style="color: #66cc66;">|</span> Boots <span style="color: #66cc66;">|</span> <span style="color: #0066cc; font-style: italic;">Remove-<span style="font-style: normal;">Item</span></span> <span style="color: #000066;">-Confirm</span><br />
&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/powerboots-tab-completion-visifire/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

