Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-chart-editor",
"description": "plotly.js chart editor react component UI",
"version": "0.32.0",
"version": "0.32.1",
"author": "Plotly, Inc.",
"bugs": {
"url": "https://github.com/plotly/react-chart-editor/issues"
Expand Down
2 changes: 2 additions & 0 deletions src/EditorControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
shamefullyCreateSplitStyleProps,
shamefullyAdjustSplitStyleTargetContainers,
shamefullyDeleteRelatedAnalysisTransforms,
shamefullyAdjustSizeref,
} from './shame';
import {EDITOR_ACTIONS} from './lib/constants';
import isNumeric from 'fast-isnumeric';
Expand Down Expand Up @@ -70,6 +71,7 @@ class EditorControls extends Component {
this.props.beforeUpdateTraces(payload);
}

shamefullyAdjustSizeref(graphDiv, payload);
shamefullyClearAxisTypes(graphDiv, payload);
shamefullyAdjustAxisRef(graphDiv, payload);
shamefullyAddTableColumns(graphDiv, payload);
Expand Down
2 changes: 1 addition & 1 deletion src/default_panels/StyleTracesPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ const StyleTracesPanel = (props, {localize: _}) => (
<Radio
label={_('Size Mode')}
attr="marker.sizemode"
options={[{label: _('Diameter'), value: 'diameter'}, {label: _('Area'), value: 'area'}]}
options={[{label: _('Area'), value: 'area'}, {label: _('Diameter'), value: 'diameter'}]}
/>
<Numeric label={_('Minimum Size')} attr="marker.sizemin" />
<NumericReciprocal label={_('Size Scale')} attr="marker.sizeref" />
Expand Down
10 changes: 10 additions & 0 deletions src/shame.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,13 @@ export const shamefullyDeleteRelatedAnalysisTransforms = (graphDiv, payload) =>
}
}
};

export const shamefullyAdjustSizeref = (gd, {update}) => {
const {'marker.size': size = null, 'marker.sizesrc': src = null} = update;
if (size && src) {
const DEFAULT_MAX_AREA_PX = 45;
const scaleFactor = DEFAULT_MAX_AREA_PX * DEFAULT_MAX_AREA_PX;
update['marker.sizeref'] = size.reduce((a, b) => Math.max(a, b)) / scaleFactor;
update['marker.sizemode'] = 'area';
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, it seems like this is a good place to put that code in.
So we can never use size.mode diameter when there's a sizeref..?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can, you just have to set it yourself after. It's almost always the wrong thing to do tho, so I'm OK with forcing it back every time you switch that dropdown.