-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathdata_visualisation.jsx
More file actions
82 lines (72 loc) · 2.48 KB
/
data_visualisation.jsx
File metadata and controls
82 lines (72 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import React, { PropTypes } from 'react';
import ChartCanvas from './chart_canvas.jsx';
import PreviewPagination from './preview_pagination.jsx';
import Loading from '/client/modules/core/components/partial/loading.jsx';
import SimpleTable from './simple_table.jsx';
import PivotTable from '/client/modules/workplace/containers/preview/pivot_table';
import { CardText } from 'material-ui/Card';
class DataVisualisation extends React.Component {
componentWillUpdate(nextProps) {
const { updateToolbarValues } = this.props;
const nextValues = nextProps.data && nextProps.data[0];
updateToolbarValues(nextValues);
}
componentWillUnmount() {
this.props.resetData();
}
render() {
const { data = [], queryObject, viewObject, tableType, isLive, isLoading,
updateSQLQueryObj } = this.props;
const { chartType } = viewObject;
const tableHeight = `${window.innerHeight - 74}px`;
return (
<div className="data-visualisation">
{tableType === 'simple' &&
<SimpleTable
fields={queryObject.fields}
data={data}
chartType={chartType}
isLoading={isLoading}
/>}
{!chartType && tableType === 'pivot' && !isLoading && isLive &&
<div className="pivot-table" style={{ maxHeight: tableHeight }}>
<PivotTable chart={{ queryObject, viewObject, data }} />
</div>}
{chartType && !!data &&
<CardText className="data-visualisation">
<ChartCanvas
data={data}
fields={queryObject.fields}
tableType={tableType}
chartType={chartType}
heightIsFixed
needRedraw
/>
</CardText>}
{!!data && tableType === 'simple' &&
<div className="preview-footer">
<PreviewPagination
pagination={queryObject.pagination}
updateSQLQueryObj={updateSQLQueryObj}
itemsCount={data.length}
/>
</div>}
{isLoading ? <Loading preview /> : ''}
</div>
);
}
}
DataVisualisation.propTypes = {
tableType: PropTypes.string,
isLoading: PropTypes.bool,
isLive: PropTypes.bool,
queryObject: PropTypes.object,
viewObject: PropTypes.object,
data: PropTypes.array,
updateSQLQueryObj: PropTypes.func,
updateToolbarValues: PropTypes.func,
resetData: PropTypes.func,
updateSorting: PropTypes.func,
processDateField: PropTypes.func,
};
export default DataVisualisation;