Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axis labels starts at -0 #33

Closed
paul1956 opened this issue Mar 15, 2023 · 12 comments
Closed

Axis labels starts at -0 #33

paul1956 opened this issue Mar 15, 2023 · 12 comments
Labels
bug Something isn't working

Comments

@paul1956
Copy link

The chart only has positive y values though some are very small 0.0000000001 and I do absolute on all the data values (there is a lot of math to get them including subtraction, I only care about 2.25 digits of precision ie.. X.0, X.025,X.5 and X.075) but I can't get rid of the - sign before the 0. Is there a way I should be setting the YAxis labels to prevent this? How is the YAxis starting value set/calculated?

@kirsan31
Copy link
Owner

Hi @paul1956
Yea it's a known problem with axes auto min \ max values due to floating point calculation. In your situation I think you can simply set axis Minimum to 0 in designer, or in code once.
More of it, I suggest not to use Auto min \ max values if you really not need them. Because their calculation is quite a costly operation.

@paul1956
Copy link
Author

Thanks. I don't need auto I just didn't know where to set a fixed value. I still create the graphs at runtime. Unless you have burning desire to fix this can be closed.

@kirsan31
Copy link
Owner

I don't need auto I just didn't know where to set a fixed value. I still create the graphs at runtime.

It's something like: chart1.ChartAreas[0].AxisY.Minimum = 0;

Unless you have burning desire to fix this can be closed.

😁

@kirsan31 kirsan31 added question Further information is requested wontfix This will not be worked on labels Mar 16, 2023
@paul1956
Copy link
Author

paul1956 commented Mar 16, 2023

@kirsan31 I think this is a bug, Below is chart initialization and AxixY.Minimum is set to 0 and is StartFromZero setting doesn't matter.

       With treatmentMarkersChartArea.AxisY
           Dim interval As Single = (TreatmentInsulinRow / 10).RoundSingle(3)
           .Interval = interval
           .IsInterlaced = False
           .IsMarginVisible = False
           .IsStartedFromZero = False
           With .LabelStyle
               .Font = labelFont
               .ForeColor = labelColor
               .Format = "{0.00}"
           End With
           .LineColor = Color.FromArgb(64, labelColor)
           With .MajorTickMark
               .Enabled = True
               .Interval = interval
               .LineColor = Color.FromArgb(64, labelColor)
           End With
           .Maximum = TreatmentInsulinRow
           .Minimum = 0
           .Title = "Delivered Insulin"
           .TitleFont = New Font(labelFont.FontFamily, 14)
           .TitleForeColor = labelColor
       End With

@kirsan31
Copy link
Owner

kirsan31 commented Mar 16, 2023

It's very strange...
About StartFromZero:

Gets or sets a flag which indicates whether the minimum value of the axis will be automatically set to zero if all data point values are positive. If there are negative data point values, the minimum value of the data points will be used.

Can you provide some repro project to I can debug this (if possible in c# 😌)?

@kirsan31 kirsan31 reopened this Mar 16, 2023
@kirsan31 kirsan31 removed question Further information is requested wontfix This will not be worked on labels Mar 16, 2023
@paul1956
Copy link
Author

The only project I have using the chart is my CareLink project, it does have sample data.
https://github.com/paul1956/CareLink
It has sample data under Start Here/Use Test Data
and the 2 tabs Running IOB and Treatment Details have the charts showing -0

I don't program in C# well enough to create a repo

If its too much work just forget it. The initialization code for the charts is very simple and I tried doing absolute value on all the Y values but it doesn't seem to matter.

@paul1956
Copy link
Author

paul1956 commented Mar 16, 2023

image
Here is what it looks like the Y axis plots the green line with black dots and the smallest value in the test data is 0.168.

@kirsan31
Copy link
Owner

Okay, as soon as I have time, I'll try to figure it out...

@paul1956
Copy link
Author

No rush I am on a 2 month holiday starting in Fiji ending in Vancouver in May.

@kirsan31 kirsan31 changed the title YAxis starts at -0 Axis labels starts at -0 Mar 18, 2023
@kirsan31 kirsan31 added the bug Something isn't working label Mar 18, 2023
@kirsan31
Copy link
Owner

kirsan31 commented Mar 18, 2023

I was able to reproduce the problem, we'll see what can be done...
As workaround you can set small positive value to axis Minimum.

kirsan31 added a commit that referenced this issue Mar 18, 2023
@kirsan31
Copy link
Owner

The cause:
image
I think it's related to https://devblogs.microsoft.com/dotnet/floating-point-parsing-and-formatting-improvements-in-net-core-3-0/

Will be fixed in 1.8.

@paul1956
Copy link
Author

@kirsan31 Thanks, it's perfect. I did try setting Axis.Minimum to Double.Epsilon before the fix but that didn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants