Question

I'm trying to use NVD3 with d3.js to make a simple sparkline. I've successfully created several sparklines with .csv data, but when I tried to use a different data set, it gave a very strange looking sparkline. See here. If I change the first data value from 92 to 0, it successfully shows the sparkline.

Is this a bug in NVD3 or am I doing something wrong?

Was it helpful?

Solution

The problem was that the y values were strings. I changed

monthlyData.push({x: data[i].Month, y: data[i].Data});

to

monthlyData.push({x: data[i].Month, y: +data[i].Data});

so that the y value becomes a number. Here's the updated version.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top