← All changes
|
classes/Visualizer/Gutenberg/src/Components/ChartSelect.js
+29
-13
3.1.0
→
3.3.4
View file →
| @@ -2,8 +2,10 @@ | ||
| 2 | 2 | * External dependencies |
| 3 | 3 | */ |
| 4 | 4 | import { Chart } from 'react-google-charts'; |
| 5 | 5 | |
| 6 | +import DataTable from './DataTable.js'; | |
| 7 | + | |
| 6 | 8 | import FileImport from './Import/FileImport.js'; |
| 7 | 9 | |
| 8 | 10 | import RemoteImport from './Import/RemoteImport.js'; |
| 9 | 11 | |
| @@ -56,10 +58,14 @@ | ||
| 56 | 58 | let chart; |
| 57 | 59 | |
| 58 | 60 | let data = formatDate( JSON.parse( JSON.stringify( this.props.chart ) ) ); |
| 59 | 61 | |
| 60 | - if ( 0 <= [ 'gauge', 'table', 'timeline' ].indexOf( this.props.chart['visualizer-chart-type']) ) { | |
| 61 | - chart = startCase( this.props.chart['visualizer-chart-type']); | |
| 62 | + if ( 0 <= [ 'gauge', 'table', 'timeline', 'dataTable' ].indexOf( this.props.chart['visualizer-chart-type']) ) { | |
| 63 | + if ( 'dataTable' === data['visualizer-chart-type']) { | |
| 64 | + chart = data['visualizer-chart-type']; | |
| 65 | + } else { | |
| 66 | + chart = startCase( this.props.chart['visualizer-chart-type']); | |
| 67 | + } | |
| 62 | 68 | } else { |
| 63 | 69 | chart = `${ startCase( this.props.chart['visualizer-chart-type']) }Chart`; |
| 64 | 70 | } |
| 65 | 71 | |
| @@ -119,19 +125,29 @@ | ||
| 119 | 125 | |
| 120 | 126 | <div className="visualizer-settings__chart"> |
| 121 | 127 | |
| 122 | 128 | { ( null !== this.props.chart ) && |
| 123 | - <Chart | |
| 124 | - chartType={ chart } | |
| 125 | - rows={ data['visualizer-data'] } | |
| 126 | - columns={ data['visualizer-series'] } | |
| 127 | - options={ | |
| 128 | - isValidJSON( this.props.chart['visualizer-settings'].manual ) ? | |
| 129 | - merge( compact( this.props.chart['visualizer-settings']), JSON.parse( this.props.chart['visualizer-settings'].manual ) ) : | |
| 130 | - compact( this.props.chart['visualizer-settings']) | |
| 131 | - } | |
| 132 | - height="500px" | |
| 133 | - /> | |
| 129 | + | |
| 130 | + ( 'dataTable' === chart ) ? ( | |
| 131 | + <DataTable | |
| 132 | + id={ this.props.id } | |
| 133 | + rows={ data['visualizer-data'] } | |
| 134 | + columns={ data['visualizer-series'] } | |
| 135 | + options={ data['visualizer-settings'] } | |
| 136 | + /> | |
| 137 | + ) : ( | |
| 138 | + <Chart | |
| 139 | + chartType={ chart } | |
| 140 | + rows={ data['visualizer-data'] } | |
| 141 | + columns={ data['visualizer-series'] } | |
| 142 | + options={ | |
| 143 | + isValidJSON( this.props.chart['visualizer-settings'].manual ) ? | |
| 144 | + merge( compact( this.props.chart['visualizer-settings']), JSON.parse( this.props.chart['visualizer-settings'].manual ) ) : | |
| 145 | + compact( this.props.chart['visualizer-settings']) | |
| 146 | + } | |
| 147 | + height="500px" | |
| 148 | + /> | |
| 149 | + ) | |
| 134 | 150 | } |
| 135 | 151 | |
| 136 | 152 | </div> |
| 137 | 153 | </Fragment> |