PowerShell, through its object-oriented design, provides a flexible and powerful framework to build interactive shell commands. Lately, in order to produce quick&dirty graphs while working on Lokad, I came up with Format-Graph, a CmdLet that outputs a text-based graphics of curves extracted directly from the PowerShell pipeline.
For those who might be interested, the source-code of the Format-Graph CmdLet is freely available as a part of the Lokad OpenShell project. The class is stand-alone, you not need the rest of the Lokad OpenShell project to get it working.
The key idea behind the Format-Graph is the way to actually retrieve, from the pipeline, the values to be plotted. Indeed, if the Format-Graph was relying on some arbitrary strong-typed inputs (think of a class named Point); then this CmdLet would be pretty much useless. Indeed, using the Format-Graph would require some heavy input formatting to actually produce anything. Instead, Format-Graph leverages the .Net reflexion to extract the values from the pipeline.
Basically, Format-Graph takes a ValuePropertyName argument that is used to extract the actual double value from the specified property. For example, in the screenshot here above, I have used -ValuePropertyName:Value to extract the values from TimeValue objects.
Future development notes: Format-Graph does not provides any axis description for now. I have already included a LabelPropertyName argument as a placeholder (labels are just ignored for now); but I am unsure about the way to handle the X axis description at this point. Additionally, I am considering to (optionally) display some scaling information for the Y axis.