Skip to content

Commit 1f01fc6

Browse files
clean up axis type and tick placement UX
1 parent 62e7448 commit 1f01fc6

File tree

6 files changed

+57
-15
lines changed

6 files changed

+57
-15
lines changed

src/components/fields/derived.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,34 @@ export const AxesRange = connectToContainer(UnconnectedAxisRangeValue, {
235235
},
236236
});
237237

238+
export const NTicks = connectToContainer(UnconnectedNumeric, {
239+
modifyPlotProps: (props, context, plotProps) => {
240+
const {fullContainer} = plotProps;
241+
if (
242+
plotProps.isVisible &&
243+
fullContainer &&
244+
fullContainer.tickmode !== 'auto'
245+
) {
246+
plotProps.isVisible = false;
247+
}
248+
return plotProps;
249+
},
250+
});
251+
252+
export const DTicks = connectToContainer(UnconnectedAxisRangeValue, {
253+
modifyPlotProps: (props, context, plotProps) => {
254+
const {fullContainer} = plotProps;
255+
if (
256+
plotProps.isVisible &&
257+
fullContainer &&
258+
fullContainer.tickmode !== 'linear'
259+
) {
260+
plotProps.isVisible = false;
261+
}
262+
return plotProps;
263+
},
264+
});
265+
238266
class UnconnectedNumericFraction extends UnconnectedNumeric {}
239267
UnconnectedNumericFraction.propTypes = UnconnectedNumeric.propTypes;
240268
UnconnectedNumericFraction.defaultProps = {

src/components/fields/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import {
2323
AnnotationRef,
2424
PositioningRef,
2525
AxesRange,
26+
NTicks,
27+
DTicks,
2628
AxisAnchorDropdown,
2729
CanvasSize,
2830
ContourNumeric,
@@ -51,6 +53,8 @@ export {
5153
PositioningRef,
5254
ArrowSelector,
5355
AxesRange,
56+
NTicks,
57+
DTicks,
5458
AxesSelector,
5559
CanvasSize,
5660
ColorPicker,

src/components/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {
77
PositioningRef,
88
ArrowSelector,
99
AxesRange,
10+
NTicks,
11+
DTicks,
1012
AxesSelector,
1113
CanvasSize,
1214
ColorPicker,
@@ -75,6 +77,8 @@ export {
7577
AxisAnchorDropdown,
7678
AxisOverlayDropdown,
7779
AxisSide,
80+
NTicks,
81+
DTicks,
7882
ShapeAccordion,
7983
RangeSelectorAccordion,
8084
SliderAccordion,

src/components/widgets/TextInput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default class TextInput extends Component {
3030
}
3131

3232
TextInput.propTypes = {
33-
defaultValue: PropTypes.number,
33+
defaultValue: PropTypes.string,
3434
editableClassName: PropTypes.string,
3535
onUpdate: PropTypes.func.isRequired,
3636
placeholder: PropTypes.string,

src/default_panels/StyleAxesPanel.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
AxisOverlayDropdown,
66
AxisSide,
77
AxesRange,
8-
AxisRangeValue,
8+
DTicks,
9+
NTicks,
910
ColorPicker,
1011
Dropdown,
1112
FontSelector,
@@ -88,9 +89,10 @@ class StyleAxesPanel extends Component {
8889

8990
<AxesFold name={_('Range')}>
9091
<Section name={_('Range')} attr="autorange">
91-
<Radio
92+
<Dropdown
9293
attr="type"
9394
label={_('Type')}
95+
clearable={false}
9496
options={[
9597
{label: _('Linear'), value: 'linear'},
9698
{label: _('Log'), value: 'log'},
@@ -274,18 +276,18 @@ class StyleAxesPanel extends Component {
274276
/>
275277
</Section>
276278

277-
<Section name={_('Number of Labels')} attr="dtick">
279+
<Section name={_('Placement')} attr="dtick">
278280
<Radio
279281
attr="tickmode"
280282
options={[
281-
{label: _('Linear'), value: 'linear'},
282-
{label: _('Custom'), value: 'auto'},
283+
{label: _('Auto'), value: 'auto'},
284+
{label: _('Custom'), value: 'linear'},
283285
]}
284286
/>
285287

286-
<AxisRangeValue label={_('Step Offset')} attr="tick0" />
287-
<AxisRangeValue label={_('Step Size')} attr="dtick" />
288-
<Numeric label={_('Max Number of Labels')} attr="nticks" />
288+
<DTicks label={_('Step Offset')} attr="tick0" />
289+
<DTicks label={_('Step Size')} attr="dtick" />
290+
<NTicks label={_('Max Number of Labels')} attr="nticks" />
289291
</Section>
290292
</AxesFold>
291293
<AxesFold name={_('Tick Markers')}>
@@ -302,18 +304,18 @@ class StyleAxesPanel extends Component {
302304
<Numeric label={_('Width')} attr="tickwidth" units="px" />
303305
<ColorPicker label={_('Tick Color')} attr="tickcolor" />
304306
</Section>
305-
<Section name={_('Number of Markers')}>
307+
<Section name={_('Placement')}>
306308
<Radio
307309
attr="tickmode"
308310
options={[
309-
{label: _('Linear'), value: 'linear'},
310-
{label: _('Custom'), value: 'auto'},
311+
{label: _('Auto'), value: 'auto'},
312+
{label: _('Custom'), value: 'linear'},
311313
]}
312314
/>
313315

314-
<AxisRangeValue label={_('Step Offset')} attr="tick0" />
315-
<AxisRangeValue label={_('Step Size')} attr="dtick" />
316-
<Numeric label={_('Max Number of Markers')} attr="nticks" />
316+
<DTicks label={_('Step Offset')} attr="tick0" />
317+
<DTicks label={_('Step Size')} attr="dtick" />
318+
<NTicks label={_('Max Number of Markers')} attr="nticks" />
317319
</Section>
318320
</AxesFold>
319321

src/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import {
2828
ArrowSelector,
2929
AxesFold,
3030
AxesRange,
31+
NTicks,
32+
DTicks,
3133
AxesSelector,
3234
Button,
3335
CanvasSize,
@@ -94,6 +96,8 @@ export {
9496
ArrowSelector,
9597
AxesFold,
9698
AxesRange,
99+
NTicks,
100+
DTicks,
97101
AxesSelector,
98102
Button,
99103
CanvasSize,

0 commit comments

Comments
 (0)