From fd1776432c35ee50c1f19280b1ed15bf0a9837c8 Mon Sep 17 00:00:00 2001 From: Doug Finke Date: Thu, 7 Apr 2016 21:42:38 -0400 Subject: [PATCH] More fluent for the api --- README.md | 15 +++++++++++++++ plot.ps1 | 14 ++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b92f958..f715afa 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,21 @@ iex (new-object System.Net.WebClient).DownloadString('https://raw.github.com/dfi # What's new +#### 4/7/2016 +Made more methods fluent +``` +$t=Get-Range 0 5 .2 + +$t2=$t|%{$_*$_} +$t3=$t|%{$_*$_*$_} + +(New-Plot). + Plot($t,$t, $t,$t2, $t,$t3). + SetChartPosition("i"). + SetChartSize(500,500). + Title("Hello World"). + Show() +``` #### 3/31/2016 * Thanks to [redoz](https://github.com/redoz) Multi Series Charts are now working diff --git a/plot.ps1 b/plot.ps1 index bb15b52..05b193c 100644 --- a/plot.ps1 +++ b/plot.ps1 @@ -122,9 +122,11 @@ class PSPlot { return $this } - SetChartPosition($yCol) { + [PSPLot] SetChartPosition($yCol) { $columnNumber = $this.GetColumnNumber($yCol)+1 - $this.chart.SetPosition(1,0,$columnNumber,0) + $this.chart.SetPosition(1,0,$columnNumber,0) + + return $this } AddSeries($xCol,$yCol,$yValues) { @@ -194,12 +196,16 @@ class PSPlot { $this.SetChartSize(300,300) } - SetChartSize([int]$width,[int]$height){ + [PSPlot] SetChartSize([int]$width,[int]$height){ $this.chart.SetSize($width, $height) + + return $this } - Title($title) { + [PSPlot] Title($title) { $this.chart.Title.Text = $title + + return $this } Show() {