The graph area can't be negative

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
sahmad
Posts: 4
Joined: Wed Dec 20, 2023 1:31 pm

The graph area can't be negative

Post by sahmad » Wed Dec 20, 2023 1:41 pm

I have a ViewXY chart that ends up having a high number of x-axes. As a result the margins become too large and render the graph area negative. The chart area is not shown.

If I try to set

Code: Select all

Chart.ViewXY.AxisLayout.AutoAdjustMargins = false;
The chart is shown but not all axes can be visible.

Is there a way to have scrolling on all the x-axes? Or any other way to set a limit on the graph area?

ArctionKestutis
Posts: 555
Joined: Mon Mar 14, 2016 9:22 am

Re: The graph area can't be negative

Post by ArctionKestutis » Thu Dec 21, 2023 8:55 am

There few thing you can do to resolve issue:

1) try to reduce gap between segment, which should increase segment size (e.g. _chart.ViewXY.AxisLayout.SegmentsGap = 0;)

2) Change Y-axes layout. For example, you can use segment layout (_chart.ViewXY.AxisLayout.YAxesLayout = YAxesLayout.Segmented) with multiple Y-axes in single segment. See User Manual chapter 6.1.2.3 Segmented and Demo's ExampleYAxesLayouts.

3) Add scrollable control in your application, where Chart should be added. This will allow to increase height of chart, where scrolling bar helps you to see/find you desired y-axis.. In WPF it would be ScrollViewer, while in WinForms Scrollable Panel could be also created.

Hope this helps.

sahmad
Posts: 4
Joined: Wed Dec 20, 2023 1:31 pm

Re: The graph area can't be negative

Post by sahmad » Thu Dec 21, 2023 10:45 am

Thanks for getting back to me.

changing the segments gap did not change anything.

And just to clarify, I only have 1 Y-axis but I have around 20 X-axes.

Is there a possibility to have scrolling over the x axes only? such that the graph area remains fixed?

At the moment I can adjust

Code: Select all

Chart.ViewXY.Margins
but that still cuts out several X-axes from the view.

ArctionKestutis
Posts: 555
Joined: Mon Mar 14, 2016 9:22 am

Re: The graph area can't be negative

Post by ArctionKestutis » Thu Dec 21, 2023 4:20 pm

You can disable X-Axis auto-placement

Code: Select all

_chart.ViewXY.AxisLayout.XAxisAutoPlacement = XAxisAutoPlacement.Off;
and then use Axis.Position property accordingly (Position percentage relatively to Height of GraphArea).
If you want, you can pack them all to single horizontal line.

sahmad
Posts: 4
Joined: Wed Dec 20, 2023 1:31 pm

Re: The graph area can't be negative

Post by sahmad » Thu Jan 04, 2024 3:10 pm

Hi,

Packing them to a single horizontal line will not be feasible. There are too many axes and it becomes hard to read.

Is it possible to not show the axis but still show its corresponding data in the graph? I'm thinking of allowing the user to select which axes to display on the chart, but have the chart itself show all the data.

Thanks

ArctionKestutis
Posts: 555
Joined: Mon Mar 14, 2016 9:22 am

Re: The graph area can't be negative

Post by ArctionKestutis » Thu Jan 04, 2024 3:48 pm

That is basically that I meant by 'packing': put all axis is same Position and then manipulate Axis.Visible property. It will hide/show only axis itself, but not data/series assigned to that axis.
Series has own Visible property, if you want to hide it temporally.

sahmad
Posts: 4
Joined: Wed Dec 20, 2023 1:31 pm

Re: The graph area can't be negative

Post by sahmad » Fri Jan 05, 2024 12:04 pm

Ah yes ok I get what you mean. Think what I'm going to do now is to have all the data shown in the chart but only show number of x-axes up to a defined limit. All series will be plotted but not all x-axes will be visible. I'll allow the user to select which x-axes are visible up to the limit.

Correct me if I'm wrong, but that would mean that the Series.Visible = true, but I would only have to set

Code: Select all

_chart.ViewXY.XAxes[i].Visible = false
to ensure that the series is shown in the chart but not the x-axis?

Thanks!

ArctionKestutis
Posts: 555
Joined: Mon Mar 14, 2016 9:22 am

Re: The graph area can't be negative

Post by ArctionKestutis » Sun Jan 07, 2024 11:03 am

yes, it is correct.

Post Reply