PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.4
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.4
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 3.10.4 All 148 releases
visualizer / classes / Visualizer / Gutenberg / src / Components / ChartSelect.js

ChartSelect.js in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.4.4, at classes/Visualizer/Gutenberg/src/Components/ChartSelect.js

195 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * External dependencies
3 */
4 import { Chart } from 'react-google-charts';
5
6 import DataTable from './DataTable.js';
7
8 import FileImport from './Import/FileImport.js';
9
10 import RemoteImport from './Import/RemoteImport.js';
11
12 import ChartImport from './Import/ChartImport.js';
13
14 import DataImport from './Import/DataImport.js';
15
16 import ManualData from './Import/ManualData.js';
17
18 import Sidebar from './Sidebar.js';
19
20 import ChartPermissions from './ChartPermissions.js';
21
22 import PanelButton from './PanelButton.js';
23
24 import merge from 'merge';
25
26 import { compact, formatDate, isValidJSON } from '../utils.js';
27
28 /**
29 * WordPress dependencies
30 */
31 const { startCase } = lodash;
32
33 const { __ } = wp.i18n;
34
35 const {
36 Component,
37 Fragment
38 } = wp.element;
39
40 const { InspectorControls } = wp.blockEditor || wp.editor;
41
42 class ChartSelect extends Component {
43 constructor() {
44 super( ...arguments );
45
46 this.state = {
47
48 /**
49 * Sidebar Route Status
50 *
51 * home - Initial screen.
52 * showAdvanced - Show Advanced Options.
53 */
54 route: 'home'
55 };
56 }
57
58 render() {
59
60 let chart, footer;
61
62 let data = formatDate( JSON.parse( JSON.stringify( this.props.chart ) ) );
63
64 if ( 0 <= [ 'gauge', 'table', 'timeline', 'dataTable' ].indexOf( this.props.chart['visualizer-chart-type']) ) {
65 if ( 'dataTable' === data['visualizer-chart-type']) {
66 chart = data['visualizer-chart-type'];
67 } else {
68 chart = startCase( this.props.chart['visualizer-chart-type']);
69 }
70 } else {
71 chart = `${ startCase( this.props.chart['visualizer-chart-type']) }Chart`;
72 }
73
74 if ( data['visualizer-data-exploded']) {
75 footer = __( 'Annotations in this chart may not display here but they will display in the front end.' );
76 }
77
78 return (
79 <Fragment>
80 { 'home' === this.state.route &&
81 <InspectorControls>
82
83 <FileImport
84 chart={ this.props.chart }
85 readUploadedFile={ this.props.readUploadedFile }
86 />
87
88 <RemoteImport
89 id={ this.props.id }
90 chart={ this.props.chart }
91 editURL={ this.props.editURL }
92 isLoading={ this.props.isLoading }
93 uploadData={ this.props.uploadData }
94 editSchedule={ this.props.editSchedule }
95 editJSONSchedule={ this.props.editJSONSchedule }
96 editJSONURL={ this.props.editJSONURL }
97 editJSONHeaders={ this.props.editJSONHeaders }
98 editJSONRoot={ this.props.editJSONRoot }
99 editJSONPaging={ this.props.editJSONPaging }
100 JSONImportData={ this.props.JSONImportData }
101 />
102
103 <ChartImport getChartData={ this.props.getChartData } isLoading={ this.props.isLoading } />
104
105 <DataImport
106 chart={ this.props.chart }
107 editSchedule={ this.props.editDatabaseSchedule }
108 databaseImportData={ this.props.databaseImportData }
109 />
110
111 <ManualData chart={ this.props.chart } editChartData={ this.props.editChartData } />
112
113 <PanelButton
114 label={ __( 'Advanced Options' ) }
115 className="visualizer-advanced-options"
116 icon="admin-tools"
117 onClick={ () => this.setState({ route: 'showAdvanced' }) }
118 />
119
120 <PanelButton
121 label={ __( 'Chart Permissions' ) }
122 icon="admin-users"
123 onClick={ () => this.setState({ route: 'showPermissions' }) }
124 />
125 </InspectorControls>
126 }
127
128 { ( 'showAdvanced' === this.state.route || 'showPermissions' === this.state.route ) &&
129 <InspectorControls>
130 <PanelButton
131 label={ __( 'Chart Settings' ) }
132 onClick={ () => this.setState({ route: 'home' }) }
133 isBack={ true }
134 />
135
136 { 'showAdvanced' === this.state.route &&
137 <Sidebar chart={ this.props.chart } edit={ this.props.editSettings } />
138 }
139
140 { 'showPermissions' === this.state.route &&
141 <ChartPermissions chart={ this.props.chart } edit={ this.props.editPermissions } />
142 }
143 </InspectorControls>
144 }
145
146 <div className="visualizer-settings__chart">
147
148 { ( null !== this.props.chart ) &&
149
150 ( 'dataTable' === chart ) ? (
151 <DataTable
152 id={ this.props.id }
153 rows={ data['visualizer-data'] }
154 columns={ data['visualizer-series'] }
155 options={ data['visualizer-settings'] }
156 />
157 ) : ( '' !== data['visualizer-data-exploded'] ? (
158 <Chart
159 chartType={ chart }
160 rows={ data['visualizer-data'] }
161 columns={ data['visualizer-series'] }
162 options={
163 isValidJSON( this.props.chart['visualizer-settings'].manual ) ?
164 merge( compact( this.props.chart['visualizer-settings']), JSON.parse( this.props.chart['visualizer-settings'].manual ) ) :
165 compact( this.props.chart['visualizer-settings'])
166 }
167 height="500px"
168 />
169 ) : (
170 <Chart
171 chartType={ chart }
172 rows={ data['visualizer-data'] }
173 columns={ data['visualizer-series'] }
174 options={
175 isValidJSON( this.props.chart['visualizer-settings'].manual ) ?
176 merge( compact( this.props.chart['visualizer-settings']), JSON.parse( this.props.chart['visualizer-settings'].manual ) ) :
177 compact( this.props.chart['visualizer-settings'])
178 }
179 height="500px"
180 />
181 )
182 ) }
183
184 <div className="visualizer-settings__charts-footer"><sub>
185 { footer }
186 </sub></div>
187
188 </div>
189 </Fragment>
190 );
191 }
192 }
193
194 export default ChartSelect;
195