esnet / react-timeseries-charts

Declarative and modular timeseries charting components for React
http://software.es.net/react-timeseries-charts
Other
865 stars 283 forks source link

Default min/max y-axis values for BandCharts #344

Open bradmontgomery opened 5 years ago

bradmontgomery commented 5 years ago

I'm using the BandChart (pulled from the current master branch), and when panning or zooming the chart I get a lot of these:

Error: <path> attribute d: Expected number, "…491151407752467,NaNL0.0296717327…".

For some reason it seems that the areaGenerator frequently produces NaNs for my data, all of which is between 0 and 1. I hacked together a solution for myself by providing default values for the yaxis of 0 and 1:

    const areaGenerator = area()
        .curve(curves[this.props.interpolation])
        .x(d => d.x0)
        .y0(d => d.y0 || 0)
        .y1(d => d.y1 || 1); 

Should there be a way to specify min/max values for the y axis here? Perhaps there's a better approach to this. If so, I'd be happy to help contribute.

In case it helps I'm constructing my data with something like this:

const series = new TimeSeries({
    name: "Data",
    columns: ['index', 'value', 'bands'],
    points: [
        ["1s-1438527040", 0.3, [0.2, 0.3, 0.4]],
        ...
   ]
 })
pjm17971 commented 5 years ago

I'm not following, but I'm interested in what's going on. What purpose do the default values serve? And by y axis are you meaning the y coordinate of the area chart?