PowerShell Studio 2016 Missing label in Chart Control

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 7 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
PsCustomObject
Posts: 137
Last visit: Thu Mar 28, 2024 3:34 am

PowerShell Studio 2016 Missing label in Chart Control

Post by PsCustomObject »

As per subject I started playing around with the chart control and facing an issue displaying all label names, the chart has 2 series which I manually populate without the helper function but while data visualization works fine intervals are not.

Googling for this I've found it's kind of a common "issue" which is solved with the following code
  1. $Chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1
Just it does not work for me or at leat it seems PowerShell studio is simply ignoring the code which I've added to the form_load event.

For sure the issue is what's between the monitor and the chair but I could not figure out what it really is.

I've attached the a demo form I'm using the figure out things and any help would be highly appreciated.
Graph Demo.psf
(39.63 KiB) Downloaded 142 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: PowerShell Studio 2016 Missing label in Chart Control

Post by jvierra »

Hi HeloCheck - This might help.

Here is a demo of how to correctly manually build a horizontal bar chart.
There is no issue with the interval. That is residue from many years ago that was likely a bug at the time. The interval is always set to1 by default.
Here are two methods of building horizontal bar series and how we usually label them. Also how they are matched.

The AddsXY wants a left reference and a right ordinal or value:

$series.points.AddXY(100, 1000)

The first number can be a label but you must match series correctly

$series1.points.AddXY(100, 250)
$series2.points.AddXY(100, 350)


Or

$series1.points.AddXY('Step 100', 250)
$series2.points.AddXY('Step 100', 350)


By not doing this you are just skewing the labels and causing the cart to function strangely.

Se attached demo:
Attachments
Demo-SimpleBars.psf
(31.12 KiB) Downloaded 157 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: PowerShell Studio 2016 Missing label in Chart Control

Post by jvierra »

Here is a better view of what is happening.
Attachments
Demo-StackedBars.psf
(45.84 KiB) Downloaded 159 times
User avatar
PsCustomObject
Posts: 137
Last visit: Thu Mar 28, 2024 3:34 am

Re: PowerShell Studio 2016 Missing label in Chart Control

Post by PsCustomObject »

Most helpful as usual.

Yes I know that's an older bug(?) but it was around last time I had to deal with charts and thought it was still around.

Thanks for your example which clarified the whole thing.
This topic is 7 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked