/** * WordPress dependencies */ const { __ } = wp.i18n; const { Component, Fragment } = wp.element; const { ColorPalette } = wp.blockEditor || wp.editor; const { BaseControl, ExternalLink, PanelBody, SelectControl, TextControl } = wp.components; class SeriesSettings extends Component { constructor() { super( ...arguments ); } componentDidMount() { /** * We use deep-clean to remove all empty properties which causes a major issue with Series Settings. * So add a dummy property to make sure `series` object isn't empty. * Should be removed before saving the data. */ const settings = this.props.chart['visualizer-settings']; Object.keys( settings.series ) .map( i => { if ( settings.series[i] !== undefined ) { settings.series[i].temp = 1; } } ); this.props.edit( settings ); } render() { const type = this.props.chart['visualizer-chart-type']; const settings = this.props.chart['visualizer-settings']; const series = this.props.chart['visualizer-series']; return ( { Object.keys( settings.series ) .map( ( i, index ) => { i++; return ( { ( -1 >= [ 'table', 'pie' ].indexOf( type ) ) && ( { settings.series[index].visibleInLegend = e; this.props.edit( settings ); } } /> ) } { ( -1 >= [ 'table', 'candlestick', 'combo', 'column', 'bar' ].indexOf( type ) ) && ( { settings.series[index].lineWidth = e; this.props.edit( settings ); } } /> { settings.series[index].pointSize = e; this.props.edit( settings ); } } /> ) } { ( -1 >= [ 'candlestick' ].indexOf( type ) ) && ( 'number' === series[i].type ) ? ( { settings.series[index].format = e; this.props.edit( settings ); } } />

{ __( 'For number axis labels, this is a subset of the formatting ' ) } { __( 'ICU pattern set.' ) } { __( ' For instance, $#,###.## will display values $1,234.56 for value 1234.56. Pay attention that if you use #%% percentage format then your values will be multiplied by 100.' ) }

) : ( 'date' === series[i].type ) && ( { settings.series[index].format = e; this.props.edit( settings ); } } />

{ __( 'This is a subset of the date formatting ' ) } { __( 'ICU date and time format.' ) }

) } { ( 0 <= [ 'scatter', 'line' ].indexOf( type ) ) && ( { settings.series[index].curveType = e; this.props.edit( settings ); } } /> ) } { ( 0 <= [ 'area' ].indexOf( type ) ) && ( { settings.series[index].areaOpacity = e; this.props.edit( settings ); } } /> ) } { ( 0 <= [ 'combo' ].indexOf( type ) ) && ( { settings.series[index].type = e; this.props.edit( settings ); } } /> ) } { ( -1 >= [ 'table' ].indexOf( type ) ) && ( { settings.series[index].color = e; this.props.edit( settings ); } } /> ) }
); } ) }
); } } export default SeriesSettings;