/** * External dependencies */ import { Chart } from 'react-google-charts'; import DataTable from './DataTable.js'; import merge from 'merge'; import { compact, formatDate, isValidJSON } from '../utils.js'; /** * WordPress dependencies */ const { startCase } = lodash; const { __ } = wp.i18n; const { Component, Fragment } = wp.element; const { Button, Dashicon, Toolbar, Tooltip } = wp.components; const { BlockControls } = wp.blockEditor || wp.editor; class ChartRender extends Component { constructor() { super( ...arguments ); } render() { let chart, footer; let data = formatDate( JSON.parse( JSON.stringify( this.props.chart ) ) ); if ( 0 <= [ 'gauge', 'table', 'timeline', 'dataTable' ].indexOf( this.props.chart['visualizer-chart-type']) ) { if ( 'dataTable' === data['visualizer-chart-type']) { chart = data['visualizer-chart-type']; } else { chart = startCase( this.props.chart['visualizer-chart-type']); } } else { chart = `${ startCase( this.props.chart['visualizer-chart-type']) }Chart`; } if ( data['visualizer-data-exploded']) { footer = __( 'Annotations in this chart may not display here but they will display in the front end.' ); } return (
{ ( null !== this.props.chart ) && { ( 'dataTable' === chart ) ? ( ) : ( '' !== data['visualizer-data-exploded'] ? ( ) : ( ) ) }
{ footer }
}
); } } export default ChartRender;