React-vis: VerticalBarSeries is not rendering when passing x as a string

Created on 17 Jan 2018  路  3Comments  路  Source: uber/react-vis

I was trying to render this simple component

export default class extends React.Component{
    constructor(props){
        super(props);
    }
    render(){
        return(
            <XYPlot width={300} height={300}>
                <HorizontalGridLines />
                <VerticalGridLines />
                <VerticalBarSeries
                    data={[{x: 'winter', y: 10}, {x: 'spring', y: 100}, {x: 'summer', y: 10000}, {x: 'fall', y: 10}]}/>
                <XAxis />
                <YAxis />
            </XYPlot>
        );
    }
}

and it fails with this error
Error: <rect> attribute width: Expected length, "NaN"

my react-vis version is 1.8.2
and react version is 15.6.2

Most helpful comment

Hey @basilaiman I believe you need to add xType="ordinal" to your XYPlot, check out the scales section of the documentation (https://uber.github.io/react-vis/documentation/general-principles/scales-and-data) for more information.

All 3 comments

Hey @basilaiman I believe you need to add xType="ordinal" to your XYPlot, check out the scales section of the documentation (https://uber.github.io/react-vis/documentation/general-principles/scales-and-data) for more information.

Thank you, it works.
I think it should be added to the data format reference on the documentation
https://uber.github.io/react-vis/documentation/series-reference/bar-series

@basilaiman I tend to think community/driven docs tend to be best, so if you see a place where adding that information would don鈥檛 hesitate to file a PR

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wroughtec picture wroughtec  路  4Comments

mcnuttandrew picture mcnuttandrew  路  3Comments

JayFields picture JayFields  路  5Comments

zavrick picture zavrick  路  4Comments

samhogg picture samhogg  路  4Comments