|
|
@@ -34,71 +34,69 @@ class AggregateTableView extends React.Component {
|
|
|
}
|
|
|
|
|
|
// 无分组
|
|
|
- createTableBodyInNoGroups = (chartOption, themeConfig) => {
|
|
|
+ createTableBodyInNoGroups = (chartOption) => {
|
|
|
const { targetColumn, direction, statistics, data } = chartOption;
|
|
|
- const { targetStyle, statisticsStyle, cellStyle } = themeConfig;
|
|
|
if(direction === 'vertical') {
|
|
|
return <tbody>
|
|
|
- <tr>
|
|
|
- <th className='target-cell' rowSpan={`${statistics.length + 1}`} style={targetStyle}>{targetColumn.label}</th>
|
|
|
+ <tr className='row-target'>
|
|
|
+ <th className='cell-target' rowSpan={`${statistics.length + 1}`}>{targetColumn.label}</th>
|
|
|
</tr>
|
|
|
{
|
|
|
- statistics.map((s, i) => <tr key={i}>
|
|
|
- <td style={statisticsStyle}>{s.label}</td>
|
|
|
- <td style={cellStyle}>{data[s.name]}</td>
|
|
|
+ statistics.map((s, i) => <tr className='row-statistics' key={i}>
|
|
|
+ <td className='cell-statistics-key'>{s.label}</td>
|
|
|
+ <td className='cell-statistics-value'>{data[s.name]}</td>
|
|
|
</tr>)
|
|
|
}
|
|
|
</tbody>
|
|
|
}
|
|
|
return <tbody>
|
|
|
- <tr>
|
|
|
- <th className='target-cell' colSpan={`${statistics.length}`} style={targetStyle}>{targetColumn.label}</th>
|
|
|
+ <tr className='row-target'>
|
|
|
+ <th className='cell-target' colSpan={`${statistics.length}`}>{targetColumn.label}</th>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- { statistics.map((s, i) => <td key={i} style={statisticsStyle}>{s.label}</td>) }
|
|
|
+ { statistics.map((s, i) => <td className='cell-statistics-key' key={i}>{s.label}</td>) }
|
|
|
</tr>
|
|
|
- <tr>
|
|
|
- { statistics.map((s, i) => <td key={i} style={cellStyle}>{data[s.name]}</td>) }
|
|
|
+ <tr className='row-statistics'>
|
|
|
+ { statistics.map((s, i) => <td className='cell-statistics-value' key={i}>{data[s.name]}</td>) }
|
|
|
</tr>
|
|
|
</tbody>;
|
|
|
}
|
|
|
|
|
|
// 有一个分组
|
|
|
- createTableBodyInOneGroups = (chartOption, themeConfig) => {
|
|
|
+ createTableBodyInOneGroups = (chartOption) => {
|
|
|
const { targetColumn, direction, group1s, statistics, data } = chartOption;
|
|
|
- const { targetStyle, statisticsStyle, groupByStyle, cellStyle } = themeConfig;
|
|
|
if(direction === 'vertical') {
|
|
|
return <tbody>
|
|
|
- <tr>
|
|
|
- <td colSpan="2"></td>
|
|
|
- { group1s.map((g, i) => <td key={i} style={groupByStyle}>{g}</td>) }
|
|
|
+ <tr className='row-group'>
|
|
|
+ <td className='cell-empty' colSpan="2"></td>
|
|
|
+ { group1s.map((g, i) => <td className='cell-group' key={i}>{g}</td>) }
|
|
|
</tr>
|
|
|
- <tr>
|
|
|
- <th className='target-cell' rowSpan={`${statistics.length + 1}`} style={targetStyle}>{targetColumn.label}</th>
|
|
|
+ <tr className='row-target'>
|
|
|
+ <th className='cell-target' rowSpan={`${statistics.length + 1}`}>{targetColumn.label}</th>
|
|
|
</tr>
|
|
|
{
|
|
|
- statistics.map((s, si) => <tr key={si}>
|
|
|
- <td style={statisticsStyle}>{s.label}</td>
|
|
|
- { group1s.map((g1, gi) => <td key={gi} style={cellStyle}>{data[gi][s.name]}</td>) }
|
|
|
+ statistics.map((s, si) => <tr className='row-statistics' key={si}>
|
|
|
+ <td className='cell-statistics-key'>{s.label}</td>
|
|
|
+ { group1s.map((g1, gi) => <td className='cell-statistics-value' key={gi}>{data[gi][s.name]}</td>) }
|
|
|
</tr>)
|
|
|
}
|
|
|
</tbody>
|
|
|
}
|
|
|
return <tbody>
|
|
|
- <tr>
|
|
|
- <th className='target-cell' colSpan={`${statistics.length + 1}`} style={targetStyle}>{targetColumn.label}</th>
|
|
|
+ <tr className='row-target'>
|
|
|
+ <th className='cell-target' colSpan={`${statistics.length + 1}`}>{targetColumn.label}</th>
|
|
|
</tr>
|
|
|
- <tr>
|
|
|
- <td></td>
|
|
|
+ <tr className='row-statistics'>
|
|
|
+ <td className='cell-empty'></td>
|
|
|
{
|
|
|
- statistics.map((s, i) => <td key={i} style={statisticsStyle}>{s.label}</td>)
|
|
|
+ statistics.map((s, i) => <td className='cell-statistics-key' key={i}>{s.label}</td>)
|
|
|
}
|
|
|
</tr>
|
|
|
{
|
|
|
- group1s.map((g, gi) => <tr key={gi}>
|
|
|
- <td style={groupByStyle}>{g}</td>
|
|
|
+ group1s.map((g, gi) => <tr className='row-statistics' key={gi}>
|
|
|
+ <td className='cell-group'>{g}</td>
|
|
|
{
|
|
|
- statistics.map((s, si) => <td key={si} style={cellStyle}>{data[gi][s.name]}</td>)
|
|
|
+ statistics.map((s, si) => <td className='cell-statistics-value' key={si}>{data[gi][s.name]}</td>)
|
|
|
}
|
|
|
</tr>)
|
|
|
}
|
|
|
@@ -106,26 +104,25 @@ class AggregateTableView extends React.Component {
|
|
|
}
|
|
|
|
|
|
// 有两个分组
|
|
|
- createTableBodyInTwoGroups = (chartOption, themeConfig) => {
|
|
|
+ createTableBodyInTwoGroups = (chartOption) => {
|
|
|
const { targetColumn, direction, group1Name, group1s, group2s, statistics, data } = chartOption;
|
|
|
- const { targetStyle, statisticsStyle, groupByStyle, cellStyle } = themeConfig;
|
|
|
if(direction === 'vertical') {
|
|
|
return <tbody>
|
|
|
- <tr>
|
|
|
- <td colSpan="3"></td>
|
|
|
- {group1s.map((g, i) => <td key={i} style={groupByStyle}>{g}</td>)}
|
|
|
+ <tr className='row-group'>
|
|
|
+ <td className='cell-empty' colSpan="3"></td>
|
|
|
+ {group1s.map((g, i) => <td className='cell-group' key={i}>{g}</td>)}
|
|
|
</tr>
|
|
|
- <tr>
|
|
|
- <th className='target-cell' rowSpan={`${group2s.length * statistics.length + 1}`} style={targetStyle}>{targetColumn.label}</th>
|
|
|
+ <tr className='row-target'>
|
|
|
+ <th className='cell-target' rowSpan={`${group2s.length * statistics.length + 1}`}>{targetColumn.label}</th>
|
|
|
</tr>
|
|
|
{
|
|
|
group2s.map((g2, idx2) => {
|
|
|
- return statistics.map((s, si) => <tr key={si}>
|
|
|
- { si === 0 && <td rowSpan={`${statistics.length}`} style={groupByStyle}>{g2}</td>}
|
|
|
- <td style={statisticsStyle}>{s.label}</td>
|
|
|
+ return statistics.map((s, si) => <tr className='row-statistics' key={si}>
|
|
|
+ { si === 0 && <td className='cell-group' rowSpan={`${statistics.length}`}>{g2}</td>}
|
|
|
+ <td className='cell-statistics-key'>{s.label}</td>
|
|
|
{group1s.map((g1, idx1) => {
|
|
|
let values = data[idx1].data[idx2];
|
|
|
- return <td key={idx1} style={cellStyle}>{values[s.name]}</td>
|
|
|
+ return <td className='cell-statistics-value' key={idx1}>{values[s.name]}</td>
|
|
|
})}
|
|
|
</tr>)
|
|
|
})
|
|
|
@@ -133,24 +130,24 @@ class AggregateTableView extends React.Component {
|
|
|
</tbody>
|
|
|
}
|
|
|
return <tbody>
|
|
|
- <tr>
|
|
|
- <th className='target-cell' colSpan={direction === 'vertical' ? group1s.length + 3 : statistics.length * group2s.length + 1} style={targetStyle}>{targetColumn.label}</th>
|
|
|
+ <tr className='row-target'>
|
|
|
+ <th className='cell-target' colSpan={direction === 'vertical' ? group1s.length + 3 : statistics.length * group2s.length + 1}>{targetColumn.label}</th>
|
|
|
</tr>
|
|
|
- <tr>
|
|
|
- <td rowSpan={2}></td>
|
|
|
- { group2s.map((g, i) => <td colSpan={statistics.length} key={i} style={groupByStyle}>{g}</td>) }
|
|
|
+ <tr className='row-group'>
|
|
|
+ <td className='cell-empty' rowSpan={2}></td>
|
|
|
+ { group2s.map((g, i) => <td className='cell-group' colSpan={statistics.length} key={i}>{g}</td>) }
|
|
|
</tr>
|
|
|
- <tr>
|
|
|
- { group2s.map((g, gi) => statistics.map((s, si) => <td key={`${gi}-${si}`} style={statisticsStyle}>{s.label}</td>)) }
|
|
|
+ <tr className='row-statistics'>
|
|
|
+ { group2s.map((g, gi) => statistics.map((s, si) => <td className='cell-statistics-key' key={`${gi}-${si}`}>{s.label}</td>)) }
|
|
|
</tr>
|
|
|
{
|
|
|
data.map((d1, d1i) => {
|
|
|
let data2 = d1.data;
|
|
|
- return <tr key={d1i}>
|
|
|
- <td style={groupByStyle}>{ d1[group1Name] }</td>
|
|
|
+ return <tr className='row-statistics' key={d1i}>
|
|
|
+ <td className='cell-group'>{ d1[group1Name] }</td>
|
|
|
{ data2.map(d2 => {
|
|
|
return statistics.map((s, si) => {
|
|
|
- return <td key={si} style={cellStyle}>{d2[s.name]}</td>
|
|
|
+ return <td className='cell-statistics-value' key={si}>{d2[s.name]}</td>
|
|
|
})
|
|
|
}) }
|
|
|
</tr>
|
|
|
@@ -162,7 +159,7 @@ class AggregateTableView extends React.Component {
|
|
|
render() {
|
|
|
const { chartOption } = this.props;
|
|
|
const { direction, themeConfig } = chartOption;
|
|
|
- const { backgroundColor } = themeConfig || {};
|
|
|
+ const { name: themeName } = themeConfig || {};
|
|
|
if(!chartOption || !chartOption.targetColumn || !chartOption.statistics || chartOption.statistics.length === 0) {
|
|
|
return <EmptyContent />
|
|
|
}
|
|
|
@@ -170,7 +167,7 @@ class AggregateTableView extends React.Component {
|
|
|
if(!body) {
|
|
|
return <EmptyContent />
|
|
|
}
|
|
|
- return <div ref={ node => this.formRef = node } className='aggregate-container' style={{ backgroundColor }}>
|
|
|
+ return <div ref={ node => this.formRef = node } className={`aggregate-container ${themeName}`}>
|
|
|
<table className={`aggregate-table ${direction}`} border='1'>
|
|
|
{ body }
|
|
|
</table>
|