File tree 4 files changed +57
-5
lines changed
4 files changed +57
-5
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ import {
24
24
import { DEFAULT_FONTS } from './constants' ;
25
25
import { localize , connectAxesToLayout , connectLayoutToPlot } from './lib' ;
26
26
27
+ import { BoxGap } from './shame' ;
28
+
27
29
const LayoutPanel = connectLayoutToPlot ( Panel ) ;
28
30
const AxesFold = connectAxesToLayout ( Fold ) ;
29
31
@@ -145,6 +147,21 @@ class DefaultEditor extends Component {
145
147
< ColorPicker label = { _ ( 'Border Color' ) } attr = "marker.line.color" />
146
148
</ TraceMarkerSection >
147
149
150
+ < Section name = { _ ( 'Size and Spacing' ) } >
151
+ < BoxGap label = { _ ( 'Bar Width' ) } attr = "bargap" />
152
+ < BoxGap label = { _ ( 'Box Width' ) } attr = "boxgap" />
153
+ < BoxGap
154
+ label = { _ ( 'Bar Padding' ) }
155
+ attr = "bargroupgap"
156
+ showArrows = { false }
157
+ />
158
+ < BoxGap
159
+ label = { _ ( 'Box Padding' ) }
160
+ attr = "boxgroupgap"
161
+ showArrows = { false }
162
+ />
163
+ </ Section >
164
+
148
165
< Section name = { _ ( 'Lines' ) } >
149
166
< Numeric label = { _ ( 'Width' ) } step = { 1.0 } attr = "line.width" />
150
167
< ColorPicker label = { _ ( 'Line Color' ) } attr = "line.color" />
Original file line number Diff line number Diff line change @@ -58,7 +58,11 @@ export default class Section extends Component {
58
58
} else {
59
59
plotProps = { isVisible : true } ;
60
60
}
61
+
62
+ // assign plotProps as a prop of children. If they are connectedToContainer
63
+ // it will see plotProps and skip recomputing them.
61
64
const childProps = Object . assign ( { plotProps} , child . props ) ;
65
+
62
66
childProps . key = i ;
63
67
attrChildren . push ( cloneElement ( child , childProps ) ) ;
64
68
}
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
4
4
import React , { Component } from 'react' ;
5
5
import { connectToContainer } from '../../lib' ;
6
6
7
- class Numeric extends Component {
7
+ export class UnconnectedNumeric extends Component {
8
8
render ( ) {
9
9
return (
10
10
< Field { ...this . props } >
@@ -23,7 +23,7 @@ class Numeric extends Component {
23
23
}
24
24
}
25
25
26
- Numeric . propTypes = {
26
+ UnconnectedNumeric . propTypes = {
27
27
defaultValue : PropTypes . number ,
28
28
fullValue : PropTypes . func ,
29
29
min : PropTypes . number ,
@@ -34,8 +34,8 @@ Numeric.propTypes = {
34
34
...Field . propTypes ,
35
35
} ;
36
36
37
- Numeric . defaultProps = {
37
+ UnconnectedNumeric . defaultProps = {
38
38
showArrows : true ,
39
39
} ;
40
40
41
- export default connectToContainer ( Numeric ) ;
41
+ export default connectToContainer ( UnconnectedNumeric ) ;
Original file line number Diff line number Diff line change 1
1
/*
2
- * DELETE THIS FILE AND EVERYTHING IN IT .
2
+ * DELETE THIS FILE. EVERYTHING NEEDS TO FIND A HOME .
3
3
*/
4
4
import { list } from 'plotly.js/src/plots/cartesian/axis_ids' ;
5
+ import { UnconnectedNumeric } from './components/fields/Numeric' ;
6
+ import {
7
+ connectLayoutToPlot ,
8
+ connectToContainer ,
9
+ getLayoutContext ,
10
+ unpackPlotProps ,
11
+ } from './lib' ;
5
12
6
13
export function noShame ( opts ) {
7
14
if ( opts . plotly && ! opts . plotly . Axes ) {
@@ -10,3 +17,27 @@ export function noShame(opts) {
10
17
} ;
11
18
}
12
19
}
20
+
21
+ class NumericNoArrows extends UnconnectedNumeric { }
22
+ NumericNoArrows . propTypes = UnconnectedNumeric . propTypes ;
23
+ NumericNoArrows . defaultProps = {
24
+ showArrows : false ,
25
+ } ;
26
+
27
+ export const BoxGap = connectLayoutToPlot (
28
+ connectToContainer ( NumericNoArrows , {
29
+ supplyPlotProps : ( props , context ) => {
30
+ // workaround the issue with nested layouts inside trace component.
31
+ // See
32
+ // https://github.com/plotly/react-plotly.js-editor/issues/58#issuecomment-345492794
33
+ const plotProps = unpackPlotProps ( props , {
34
+ ...context ,
35
+ ...getLayoutContext ( context ) ,
36
+ } ) ;
37
+
38
+ // Full value should multiply by percentage if number.
39
+
40
+ return plotProps ;
41
+ } ,
42
+ } )
43
+ ) ;
You can’t perform that action at this time.
0 commit comments