Skip to content

Commit cb591cb

Browse files
authored
Merge pull request #313 from plotly/histogram
Histogram & Histogram 2d adjustments
2 parents a061c56 + 55ae918 commit cb591cb

File tree

3 files changed

+57
-4
lines changed

3 files changed

+57
-4
lines changed

src/components/containers/TraceMarkerSection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TraceMarkerSection extends Component {
1616
setLocals(context) {
1717
const _ = this.props.localize;
1818
const traceType = context.fullContainer._fullInput.type;
19-
if (traceType === 'bar') {
19+
if (['bar', 'histogram'].includes(traceType)) {
2020
this.name = _('Bars');
2121
} else {
2222
this.name = _('Points');

src/components/fields/derived.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,38 @@ export const TraceOrientation = connectToContainer(UnconnectedRadio, {
5959
ysrc: context.container.xsrc,
6060
});
6161
}
62+
63+
if (
64+
context.container.type === 'histogram' &&
65+
plotProps.fullValue === 'v' &&
66+
context.container.y &&
67+
context.container.y.length !== 0
68+
) {
69+
context.updateContainer({
70+
y: null,
71+
ysrc: null,
72+
ybins: null,
73+
x: context.container.y,
74+
xsrc: context.container.ysrc,
75+
xbins: context.container.ybins,
76+
});
77+
}
78+
79+
if (
80+
context.container.type === 'histogram' &&
81+
plotProps.fullValue === 'h' &&
82+
context.container.x &&
83+
context.container.x.length !== 0
84+
) {
85+
context.updateContainer({
86+
x: null,
87+
xsrc: null,
88+
xbins: null,
89+
y: context.container.x,
90+
ysrc: context.container.xsrc,
91+
ybins: context.container.xbins,
92+
});
93+
}
6294
},
6395
});
6496

src/default_panels/GraphCreatePanel.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,30 @@ const GraphCreatePanel = ({localize: _}) => {
2626
<DataSelector label={_('Locations')} attr="locations" />
2727
<DataSelector label={_('Latitude')} attr="lat" />
2828
<DataSelector label={_('Longitude')} attr="lon" />
29-
<DataSelector label={_('X')} attr="x" />
30-
<DataSelector label={_('Y')} attr="y" />
31-
<DataSelector label={{choropleth: _('Values'), '*': _('Z')}} attr="z" />
29+
<DataSelector
30+
label={{
31+
histogram2d: _('X Values'),
32+
histogram: _('X Values'),
33+
'*': _('X'),
34+
}}
35+
attr="x"
36+
/>
37+
<DataSelector
38+
label={{
39+
histogram2d: _('Y Values'),
40+
histogram: _('Y Values'),
41+
'*': _('Y'),
42+
}}
43+
attr="y"
44+
/>
45+
<DataSelector
46+
label={{
47+
choropleth: _('Values'),
48+
histogram2d: _('Z Values'),
49+
'*': _('Z'),
50+
}}
51+
attr="z"
52+
/>
3253
<DataSelector label={_('I (Optional)')} attr="i" />
3354
<DataSelector label={_('J (Optional)')} attr="j" />
3455
<DataSelector label={_('K (Optional)')} attr="k" />

0 commit comments

Comments
 (0)