go-chart icon indicating copy to clipboard operation
go-chart copied to clipboard

error: nan y-range delta

Open 5k3105 opened this issue 7 years ago • 11 comments

Could you explain what this means?

Grafana can read the field - float64.

code is here: https://github.com/5k3105/genchart

5k3105 avatar Mar 30 '17 01:03 5k3105

we

It ran correctly last night once for some reason but checking this morning, it's not working.

environmental pressure humidity This is what it looks like when I coment out that range error check.

5k3105 avatar Mar 30 '17 16:03 5k3105

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?

wcharczuk avatar Apr 02 '17 01:04 wcharczuk

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]]

5k3105 avatar Apr 02 '17 01:04 5k3105

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

5k3105 avatar Apr 14 '17 18:04 5k3105

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 avatar Apr 27 '17 16:04 danielbk18

@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 avatar Apr 27 '17 17:04 wcharczuk

@wcharczuk Thanks! It's working now.

danielbk18 avatar Apr 28 '17 16:04 danielbk18

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?

Raggaer avatar Jul 11 '17 01:07 Raggaer

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

5k3105 avatar Sep 30 '17 23:09 5k3105

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
					}
				}
			}

5k3105 avatar Dec 07 '17 01:12 5k3105

why the range estimator can not deal with a flat line?

xrefft avatar Sep 25 '20 09:09 xrefft