-
-
Notifications
You must be signed in to change notification settings - Fork 112
Test nested connections and add nested connection #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
adfecc9
74674e2
7ac3006
1ba847d
04c83ef
c3445bd
f1ce3ed
92661db
1c137f3
cd37d4c
94a27c1
96d2ba0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/* | ||
* DELETE THIS FILE. EVERYTHING NEEDS TO FIND A HOME. | ||
*/ | ||
import isNumeric from 'fast-isnumeric'; | ||
import {list} from 'plotly.js/src/plots/cartesian/axis_ids'; | ||
import {UnconnectedNumeric} from './components/fields/Numeric'; | ||
import { | ||
|
@@ -22,22 +23,67 @@ class NumericNoArrows extends UnconnectedNumeric {} | |
NumericNoArrows.propTypes = UnconnectedNumeric.propTypes; | ||
NumericNoArrows.defaultProps = { | ||
showArrows: false, | ||
postfix: '%', | ||
}; | ||
|
||
export const BoxGap = connectLayoutToPlot( | ||
// Workaround the issue with nested layouts inside trace component. | ||
// See: | ||
// https://github.com/plotly/react-plotly.js-editor/issues/58#issuecomment-345492794 | ||
const supplyLayoutPlotProps = (props, context) => { | ||
return unpackPlotProps(props, { | ||
...context, | ||
...getLayoutContext(context), | ||
}); | ||
}; | ||
|
||
export const BoxWidth = connectLayoutToPlot( | ||
connectToContainer(NumericNoArrows, { | ||
supplyPlotProps: (props, context) => { | ||
// workaround the issue with nested layouts inside trace component. | ||
// See | ||
// https://github.com/plotly/react-plotly.js-editor/issues/58#issuecomment-345492794 | ||
const plotProps = unpackPlotProps(props, { | ||
...context, | ||
...getLayoutContext(context), | ||
}); | ||
|
||
// Full value should multiply by percentage if number. | ||
|
||
return plotProps; | ||
supplyPlotProps: supplyLayoutPlotProps, | ||
modifyPlotProps: (props, context, plotProps) => { | ||
const {fullValue, updatePlot} = plotProps; | ||
plotProps.fullValue = () => { | ||
let fv = fullValue(); | ||
if (isNumeric(fv)) { | ||
fv = Math.round((1 - fv) * 100); | ||
} | ||
return fv; | ||
}; | ||
|
||
plotProps.updatePlot = v => { | ||
if (isNumeric(v)) { | ||
updatePlot(1 - v / 100); | ||
} else { | ||
updatePlot(v); | ||
} | ||
}; | ||
|
||
plotProps.max = 100; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right now all of these have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good point will do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
}, | ||
}) | ||
); | ||
|
||
export const BoxPad = connectLayoutToPlot( | ||
connectToContainer(NumericNoArrows, { | ||
supplyPlotProps: supplyLayoutPlotProps, | ||
modifyPlotProps: (props, context, plotProps) => { | ||
const {fullValue, updatePlot} = plotProps; | ||
plotProps.fullValue = () => { | ||
let fv = fullValue(); | ||
if (isNumeric(fv)) { | ||
fv = fv * 100; | ||
} | ||
return fv; | ||
}; | ||
|
||
plotProps.updatePlot = v => { | ||
if (isNumeric(v)) { | ||
updatePlot(v / 100); | ||
} else { | ||
updatePlot(v); | ||
} | ||
}; | ||
|
||
plotProps.max = 100; | ||
}, | ||
}) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps
FractionalWidth
? OrLayoutWidthFraction
? Violin is going to use this too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep works for me 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something like 1bebf70 ?