Closed paul1956 closed 1 year ago
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.
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.
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 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
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# 😌)?
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.
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.
Okay, as soon as I have time, I'll try to figure it out...
No rush I am on a 2 month holiday starting in Fiji ending in Vancouver in May.
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
.
The cause: 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.
@kirsan31 Thanks, it's perfect. I did try setting Axis.Minimum to Double.Epsilon before the fix but that didn't work.
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?