mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-21 18:53:19 +00:00
Add Plot function
This commit is contained in:
8
Examples/JustCharts/TargetData.csv
Normal file
8
Examples/JustCharts/TargetData.csv
Normal 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
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
RootModule = 'ImportExcel.psm1'
|
RootModule = 'ImportExcel.psm1'
|
||||||
|
|
||||||
# Version number of this module.
|
# Version number of this module.
|
||||||
ModuleVersion = '2.1.4'
|
ModuleVersion = '2.2.0'
|
||||||
|
|
||||||
# ID used to uniquely identify this module
|
# ID used to uniquely identify this module
|
||||||
GUID = '60dd4136-feff-401a-ba27-a84458c57ede'
|
GUID = '60dd4136-feff-401a-ba27-a84458c57ede'
|
||||||
|
|||||||
@@ -18,7 +18,12 @@ Add-Type -Path "$($PSScriptRoot)\EPPlus.dll"
|
|||||||
. $PSScriptRoot\Get-Range.ps1
|
. $PSScriptRoot\Get-Range.ps1
|
||||||
. $PSScriptRoot\plot.ps1
|
. $PSScriptRoot\plot.ps1
|
||||||
|
|
||||||
function New-Plot { [psplot]::new() }
|
function New-Plot {
|
||||||
|
[OutputType([PSPlot])]
|
||||||
|
param()
|
||||||
|
|
||||||
|
[psplot]::new()
|
||||||
|
}
|
||||||
|
|
||||||
function Import-Excel {
|
function Import-Excel {
|
||||||
param(
|
param(
|
||||||
|
|||||||
46
plot.ps1
46
plot.ps1
@@ -24,6 +24,21 @@ class PSPlot {
|
|||||||
$this.SetChartPosition($yCol)
|
$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) {
|
Plot($xValues,$yValues) {
|
||||||
|
|
||||||
$this.NewChart()
|
$this.NewChart()
|
||||||
@@ -33,6 +48,21 @@ class PSPlot {
|
|||||||
|
|
||||||
$this.AddDataToSheet($xCol,$yCol,'x','y',$xValues,$yValues)
|
$this.AddDataToSheet($xCol,$yCol,'x','y',$xValues,$yValues)
|
||||||
$this.AddSeries($xCol,$yCol,$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)
|
$this.SetChartPosition($yCol)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,6 +121,18 @@ class PSPlot {
|
|||||||
$Series=$this.chart.Series.Add($yRange,$xRange)
|
$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) {
|
hidden [string]GetNextColumnName($columnName) {
|
||||||
return $this.GetColumnName($this.GetColumnNumber($columnName)+1)
|
return $this.GetColumnName($this.GetColumnNumber($columnName)+1)
|
||||||
}
|
}
|
||||||
@@ -144,6 +186,10 @@ class PSPlot {
|
|||||||
$this.chart.SetSize($width, $height)
|
$this.chart.SetSize($width, $height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Title($title) {
|
||||||
|
$this.chart.Title.Text = $title
|
||||||
|
}
|
||||||
|
|
||||||
Show() {
|
Show() {
|
||||||
$this.pkg.Save()
|
$this.pkg.Save()
|
||||||
$this.pkg.Dispose()
|
$this.pkg.Dispose()
|
||||||
|
|||||||
Reference in New Issue
Block a user