| 1 |
/** |
| 2 |
* WordPress dependencies |
| 3 |
*/ |
| 4 |
const { __ } = wp.i18n; |
| 5 |
|
| 6 |
const { Component } = wp.element; |
| 7 |
|
| 8 |
const { ColorPalette } = wp.blockEditor || wp.editor; |
| 9 |
|
| 10 |
import { isChecked } from '../../utils.js'; |
| 11 |
|
| 12 |
const { |
| 13 |
CheckboxControl, |
| 14 |
BaseControl, |
| 15 |
PanelBody, |
| 16 |
TextControl |
| 17 |
} = wp.components; |
| 18 |
|
| 19 |
class BubbleSettings extends Component { |
| 20 |
constructor() { |
| 21 |
super( ...arguments ); |
| 22 |
} |
| 23 |
|
| 24 |
componentDidMount() { |
| 25 |
|
| 26 |
} |
| 27 |
|
| 28 |
render() { |
| 29 |
|
| 30 |
const settings = this.props.chart['visualizer-settings']; |
| 31 |
|
| 32 |
return ( |
| 33 |
<PanelBody |
| 34 |
title={ __( 'Bubble Settings' ) } |
| 35 |
initialOpen={ false } |
| 36 |
className="visualizer-advanced-panel" |
| 37 |
> |
| 38 |
|
| 39 |
<TextControl |
| 40 |
label={ __( 'Opacity' ) } |
| 41 |
help={ __( 'The default opacity of the bubbles, where 0.0 is fully transparent and 1.0 is fully opaque.' ) } |
| 42 |
type="number" |
| 43 |
min="0" |
| 44 |
max="1" |
| 45 |
step="0.1" |
| 46 |
value={ settings.bubble.opacity } |
| 47 |
onChange={ e => { |
| 48 |
if ( ! settings.bubble ) { |
| 49 |
settings.bubble = {}; |
| 50 |
} |
| 51 |
settings.bubble.opacity = e; |
| 52 |
this.props.edit( settings ); |
| 53 |
} } |
| 54 |
/> |
| 55 |
|
| 56 |
<BaseControl |
| 57 |
label={ __( 'Stroke Color' ) } |
| 58 |
> |
| 59 |
<ColorPalette |
| 60 |
value={ settings.bubble.stroke } |
| 61 |
onChange={ e => { |
| 62 |
if ( ! settings.bubble ) { |
| 63 |
settings.bubble = {}; |
| 64 |
} |
| 65 |
settings.bubble.stroke = e; |
| 66 |
this.props.edit( settings ); |
| 67 |
} } |
| 68 |
/> |
| 69 |
</BaseControl> |
| 70 |
|
| 71 |
<CheckboxControl |
| 72 |
label={ __( 'Sort Bubbles by Size' ) } |
| 73 |
help={ __( 'If checked, sorts the bubbles by size so the smaller bubbles appear above the larger bubbles. If unchecked, bubbles are sorted according to their order in the table.' ) } |
| 74 |
checked={ isChecked( settings, 'sortBubblesBySize' ) } |
| 75 |
onChange={ e => { |
| 76 |
settings.sortBubblesBySize = e; |
| 77 |
this.props.edit( settings ); |
| 78 |
} } |
| 79 |
/> |
| 80 |
|
| 81 |
<TextControl |
| 82 |
label={ __( 'Size (max)' ) } |
| 83 |
help={ __( 'The size value (as appears in the chart data) to be mapped to sizeAxis.maxSize. Larger values will be cropped to this value.' ) } |
| 84 |
type="number" |
| 85 |
step="1" |
| 86 |
value={ settings.sizeAxis.maxValue } |
| 87 |
onChange={ e => { |
| 88 |
if ( ! settings.sizeAxis ) { |
| 89 |
settings.sizeAxis = {}; |
| 90 |
} |
| 91 |
settings.sizeAxis.maxValue = e; |
| 92 |
this.props.edit( settings ); |
| 93 |
} } |
| 94 |
/> |
| 95 |
|
| 96 |
<TextControl |
| 97 |
label={ __( 'Size (min)' ) } |
| 98 |
help={ __( 'The size value (as appears in the chart data) to be mapped to sizeAxis.minSize. Smaller values will be cropped to this value.' ) } |
| 99 |
type="number" |
| 100 |
step="1" |
| 101 |
value={ settings.sizeAxis.minValue } |
| 102 |
onChange={ e => { |
| 103 |
if ( ! settings.sizeAxis ) { |
| 104 |
settings.sizeAxis = {}; |
| 105 |
} |
| 106 |
settings.sizeAxis.minValue = e; |
| 107 |
this.props.edit( settings ); |
| 108 |
} } |
| 109 |
/> |
| 110 |
|
| 111 |
</PanelBody> |
| 112 |
); |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
export default BubbleSettings; |
| 117 |
|