Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS Chart and NaN

Tags:

c#

mschart

I'm using MS Chart with C# and I'm having issues when I try to retrieve almost any meta values from the chart, all I am getting is NaN. Couple of examples...

void chart_CursorPositionChanged(object sender, CursorEventArgs e)
{
            double selectStart = e.NewSelectionStart;
            double selectEnd = e.NewSelectionEnd;
}

e.NewSelectionStart and e.NewSelectionEnd both show NaN for their values.

Another example...

chart.ChartAreas[0].AxisX.Maximum

is also NaN. However, if I set it to a value the chart properly reflects it. Any ideas what I'm doing wrong?

like image 368
Motie Mediator Avatar asked Mar 28 '26 20:03

Motie Mediator


1 Answers

It sounds like you might not be properly initializing chart.ChartAreas[0]: Have you set Cursor.IsUserSelectionEnabled to true?

chart.ChartAreas[0].CursorX.IsSelectionEnabled = true;

If you haven't enabled user selecting then the event will still fire when a user clicks and moves the mouse, but a selection won't take place.

As for

chart.ChartAreas[0].AxisX.Maximum == Double.NaN

This means that the chart will manage the margin itself.

like image 132
Guildencrantz Avatar answered Mar 31 '26 09:03

Guildencrantz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!