import React from 'react'; import Indicator from './indicator'; import './table-view.less'; export default class TableView extends React.Component { render() { const ind = this.props.indicator; const data = ind.data; const colCount = data.columns.keys.length; const rowCount = data.rows.keys.length; // check if there is anything to render if (colCount === 0 || rowCount === 0) { return null; } // get the columns to render const colTitles = ind.tableColumns(); const rowTitles = ind.tableRows(); // calc the number of columns const colsCount = colTitles[colTitles.length - 1].length; return (
{ colTitles.map((colrow, index) => ( { colrow.map(c => ( )) } )) } { data.values.map((vals, index) => { vals.map((val, ind2) => ( )) } ) }
{ data.rows.variables.map(v =>
{v.name}
) }
{ data.columns.variables.map(v => v.name).join(', ') } {__('global.total')}
{ c.title }
{rowTitles[index]} {val}
); } } TableView.propTypes = { indicator: React.PropTypes.instanceOf(Indicator).isRequired };