Add Plot function

This commit is contained in:
dfinke
2016-03-20 22:51:07 -04:00
parent 10789b6035
commit 42d0ad0378
4 changed files with 61 additions and 2 deletions

View File

@@ -0,0 +1,8 @@
Cost,Date,Name
1.1,1/1/2015,John
2.1,1/2/2015,Tom
5.1,1/2/2015,Dick
11.1,1/2/2015,Harry
7.1,1/2/2015,Jane
22.1,1/2/2015,Mary
32.1,1/2/2015,Liz
1 Cost Date Name
2 1.1 1/1/2015 John
3 2.1 1/2/2015 Tom
4 5.1 1/2/2015 Dick
5 11.1 1/2/2015 Harry
6 7.1 1/2/2015 Jane
7 22.1 1/2/2015 Mary
8 32.1 1/2/2015 Liz

View File

@@ -4,7 +4,7 @@
RootModule = 'ImportExcel.psm1'
# Version number of this module.
ModuleVersion = '2.1.4'
ModuleVersion = '2.2.0'
# ID used to uniquely identify this module
GUID = '60dd4136-feff-401a-ba27-a84458c57ede'

View File

@@ -18,7 +18,12 @@ Add-Type -Path "$($PSScriptRoot)\EPPlus.dll"
. $PSScriptRoot\Get-Range.ps1
. $PSScriptRoot\plot.ps1
function New-Plot { [psplot]::new() }
function New-Plot {
[OutputType([PSPlot])]
param()
[psplot]::new()
}
function Import-Excel {
param(

View File

@@ -24,6 +24,21 @@ class PSPlot {
$this.SetChartPosition($yCol)
}
Plot($yValues,[string]$options) {
$this.NewChart()
$xValues = 0..$yValues.Count
$xCol = 'A'
$yCol = 'B'
$this.AddDataToSheet($xCol,$yCol,'x','y',$xValues,$yValues)
$this.AddSeries($xCol,$yCol,$yValues)
$this.SetMarkerInfo($options)
$this.SetChartPosition($yCol)
}
Plot($xValues,$yValues) {
$this.NewChart()
@@ -33,6 +48,21 @@ class PSPlot {
$this.AddDataToSheet($xCol,$yCol,'x','y',$xValues,$yValues)
$this.AddSeries($xCol,$yCol,$yValues)
$this.SetChartPosition($yCol)
}
Plot($xValues,$yValues,[string]$options) {
$this.NewChart()
$xCol = 'A'
$yCol = 'B'
$this.AddDataToSheet($xCol,$yCol,'x','y',$xValues,$yValues)
$this.AddSeries($xCol,$yCol,$yValues)
$this.SetMarkerInfo($options)
$this.SetChartPosition($yCol)
}
@@ -91,6 +121,18 @@ class PSPlot {
$Series=$this.chart.Series.Add($yRange,$xRange)
}
hidden SetMarkerInfo([string]$options) {
$c=$options.Substring(0,1)
$m=$options.Substring(1)
$cmap=@{r='red';g='green';b='blue';i='indigo';v='violet';c='cyan'}
$mmap=@{Ci='Circle';Da='Dash';di='diamond';do='dot';pl='plus';sq='square';tr='triangle'}
$this.chart.Series[0].Marker = $mmap.$m
$this.chart.Series[0].MarkerColor = $cmap.$c
$this.chart.Series[0].MarkerLineColor = $cmap.$c
}
hidden [string]GetNextColumnName($columnName) {
return $this.GetColumnName($this.GetColumnNumber($columnName)+1)
}
@@ -144,6 +186,10 @@ class PSPlot {
$this.chart.SetSize($width, $height)
}
Title($title) {
$this.chart.Title.Text = $title
}
Show() {
$this.pkg.Save()
$this.pkg.Dispose()