Skip to content

Commit e0e0fd5

Browse files
CanvasSize
1 parent 21fb7ec commit e0e0fd5

File tree

5 files changed

+64
-1
lines changed

5 files changed

+64
-1
lines changed

src/DefaultEditor.js

+33-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
33
import {
44
AxesSelector,
55
AxesRange,
6+
CanvasSize,
67
ColorPicker,
78
DataSelector,
89
Dropdown,
@@ -176,12 +177,43 @@ class DefaultEditor extends Component {
176177

177178
<LayoutPanel group="Style" name={_('Layout')}>
178179
<Fold name={_('Canvas')}>
179-
<Numeric
180+
<Radio
181+
attr="autosize"
182+
options={[
183+
{label: _('Auto'), value: true},
184+
{label: _('Custom'), value: false},
185+
]}
186+
/>
187+
<CanvasSize
180188
label={_('Fixed Width')}
181189
step={1}
182190
attr="width"
183191
postfix="px"
184192
/>
193+
<CanvasSize
194+
label={_('Fixed Height')}
195+
step={1}
196+
attr="height"
197+
postfix="px"
198+
/>
199+
<ColorPicker label={_('Color')} attr="paper_bgcolor" />
200+
</Fold>
201+
<Fold name={_('Margins and Padding')}>
202+
<Numeric label={_('Top')} step={1} attr="margin.t" postfix="px" />
203+
<Numeric
204+
label={_('Bottom')}
205+
step={1}
206+
attr="margin.b"
207+
postfix="px"
208+
/>
209+
<Numeric label={_('Left')} step={1} attr="margin.l" postfix="px" />
210+
<Numeric label={_('Right')} step={1} attr="margin.r" postfix="px" />
211+
<Numeric
212+
label={_('Padding')}
213+
step={1}
214+
attr="margin.pad"
215+
postfix="px"
216+
/>
185217
</Fold>
186218
</LayoutPanel>
187219

src/components/fields/CanvasSize.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Numeric from './Numeric';
2+
import React, {Component} from 'react';
3+
import {connectToContainer} from '../../lib';
4+
5+
class CanvasSize extends Component {
6+
static modifyPlotProps(props, context, plotProps) {
7+
if (!plotProps.isVisible) {
8+
return;
9+
}
10+
const {fullContainer} = plotProps;
11+
if (fullContainer && fullContainer.autosize) {
12+
plotProps.isVisible = false;
13+
}
14+
}
15+
16+
render() {
17+
return <Numeric {...this.props} />;
18+
}
19+
}
20+
21+
CanvasSize.propTypes = {
22+
...Numeric.propTypes,
23+
};
24+
25+
export default connectToContainer(CanvasSize);

src/components/fields/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import AxesRange from './AxesRange';
22
import AxesSelector from './AxesSelector';
3+
import CanvasSize from './CanvasSize';
34
import ColorPicker from './Color';
45
import Dropdown from './Dropdown';
56
import Flaglist from './Flaglist';
@@ -13,6 +14,7 @@ import TraceSelector from './TraceSelector';
1314
export {
1415
AxesRange,
1516
AxesSelector,
17+
CanvasSize,
1618
ColorPicker,
1719
Dropdown,
1820
Flaglist,

src/components/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
AxesRange,
33
AxesSelector,
4+
CanvasSize,
45
ColorPicker,
56
Dropdown,
67
Flaglist,
@@ -26,6 +27,7 @@ export {
2627
AxesSelector,
2728
AxesRange,
2829
MenuPanel,
30+
CanvasSize,
2931
ColorPicker,
3032
DataSelector,
3133
Dropdown,

src/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {EDITOR_ACTIONS} from './constants';
1212
import {
1313
AxesRange,
1414
AxesSelector,
15+
CanvasSize,
1516
ColorPicker,
1617
DataSelector,
1718
Dropdown,
@@ -35,6 +36,7 @@ export {
3536
AxesRange,
3637
AxesSelector,
3738
MenuPanel,
39+
CanvasSize,
3840
ColorPicker,
3941
DataSelector,
4042
Dropdown,

0 commit comments

Comments
 (0)