go-chart
go-chart copied to clipboard
error: nan y-range delta
Could you explain what this means?
Grafana can read the field - float64.
code is here: https://github.com/5k3105/genchart
It ran correctly last night once for some reason but checking this morning, it's not working.
This is what it looks like when I coment out that range error check.
nan range delta
means, for a given chart, either the x or y range has a x/0 difference between the min and max values. in order to draw a chart, you need the minimum and maximum to be different (otherwise it's a one dimensional line).
my sense looking at your chart is that there is a very very small difference (approaching zero) between the min and max of a single series.
are you mapping that series to the secondary y-axis?
Here are the values from the chart above that won't render:
[[24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6 24.6]]
[[834.4 834.4 834.5 834.5 834.4 834.4 834.4 834.5 834.4 834.4 834.5 834.3 834.3 834.3 834.3 834.4 834.3 834.4 834.2 834.2 834.2 834.3 834.2 834.3 834.2 834.3 834.2 834.3 834.3 834.3 834.3 834.2 834.2 834.2 834.3 834.1 834.3 834.3 834.2 834.2 834.3 834.3 834.1 834.2 834.2 834.1 834.1 834.2 834.1 834.1 834.1 834.1 834.1 834.1 834.1 834.1 834.1 834.1 834 834.1 834 834 834.1 834.1 834.2 834.1 834.2 834.1 834.2 834.2 834.2 834.1 834.1 834.2 834.2 834.2 834.1 834.2 834.2 834.2 834.2 834.3 834.2 834.3 834.2 834.3 834.2 834.3 834.3 834.3 834.4 834.4 834.3 834.2 834.3 834.2 834.3 834.2 834.2 834.3 834.3 834.3 834.3 834.3 834.4 834.4 834.4 834.3 834.4 834.3 834.3 834.4 834.4 834.4 834.4 834.4 834.4 834.4 834.4 834.4 834.3 834.4 834.4 834.4 834.3 834.4 834.3 834.3 834.3 834.4 834.6 834.4 834.4 834.5 834.5 834.4 834.4 834.4 834.4 834.4 834.5 834.4 834.4 834.4 834.5 834.4 834.5 834.5 834.5 834.6 834.5 834.5 834.5 834.5 834.5 834.6 834.5 834.7 834.5 834.7 834.5 834.6 834.6 834.5 834.5 834.6 834.6 834.6 834.5 834.5 834.5 834.6 834.5 834.5 834.6 834.6]]
It's the cabin humidity. It's sitting at 24.6 for the time range, so it's a flat line. The y-range check doesn't like it I guess. Is there a way to fix this?
Thanks
I'm also having this issue. In some cases my data would print a flat line, but instead go-chart does not print it, showing a white image. I also get the 'not a number y-range delta' error.
Is there a workaround to draw a chart with no delta between the values?
@danielbk18 the workaround is to manually set a y-axis range (usually continuous) with a small delta above and below the constant value. i can have the range estimator do this automatically, as well, but for now a manual range is the easiest way to get it to draw.
@wcharczuk Thanks! It's working now.
Any news on this? How can I render a flat line with a chart.TimeSeries
? Is manually adding a value the only solution to this?
I've added min max ranges like suggested yet it still does not render, all values are 0, and when compiled does not produce an error -- it produces a 5k file that will not display.
Changing it from TimeSeries to ContinuousSeries does not fix it.
updated code is here: https://github.com/5k3105/genchart/blob/master/main.go
Seems to fix this
if miny == maxy {
miny -= 0.05
maxy += 0.05
}
(chart.go):
} else if vp, isValuesProvider := s.(ValuesProvider); isValuesProvider {
seriesLength := vp.Len()
for index := 0; index < seriesLength; index++ {
vx, vy := vp.GetValues(index)
minx = math.Min(minx, vx)
maxx = math.Max(maxx, vx)
if seriesAxis == YAxisPrimary {
miny = math.Min(miny, vy)
maxy = math.Max(maxy, vy)
if miny == maxy {
miny -= 0.05
maxy += 0.05
}
} else if seriesAxis == YAxisSecondary {
minya = math.Min(minya, vy)
maxya = math.Max(maxya, vy)
if minya == maxya {
minya -= 0.05
maxya += 0.05
}
seriesMappedToSecondaryAxis = true
}
}
}
why the range estimator can not deal with a flat line?