esbullington / react-d3

Modular React charts made with d3.js
https://reactiva.github.io/react-d3-website/
MIT License
1.75k stars 179 forks source link

Failed propType: Invalid prop `width` of type String supplied to LineChart #327

Closed SylarRuby closed 8 years ago

SylarRuby commented 8 years ago

Warning: Failed propType: Invalid prop width of type string supplied to LineChart, expected number. Check the render method of MyComponent.

<LineChart
              legend={true}
              data={lineData}
              width='100%'
              height={400}
              viewBoxObject={{
                x: 0,
                y: 0,
                width: 500,
                height: 400
              }}
              title="Line Chart"
              yAxisLabel="Altitude"
              xAxisLabel="Elapsed Time (sec)"
              domain={{x: [,10], y: [-10,]}}
              gridHorizontal={true}
            />

How to go around this? If I set a number I lose the responsive on the width.

johnsoftek commented 8 years ago

Have you tried {width='100%'}?

SylarRuby commented 8 years ago

@johnsoftek Same issue:

...
width={'100%'}
...
yang-wei commented 8 years ago

Thanks for the report.

It's fix in the forked library. https://github.com/yang-wei/rd3/pull/22

If you don't want to use it you can see how to fix it and apply it in your own fork. Thanks @SylarRuby