score:0

Accepted answer

try adding return before keysarray.map((datas,indexs)=>{ you need to return inside map in order to get array.

currently you are getting array of null values.

from your code - you'll be getting 2d array. is that what you want !

score:0

you need to return from map as

return(
    <barchart width={600} height={300} data={data}
        margin={{top: 20, right: 30, left: 20, bottom: 5}}>
        <cartesiangrid strokedasharray="6 0"/>
        <xaxis datakey="name"/>
        <yaxis/>
        <tooltip/>
        <legend />


        {  data.map((e, i) => {

            if(i===0){
                console.log(e);
                return keysarray.map((datas,indexs)=>{
                    if(datas!=="name"){
                        console.log(indexs)
                        console.log(datas)
                        return (
                            <bar datakey={datas} stackid="a" fill={colors[indexs]} />
                        );

                    }
                })
            }


        }) }


    {/* <bar datakey="pv" stackid="a" fill="#8884d8" />
   <bar datakey="uv" stackid="a" fill="#82ca9d" />
   <bar datakey={keysarray[1]} stackid="a" fill={colors[0]} />    */}
    </barchart>
);

hope it helps


Related Query

More Query from same tag