Control Set Chart errors

Support for all customers who have purchased a SAPIEN PowerShell Studio product license. This forum does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
smjadtnf707
Posts: 28
Joined: Sun May 19, 2019 7:26 pm

Control Set Chart errors

Post by smjadtnf707 » Sat Jun 08, 2019 6:46 pm

Hello,

Thank you for some great add-in like the fade-in and splash screen, and the performance charts.

On one of the charts I get an error and I am not sure exactly how to correct:

Code: Select all

>> Debugging (MyFirstAPP.psproj) Project Script...
>> Platform: V5 64Bit (STA) (Elevated) (Forced)
>> Analyzing Script (Results in Tools Output panel)...
ERROR: The property 'Text' cannot be found on this object. Verify that the property exists and can be set.
MainForm.psf (385, 3): ERROR: At Line: 385 char: 3
ERROR: +             $ChartControl.Titles[$TitleIndex].Text = $Title
ERROR: +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
ERROR:     + FullyQualifiedErrorId : PropertyNotFound
ERROR:
ERROR: The property 'Text' cannot be found on this object. Verify that the property exists and can be set.
MainForm.psf (385, 3): ERROR: At Line: 385 char: 3
ERROR: +             $ChartControl.Titles[$TitleIndex].Text = $Title
ERROR: +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
ERROR:     + FullyQualifiedErrorId : PropertyNotFound
ERROR:
Some of your control and code you add are pretty complex so I don't really want to tweak it unless I know what to do to fix it.
Thank You,

Wayne

User avatar
davidc
Posts: 5878
Joined: Thu Aug 18, 2011 4:56 am

Re: Control Set Chart errors

Post by davidc » Mon Jun 10, 2019 8:15 am

Hello Wayne,

Thank you for reporting the issue. Which chart control set is producing the error?
David
SAPIEN Technologies, Inc.

User avatar
smjadtnf707
Posts: 28
Joined: Sun May 19, 2019 7:26 pm

Re: Control Set Chart errors

Post by smjadtnf707 » Tue Jun 11, 2019 7:11 pm

Hello,

Does this help?

Code: Select all

>> Running (MyFirstAPP.psproj) Project Script...
WARNING: "System.Windows.Interactivity" Assembly is not compatible with .NET 2.0 and Windows PowerShell V2.
WARNING: "Microsoft.GroupPolicy.Commands" Assembly is not compatible with .NET 2.0 and Windows PowerShell V2.
WARNING: "System.Windows.Forms.DataVisualization" Assembly is not compatible with .NET 2.0 and Windows PowerShell V2.
>> Platform: V5 64Bit (STA) (Elevated) (Forced)
>> Analyzing Script (Results in Tools Output panel)...
Transcript started, output file is C:\Temp\Transcript.txt
ERROR: The property 'Text' cannot be found on this object. Verify that the property exists and can be set.
MainForm.psf (375, 3): ERROR: At Line: 375 char: 3
ERROR: +             $ChartControl.Titles[$TitleIndex].Text = $Title
ERROR: +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
ERROR:     + FullyQualifiedErrorId : PropertyNotFound
ERROR:
ERROR: The property 'Text' cannot be found on this object. Verify that the property exists and can be set.
MainForm.psf (375, 3): ERROR: At Line: 375 char: 3
ERROR: +             $ChartControl.Titles[$TitleIndex].Text = $Title
ERROR: +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
ERROR:     + FullyQualifiedErrorId : PropertyNotFound
ERROR:
ERROR: The property 'Text' cannot be found on this object. Verify that the property exists and can be set.
MainForm.psf (375, 3): ERROR: At Line: 375 char: 3
ERROR: +             $ChartControl.Titles[$TitleIndex].Text = $Title
ERROR: +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
ERROR:     + FullyQualifiedErrorId : PropertyNotFound
ERROR:
ERROR: The property 'Text' cannot be found on this object. Verify that the property exists and can be set.
MainForm.psf (375, 3): ERROR: At Line: 375 char: 3
ERROR: +             $ChartControl.Titles[$TitleIndex].Text = $Title
ERROR: +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
ERROR:     + FullyQualifiedErrorId : PropertyNotFound
ERROR:

*** PowerShell Script finished. ***
>> Execution time: 00:55:39
>> Script Ended
>> Max. CPU: 33 %  Max. Memory: 257.32 MB
Seems to be error in this function:

Code: Select all

function Update-Chart
{
<#
	.SYNOPSIS
		This functions helps you plot points on a chart
	
	.DESCRIPTION
		Use the function to plot points on a chart or add more charts to a chart control
	
	.PARAMETER ChartControl
		The Chart Control you when to add points to
	
	.PARAMETER XPoints
		Set the X Axis Points. These can be strings or numerical values.
	
	.PARAMETER YPoints
		Set the Y Axis Points. These can be strings or numerical values.
	
	.PARAMETER XTitle
		Set the Title for the X Axis.
	
	.PARAMETER YTitle
		Set the Title for the Y Axis.
	
	.PARAMETER Title
		Set the Title for the chart.
	
	.PARAMETER ChartType
		Set the Style of the chart. See System.Windows.Forms.DataVisualization.Charting.SeriesChartType Enum
	
	.PARAMETER SeriesIndex
		Set the settings of a particular Series and corresponding ChartArea
	
	.PARAMETER TitleIndex
		Set the settings of a particular Title
	
	.PARAMETER SeriesName
		Set the settings of a particular Series using its name and corresponding ChartArea.
		The Series will be created if not found.
		If SeriesIndex is set, it will replace the Series' name if the Series does not exist
	
	.PARAMETER Enable3D
		The chart will be rendered in 3D.
	
	.PARAMETER Disable3D
		The chart will be rendered in 2D.
	
	.PARAMETER AppendNew
		When this switch is used, a new ChartArea is added to Chart Control.
	
	.NOTES
		Additional information about the function.
	
	.LINK
		http://www.sapien.com/blog/2011/05/05/primalforms-2011-designing-charts-for-powershell/
#>
	
	param
	(
		[Parameter(Mandatory = $true,
				   Position = 1)]
		[ValidateNotNull()]
		[System.Windows.Forms.DataVisualization.Charting.Chart]
		$ChartControl,
		[Parameter(Mandatory = $true,
				   Position = 2)]
		[ValidateNotNull()]
		$XPoints,
		[Parameter(Mandatory = $true,
				   Position = 3)]
		$YPoints,
		[Parameter(Mandatory = $false,
				   Position = 4)]
		[string]
		$XTitle,
		[Parameter(Mandatory = $false,
				   Position = 5)]
		[string]
		$YTitle,
		[Parameter(Mandatory = $false,
				   Position = 6)]
		[string]
		$Title,
		[Parameter(Mandatory = $false,
				   Position = 7)]
		[System.Windows.Forms.DataVisualization.Charting.SeriesChartType]
		$ChartType,
		[Parameter(Mandatory = $false,
				   Position = 8)]
		$SeriesIndex = '-1',
		[Parameter(Mandatory = $false,
				   Position = 9)]
		$TitleIndex = '0',
		[Parameter(Mandatory = $false)]
		[string]
		$SeriesName = $null,
		[switch]
		$Enable3D,
		[switch]
		$Disable3D,
		[switch]
		$AppendNew
	)
	
	$ChartAreaIndex = 0
	if ($AppendNew)
	{
		$name = "ChartArea " + ($ChartControl.ChartAreas.Count + 1).ToString();
		$ChartArea = $ChartControl.ChartAreas.Add($name)
		$ChartAreaIndex = $ChartControl.ChartAreas.Count - 1
		
		$name = "Series " + ($ChartControl.Series.Count + 1).ToString();
		$Series = $ChartControl.Series.Add($name)
		$SeriesIndex = $ChartControl.Series.Count - 1
		
		$Series.ChartArea = $ChartArea.Name
		
		if ($Title)
		{
			$name = "Title " + ($ChartControl.Titles.Count + 1).ToString();
			$TitleObj = $ChartControl.Titles.Add($Title)
			$TitleIndex = $ChartControl.Titles.Count - 1
			$TitleObj.DockedToChartArea = $ChartArea.Name
			$TitleObj.IsDockedInsideChartArea = $false
		}
	}
	else
	{
		if ($ChartControl.ChartAreas.Count -eq 0)
		{
			$name = "ChartArea " + ($ChartControl.ChartAreas.Count + 1).ToString();
			[void]$ChartControl.ChartAreas.Add($name)
			$ChartAreaIndex = $ChartControl.ChartAreas.Count - 1
		}
		
		if ($ChartControl.Series.Count -eq 0)
		{
			if (-not $SeriesName)
			{
				$SeriesName = "Series " + ($ChartControl.Series.Count + 1).ToString();
			}
			
			$Series = $ChartControl.Series.Add($SeriesName)
			$SeriesIndex = $ChartControl.Series.Count - 1
			$Series.ChartArea = $ChartControl.ChartAreas[$ChartAreaIndex].Name
		}
		elseif ($SeriesName)
		{
			$Series = $ChartControl.Series.FindByName($SeriesName)
			
			if ($null -eq $Series)
			{
				if (($SeriesIndex -gt -1) -and ($SeriesIndex -lt $ChartControl.Series.Count))
				{
					$Series = $ChartControl.Series[$SeriesIndex]
					$Series.Name = $SeriesName
				}
				else
				{
					$Series = $ChartControl.Series.Add($SeriesName)
					$SeriesIndex = $ChartControl.Series.Count - 1
				}
				
				$Series.ChartArea = $ChartControl.ChartAreas[$ChartAreaIndex].Name
			}
			else
			{
				$SeriesIndex = $ChartControl.Series.IndexOf($Series)
				$ChartAreaIndex = $ChartControl.ChartAreas.IndexOf($Series.ChartArea)
			}
		}
	}
	
	if (($SeriesIndex -lt 0) -or ($SeriesIndex -ge $ChartControl.Series.Count))
	{
		$SeriesIndex = 0
	}
	
	$Series = $ChartControl.Series[$SeriesIndex]
	$Series.Points.Clear()
	$ChartArea = $ChartControl.ChartAreas[$Series.ChartArea]
	
	if ($Enable3D)
	{
		$ChartArea.Area3DStyle.Enable3D = $true
	}
	elseif ($Disable3D)
	{
		$ChartArea.Area3DStyle.Enable3D = $false
	}
	
	if ($Title)
	{
		if ($ChartControl.Titles.Count -eq 0)
		{
			
			#$name = "Title " + ($ChartControl.Titles.Count + 1).ToString();
			$TitleObj = $ChartControl.Titles.Add($Title)
			$TitleIndex = $ChartControl.Titles.Count - 1
			$TitleObj.DockedToChartArea = $ChartArea.Name
			$TitleObj.IsDockedInsideChartArea = $false
		}
		
		$ChartControl.Titles[$TitleIndex].Text = $Title
	}
	
	if ($ChartType)
	{
		$Series.ChartType = $ChartType
	}
	
	if ($XTitle)
	{
		$ChartArea.AxisX.Title = $XTitle
	}
	
	if ($YTitle)
	{
		$ChartArea.AxisY.Title = $YTitle
	}
	
	if ($XPoints -isnot [Array] -or $XPoints -isnot [System.Collections.IEnumerable])
	{
		$array = New-Object System.Collections.ArrayList
		$array.Add($XPoints)
		$XPoints = $array
	}
	
	if ($YPoints -isnot [Array] -or $YPoints -isnot [System.Collections.IEnumerable])
	{
		$array = New-Object System.Collections.ArrayList
		$array.Add($YPoints)
		$YPoints = $array
	}
	
	$Series.Points.DataBindXY($XPoints, $YPoints)
}
I apologize, it is the best I can do. It is a really complicated code for me to try and understand so I am pasting the whole function.
I think it is just a simple fix like a word or two.
I hope it is not my fault and I accidentally edited the code somehow. :o :oops:
Thank You,

Wayne

User avatar
davidc
Posts: 5878
Joined: Thu Aug 18, 2011 4:56 am

Re: Control Set Chart errors

Post by davidc » Wed Jun 12, 2019 7:34 am

Found the issue. Please replace the Update-Chart function's TitleIndex parameter declaration:

Code: Select all

[Parameter(Mandatory = $false,
		   Position = 9)]
$TitleIndex = '0',
with:

Code: Select all

[Parameter(Mandatory = $false,
		   Position = 9)]
[int]$TitleIndex = 0,
At some point the value was changed to a string '0' instead of 0. We will be sure to update the control set on our end.
David
SAPIEN Technologies, Inc.

User avatar
smjadtnf707
Posts: 28
Joined: Sun May 19, 2019 7:26 pm

Re: Control Set Chart errors

Post by smjadtnf707 » Wed Jun 12, 2019 7:44 pm

Thank you that fixed issue.
Thank You,

Wayne

User avatar
davidc
Posts: 5878
Joined: Thu Aug 18, 2011 4:56 am

Re: Control Set Chart errors

Post by davidc » Fri Jun 14, 2019 8:33 am

We released a new service build v5.6.165. The control sets and the helper functions have been fixed.
David
SAPIEN Technologies, Inc.