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
Source: stackoverflow.com
Related Query
- how do i return http tags in map function react
- How to return only 1 item in an array in react using map function
- how to access vairables outside of map function in js and jsx in a React component
- How to loop inside map function using jsx format React JS
- How to return a React memoized callback from factory function
- How can I use an IIFE in the return function of a react component?
- How to return an http error in a react component?
- How do i correctly return in a map function
- How to use ES6 map function in React stateless component
- React / Javascript map function - return array
- How to use Bootstrap Modal inside map function in React Js to render indivisual elements?
- How do I return two functions in a function that renders as two components in react instead of the second function overwriting the first
- How to use map function on react state hook
- How to return text + icon from a function in React
- React : how to pass and array from inside a Function to the return (JSX)
- How to access data within map function for onClick in react
- How do you return function results to a React Component?
- React - How to select all checkboxes based on one without using the map function
- Using enzyme, How to find a child component in a component react if they are result of function return
- How to change the html meta tags with react function components
- How to return as many elements(html tags) from function as the number passed to the function is ? React
- How to make 3 column grid with map function react
- React - How to show skeleton placeholders until Array map function ended
- How to use map function with react router?
- How to return the result of " axios' POST request " from reducer function in react
- How Use images from javascript array in react using filter and map function
- Mixing tags and map function inside react conditional
- React How to fire onClick each from map function
- How to add if statement in the map function using react
- How to pass an object as props in a map function in react
More Query from same tag
- React, Formik, Yup: Validate order of array
- React.js setState function doesn't assign data
- JS spread operator workflow on React
- Pass props from <link > in a child component to another component
- Merging Objects Using Vanilla JavaScript
- Can you emulate the shift key being held before the event runs
- how write a type definition for a HoC using flow
- Passing ref through to hook issue
- can i use graphql in react without using Apollo?
- Using list item key to pass data to another component
- i am new to redux and react i am trying to update the nested state in REDUX store, but unable to sort it out
- return this returns undefined
- How do you use Jest to test img.onerror
- solidity and react - can't get manager
- How to fix Uncaught TypeError: Cannot read property 'getState' of undefined?
- React props normalization or computed property
- Conditionally changing a dynamically generated component in React
- Changing styles during clicking
- How to run ionic-react applications on real devices?
- Populate a map with an object / restructing
- How to include i18next locale files in ReactJS build
- Multiple url API in React
- How is it possible to show the menu of a chart with React Highcharts?
- How do I shallow test a react component wrapped in memo and withStyles?
- How to pass a react prop if it's deeply nested inside a JSON object?
- How to vertical align links and image inside <ul> <li>
- Filter data according to input from child Component
- How to append boolean type values in formdata?
- How to set up routing in ReactJS?
- Update element on updating react state array