Skip to content

Commit 25722c1

Browse files
Merge pull request #772 from plotly/autosize
preset sizeref reasonably
2 parents e780863 + 9fb53c7 commit 25722c1

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-chart-editor",
33
"description": "plotly.js chart editor react component UI",
4-
"version": "0.32.0",
4+
"version": "0.32.1",
55
"author": "Plotly, Inc.",
66
"bugs": {
77
"url": "https://github.com/plotly/react-chart-editor/issues"

src/EditorControls.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
shamefullyCreateSplitStyleProps,
1111
shamefullyAdjustSplitStyleTargetContainers,
1212
shamefullyDeleteRelatedAnalysisTransforms,
13+
shamefullyAdjustSizeref,
1314
} from './shame';
1415
import {EDITOR_ACTIONS} from './lib/constants';
1516
import isNumeric from 'fast-isnumeric';
@@ -70,6 +71,7 @@ class EditorControls extends Component {
7071
this.props.beforeUpdateTraces(payload);
7172
}
7273

74+
shamefullyAdjustSizeref(graphDiv, payload);
7375
shamefullyClearAxisTypes(graphDiv, payload);
7476
shamefullyAdjustAxisRef(graphDiv, payload);
7577
shamefullyAddTableColumns(graphDiv, payload);

src/default_panels/StyleTracesPanel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ const StyleTracesPanel = (props, {localize: _}) => (
246246
<Radio
247247
label={_('Size Mode')}
248248
attr="marker.sizemode"
249-
options={[{label: _('Diameter'), value: 'diameter'}, {label: _('Area'), value: 'area'}]}
249+
options={[{label: _('Area'), value: 'area'}, {label: _('Diameter'), value: 'diameter'}]}
250250
/>
251251
<Numeric label={_('Minimum Size')} attr="marker.sizemin" />
252252
<NumericReciprocal label={_('Size Scale')} attr="marker.sizeref" />

src/shame.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,13 @@ export const shamefullyDeleteRelatedAnalysisTransforms = (graphDiv, payload) =>
202202
}
203203
}
204204
};
205+
206+
export const shamefullyAdjustSizeref = (gd, {update}) => {
207+
const {'marker.size': size = null, 'marker.sizesrc': src = null} = update;
208+
if (size && src) {
209+
const DEFAULT_MAX_AREA_PX = 45;
210+
const scaleFactor = DEFAULT_MAX_AREA_PX * DEFAULT_MAX_AREA_PX;
211+
update['marker.sizeref'] = size.reduce((a, b) => Math.max(a, b)) / scaleFactor;
212+
update['marker.sizemode'] = 'area';
213+
}
214+
};

0 commit comments

Comments
 (0)