Skip to content

Commit f75c013

Browse files
committed
correct histogram binning options
1 parent 5645d6f commit f75c013

File tree

3 files changed

+58
-32
lines changed

3 files changed

+58
-32
lines changed

src/components/fields/derived.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,19 @@ export const BinningNumeric = connectToContainer(UnconnectedNumeric, {
127127
export const BinningDropdown = connectToContainer(UnconnectedDropdown, {
128128
modifyPlotProps: (props, context, plotProps) => {
129129
const {localize: _} = context;
130-
plotProps.options =
131-
plotProps.fullContainer.orientation === 'v'
132-
? [
133-
{label: _('Count X'), value: 'count'},
134-
{label: _('Sum Y'), value: 'sum'},
135-
{label: _('Average Y'), value: 'avg'},
136-
{label: _('Minimum Y'), value: 'min'},
137-
{label: _('Maximum Y'), value: 'max'},
138-
]
139-
: [
140-
{label: _('Count Y'), value: 'count'},
141-
{label: _('Sum X'), value: 'sum'},
142-
{label: _('Average X'), value: 'avg'},
143-
{label: _('Minimum X'), value: 'min'},
144-
{label: _('Maximum X'), value: 'max'},
145-
];
130+
const axis =
131+
plotProps.fullContainer.type === 'histogram2d'
132+
? 'Z'
133+
: plotProps.fullContainer.orientation === 'v'
134+
? 'Y'
135+
: 'X';
136+
plotProps.options = [
137+
{label: _('Count ') + axis, value: 'count'},
138+
{label: _('Sum ') + axis, value: 'sum'},
139+
{label: _('Average ') + axis, value: 'avg'},
140+
{label: _('Minimum ') + axis, value: 'min'},
141+
{label: _('Maximum ') + axis, value: 'max'},
142+
];
146143
},
147144
});
148145

@@ -169,6 +166,13 @@ export const HistogramInfoHorizontal = connectToContainer(Info, {
169166
},
170167
});
171168

169+
export const Histogram2d = connectToContainer(Info, {
170+
modifyPlotProps: (props, context, plotProps) => {
171+
plotProps.isVisible = context.fullContainer.type === 'histogram2d';
172+
return plotProps;
173+
},
174+
});
175+
172176
export const AxesRange = connectToContainer(UnconnectedAxisRangeValue, {
173177
modifyPlotProps: (props, context, plotProps) => {
174178
const {fullContainer} = plotProps;

src/default_panels/GraphCreatePanel.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ import {
1212
TraceTypeSection,
1313
LocationSelector,
1414
} from '../components';
15-
import {HistogramInfoVertical, HistogramInfoHorizontal} from '../components/fields/derived';
15+
import {
16+
HistogramInfoVertical,
17+
HistogramInfoHorizontal,
18+
Histogram2d,
19+
} from '../components/fields/derived';
1620

17-
const GraphCreatePanel = (props, {localize: _}) => {
21+
const GraphCreatePanel = (props, {localize: _, setPanel}) => {
1822
return (
1923
<TraceAccordion
2024
canAdd
@@ -59,11 +63,26 @@ const GraphCreatePanel = (props, {localize: _}) => {
5963
options={[{label: _('Vertical'), value: 'v'}, {label: _('Horizontal'), value: 'h'}]}
6064
/>
6165
<HistogramInfoVertical>
62-
{_('Note: in vertical orientation, X values are used for bins and Y values for weights.')}
66+
{_(
67+
'Note: in vertical orientation, X values are used for binning. If Y values are provided, they are used as inputs to the histogram function which you can configure in the '
68+
)}
69+
<a onClick={() => setPanel('Style', 'Traces')}>{_('Traces')}</a>
70+
{_(' panel. If Y values are omitted, the histogram function defaults to Count.')}
6371
</HistogramInfoVertical>
6472
<HistogramInfoHorizontal>
65-
{_('Note: in horizontal orientation, Y Values are used for bins and X values for weights.')}
73+
{_(
74+
'Note: in horizontal orientation, Y values are used for binning. If X values are provided, they are used as inputs to the histogram function which you can configure in the '
75+
)}
76+
<a onClick={() => setPanel('Style', 'Traces')}>{_('Traces')}</a>
77+
{_(' panel. If X values are omitted, the histogram function defaults to Count.')}
6678
</HistogramInfoHorizontal>
79+
<Histogram2d>
80+
{_(
81+
'Note: X and Y Values are used for binning. If Z values are provided, they are used as inputs to the histogram function which you can configure in the '
82+
)}
83+
<a onClick={() => setPanel('Style', 'Traces')}>{_('Traces')}</a>
84+
{_(' panel. If Z values are omitted, the histogram function defaults to Count.')}
85+
</Histogram2d>
6786
<DataSelector label={_('I (Optional)')} attr="i" />
6887
<DataSelector label={_('J (Optional)')} attr="j" />
6988
<DataSelector label={_('K (Optional)')} attr="k" />
@@ -132,4 +151,5 @@ const GraphCreatePanel = (props, {localize: _}) => {
132151
export default GraphCreatePanel;
133152
GraphCreatePanel.contextTypes = {
134153
localize: PropTypes.func,
154+
setPanel: PropTypes.func,
135155
};

src/default_panels/StyleTracesPanel.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,20 @@ const StyleTracesPanel = (props, {localize: _}) => (
5151
<NumericFraction label={_('Trace Opacity')} attr="opacity" />
5252
<MultiColorPicker label={_('Color')} attr="color" />
5353
<PieColorscalePicker label={_('Colors')} attr="marker.colors" />
54-
<Dropdown
55-
label={_('Histogram Normalization')}
56-
options={[
57-
{label: _('Number of Occurences'), value: ''},
58-
{label: _('Percent'), value: 'percent'},
59-
{label: _('Probability'), value: 'probability'},
60-
{label: _('Density'), value: 'density'},
61-
{label: _('Probability Density'), value: 'probability density'},
62-
]}
63-
attr="histnorm"
64-
/>
54+
<PlotlySection name={_('Values')}>
55+
<BinningDropdown label={_('Histogram Function')} attr="histfunc" />
56+
<Dropdown
57+
label={_('Histogram Normalization')}
58+
options={[
59+
{label: _('Number of Occurences'), value: ''},
60+
{label: _('Percent'), value: 'percent'},
61+
{label: _('Probability'), value: 'probability'},
62+
{label: _('Density'), value: 'density'},
63+
{label: _('Probability Density'), value: 'probability density'},
64+
]}
65+
attr="histnorm"
66+
/>
67+
</PlotlySection>
6568
<PlotlySection name={_('Cumulative')}>
6669
<Radio
6770
label={_('Cumulative')}
@@ -139,7 +142,6 @@ const StyleTracesPanel = (props, {localize: _}) => (
139142
/>
140143
</PlotlySection>
141144
<PlotlySection name={_('Binning')}>
142-
<BinningDropdown label={_('Binning Function')} attr="histfunc" />
143145
<Radio
144146
label={_('X Binning')}
145147
attr="autobinx"

0 commit comments

Comments
 (0)