PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.2.0
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.2.0
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.2.0, at classes/Visualizer/Gutenberg/src/Components/ChartSelect.js

143 lines 3.4 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 FileImport from './Import/FileImport.js';
7
8 import RemoteImport from './Import/RemoteImport.js';
9
10 import ChartImport from './Import/ChartImport.js';
11
12 import ManualData from './Import/ManualData.js';
13
14 import Sidebar from './Sidebar.js';
15
16 import ChartPermissions from './ChartPermissions.js';
17
18 import PanelButton from './PanelButton.js';
19
20 import merge from 'merge';
21
22 import { compact, formatDate, isValidJSON } from '../utils.js';
23
24 /**
25 * WordPress dependencies
26 */
27 const { startCase } = lodash;
28
29 const { __ } = wp.i18n;
30
31 const {
32 Component,
33 Fragment
34 } = wp.element;
35
36 const { InspectorControls } = wp.editor;
37
38 class ChartSelect extends Component {
39 constructor() {
40 super( ...arguments );
41
42 this.state = {
43
44 /**
45 * Sidebar Route Status
46 *
47 * home - Initial screen.
48 * showAdvanced - Show Advanced Options.
49 */
50 route: 'home'
51 };
52 }
53
54 render() {
55
56 let chart;
57
58 let data = formatDate( JSON.parse( JSON.stringify( this.props.chart ) ) );
59
60 if ( 0 <= [ 'gauge', 'table', 'timeline' ].indexOf( this.props.chart['visualizer-chart-type']) ) {
61 chart = startCase( this.props.chart['visualizer-chart-type']);
62 } else {
63 chart = `${ startCase( this.props.chart['visualizer-chart-type']) }Chart`;
64 }
65
66 return (
67 <Fragment>
68 { 'home' === this.state.route &&
69 <InspectorControls>
70
71 <FileImport
72 chart={ this.props.chart }
73 readUploadedFile={ this.props.readUploadedFile }
74 />
75
76 <RemoteImport
77 chart={ this.props.chart }
78 editURL={ this.props.editURL }
79 isLoading={ this.props.isLoading }
80 uploadData={ this.props.uploadData }
81 editSchedule={ this.props.editSchedule }
82 />
83
84 <ChartImport getChartData={ this.props.getChartData } isLoading={ this.props.isLoading } />
85
86 <ManualData chart={ this.props.chart } editChartData={ this.props.editChartData } />
87
88 <PanelButton
89 label={ __( 'Advanced Options' ) }
90 icon="admin-tools"
91 onClick={ () => this.setState({ route: 'showAdvanced' }) }
92 />
93
94 <PanelButton
95 label={ __( 'Chart Permissions' ) }
96 icon="admin-users"
97 onClick={ () => this.setState({ route: 'showPermissions' }) }
98 />
99 </InspectorControls>
100 }
101
102 { ( 'showAdvanced' === this.state.route || 'showPermissions' === this.state.route ) &&
103 <InspectorControls>
104 <PanelButton
105 label={ __( 'Chart Settings' ) }
106 onClick={ () => this.setState({ route: 'home' }) }
107 isBack={ true }
108 />
109
110 { 'showAdvanced' === this.state.route &&
111 <Sidebar chart={ this.props.chart } edit={ this.props.editSettings } />
112 }
113
114 { 'showPermissions' === this.state.route &&
115 <ChartPermissions chart={ this.props.chart } edit={ this.props.editPermissions } />
116 }
117 </InspectorControls>
118 }
119
120 <div className="visualizer-settings__chart">
121
122 { ( 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 />
134 }
135
136 </div>
137 </Fragment>
138 );
139 }
140 }
141
142 export default ChartSelect;
143