| 1 |
/** |
| 2 |
* WordPress dependencies |
| 3 |
*/ |
| 4 |
const { __ } = wp.i18n; |
| 5 |
|
| 6 |
const { |
| 7 |
Component, |
| 8 |
Fragment |
| 9 |
} = wp.element; |
| 10 |
|
| 11 |
const { ColorPalette } = wp.blockEditor || wp.editor; |
| 12 |
|
| 13 |
const { |
| 14 |
BaseControl, |
| 15 |
ExternalLink, |
| 16 |
PanelBody, |
| 17 |
SelectControl, |
| 18 |
TextControl |
| 19 |
} = wp.components; |
| 20 |
|
| 21 |
class PieSettings extends Component { |
| 22 |
constructor() { |
| 23 |
super( ...arguments ); |
| 24 |
} |
| 25 |
|
| 26 |
render() { |
| 27 |
|
| 28 |
const settings = this.props.chart['visualizer-settings']; |
| 29 |
|
| 30 |
return ( |
| 31 |
<PanelBody |
| 32 |
title={ __( 'Pie Settings' ) } |
| 33 |
initialOpen={ false } |
| 34 |
className="visualizer-advanced-panel" |
| 35 |
> |
| 36 |
|
| 37 |
<Fragment> |
| 38 |
|
| 39 |
<TextControl |
| 40 |
label={ __( 'Number Format' ) } |
| 41 |
help={ __( 'Enter custom format pattern to apply to chart labels.' ) } |
| 42 |
value={ settings.format } |
| 43 |
onChange={ e => { |
| 44 |
settings.format = e; |
| 45 |
this.props.edit( settings ); |
| 46 |
} } |
| 47 |
/> |
| 48 |
|
| 49 |
<p> |
| 50 |
{ __( 'For number axis labels, this is a subset of the formatting ' ) } |
| 51 |
<ExternalLink href="http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details"> |
| 52 |
{ __( 'ICU pattern set.' ) } |
| 53 |
</ExternalLink> |
| 54 |
{ __( ' 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.' ) } |
| 55 |
</p> |
| 56 |
|
| 57 |
<p> |
| 58 |
{ __( 'For date axis labels, this is a subset of the date formatting ' ) } |
| 59 |
<ExternalLink href="https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax"> |
| 60 |
{ __( 'ICU date and time format.' ) } |
| 61 |
</ExternalLink> |
| 62 |
</p> |
| 63 |
|
| 64 |
</Fragment> |
| 65 |
|
| 66 |
<SelectControl |
| 67 |
label={ __( 'Is 3D' ) } |
| 68 |
help={ __( 'If set to yes, displays a three-dimensional chart.' ) } |
| 69 |
value={ settings.is3D ? settings.is3D : '0' } |
| 70 |
options={ [ |
| 71 |
{ label: __( 'Yes' ), value: '1' }, |
| 72 |
{ label: __( 'No' ), value: '0' } |
| 73 |
] } |
| 74 |
onChange={ e => { |
| 75 |
settings.is3D = e; |
| 76 |
this.props.edit( settings ); |
| 77 |
} } |
| 78 |
/> |
| 79 |
|
| 80 |
<SelectControl |
| 81 |
label={ __( 'Reverse Categories' ) } |
| 82 |
help={ __( 'If set to yes, will draw slices counterclockwise.' ) } |
| 83 |
value={ settings.reverseCategories ? settings.reverseCategories : '0' } |
| 84 |
options={ [ |
| 85 |
{ label: __( 'Yes' ), value: '1' }, |
| 86 |
{ label: __( 'No' ), value: '0' } |
| 87 |
] } |
| 88 |
onChange={ e => { |
| 89 |
settings.reverseCategories = e; |
| 90 |
this.props.edit( settings ); |
| 91 |
} } |
| 92 |
/> |
| 93 |
|
| 94 |
<SelectControl |
| 95 |
label={ __( 'Slice Text' ) } |
| 96 |
help={ __( 'The content of the text displayed on the slice.' ) } |
| 97 |
value={ settings.pieSliceText ? settings.pieSliceText : 'percentage' } |
| 98 |
options={ [ |
| 99 |
{ label: __( 'The percentage of the slice size out of the total' ), value: 'percentage' }, |
| 100 |
{ label: __( 'The quantitative value of the slice' ), value: 'value' }, |
| 101 |
{ label: __( 'The name of the slice' ), value: 'label' }, |
| 102 |
{ label: __( 'The quantitative value and percentage of the slice' ), value: 'value-and-percentage' }, |
| 103 |
{ label: __( 'No text is displayed' ), value: 'none' } |
| 104 |
] } |
| 105 |
onChange={ e => { |
| 106 |
settings.pieSliceText = e; |
| 107 |
this.props.edit( settings ); |
| 108 |
} } |
| 109 |
/> |
| 110 |
|
| 111 |
<TextControl |
| 112 |
label={ __( 'Pie Hole' ) } |
| 113 |
help={ __( 'If between 0 and 1, displays a donut chart. The hole with have a radius equal to number times the radius of the chart. Only applicable when the chart is two-dimensional.' ) } |
| 114 |
placeholder={ __( '0.5' ) } |
| 115 |
value={ settings.pieHole } |
| 116 |
onChange={ e => { |
| 117 |
settings.pieHole = e; |
| 118 |
this.props.edit( settings ); |
| 119 |
} } |
| 120 |
/> |
| 121 |
|
| 122 |
<TextControl |
| 123 |
label={ __( 'Start Angle' ) } |
| 124 |
help={ __( 'The angle, in degrees, to rotate the chart by. The default of 0 will orient the leftmost edge of the first slice directly up.' ) } |
| 125 |
value={ settings.pieStartAngle } |
| 126 |
onChange={ e => { |
| 127 |
settings.pieStartAngle = e; |
| 128 |
this.props.edit( settings ); |
| 129 |
} } |
| 130 |
/> |
| 131 |
|
| 132 |
<BaseControl |
| 133 |
label={ __( 'Slice Border Color' ) } |
| 134 |
> |
| 135 |
<ColorPalette |
| 136 |
value={ settings.pieSliceBorderColor } |
| 137 |
onChange={ e => { |
| 138 |
settings.pieSliceBorderColor = e; |
| 139 |
this.props.edit( settings ); |
| 140 |
} } |
| 141 |
/> |
| 142 |
</BaseControl> |
| 143 |
|
| 144 |
</PanelBody> |
| 145 |
); |
| 146 |
} |
| 147 |
} |
| 148 |
|
| 149 |
export default PieSettings; |
| 150 |
|