davidguttman / react-pivot

React-Pivot is a data-grid component with pivot-table-like functionality for data display, filtering, and exploration.
http://davidguttman.github.io/react-pivot/
1.05k stars 148 forks source link

How we can use dimenstions for array of objects inside. #63

Closed gmmurugan closed 6 years ago

gmmurugan commented 6 years ago

eg: [ { "firstName": "Francisco", "lastName": "Brekke", "state": "NY", "transactions": [{ "amount": "399.73", "date": "2012-02-02T08:00:00.000Z", "business": "Kozey-Moore", "name": "Checking Account 2297", "type": "deposit", "account": "82741327" }, { "amount": "399.73", "date": "2012-02-02T08:00:00.000Z", "business": "Kozey-Moore", "name": "Checking Account 2297", "type": "withdrawal", "account": "82741327" } ] } ]

and i want the dimensions to get type of transactions..

davidguttman commented 6 years ago

Sorry for the delay on this.

If the most granular level you're interested in (e.g. what you want to see when all dimensions are visible) are individual transactions, you'd want to transform the data before giving it to RP. Something like:

var transactions = []
people.forEach(function (person) {
  person.transactions.forEach(function (tx) {
    tx.firstName = person.firstName
    tx.lastName = person.lastName
    tx.state = person.state
    transactions.push(tx)
  })
})

Then you could just have a dimension type.