Skip to content

Commit b865622

Browse files
committed
Only allow creation of new axes for cartesian types for now
1 parent 0a6a533 commit b865622

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

src/components/containers/Section.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
containerConnectedContextTypes,
55
localize,
66
unpackPlotProps,
7+
traceTypeToAxisType,
78
} from '../../lib';
89

910
class Section extends Component {
@@ -36,7 +37,13 @@ class Section extends Component {
3637
}
3738

3839
if ((child.type.plotly_editor_traits || {}).is_axis_creator) {
39-
if (this.context.data.length > 1) {
40+
const {data, fullContainer} = this.context;
41+
42+
// for now, only allowing for cartesian chart types
43+
if (
44+
data.length > 1 &&
45+
traceTypeToAxisType(data[fullContainer.index].type) === 'cartesian'
46+
) {
4047
this.sectionVisible = true;
4148
return cloneElement(child, {
4249
isVisible: true,

src/components/fields/AxesSelector.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default class AxesSelector extends Component {
3030
<Field {...this.props} center>
3131
{hasSecondaryAxis ? (
3232
<Dropdown
33+
label={_('Select Axis')}
3334
options={axesOptions.map(option => {
3435
if (option.value !== 'allaxes') {
3536
return {

src/components/fields/AxisCreator.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ export class UnconnectedAxisCreator extends Component {
2323
context.data.filter(d => d.type === props.container.type).length === 1;
2424

2525
function getNewSubplot(axis, subplot) {
26-
const ok = isFirstTraceOfType
26+
return isFirstTraceOfType
2727
? axis
2828
: axis + (context.fullLayout._subplots[subplot].length + 1);
29-
return ok;
3029
}
3130

3231
function getAxisControl(label, attr, subplot, update) {

src/lib/getAllAxes.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,9 @@ export function traceTypeToAxisType(traceType) {
5555
return category;
5656
}
5757

58+
if (traceType === 'pie') {
59+
return null;
60+
}
61+
5862
throw new Error(`Sorry, could not find ${traceType} in any category.`);
5963
}

0 commit comments

Comments
 (0)