Skip to content

Commit cc99d18

Browse files
committed
add group positioning options to scatter
1 parent f10b777 commit cc99d18

File tree

10 files changed

+64
-28
lines changed

10 files changed

+64
-28
lines changed

src/traces/bar/attributes.js

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -196,27 +196,8 @@ module.exports = {
196196

197197
marker: marker,
198198

199-
offsetgroup: {
200-
valType: 'string',
201-
dflt: '',
202-
editType: 'calc',
203-
description: [
204-
'Set several traces linked to the same position axis',
205-
'or matching axes to the same',
206-
'offsetgroup where bars of the same position coordinate will line up.'
207-
].join(' ')
208-
},
209-
alignmentgroup: {
210-
valType: 'string',
211-
dflt: '',
212-
editType: 'calc',
213-
description: [
214-
'Set several traces linked to the same position axis',
215-
'or matching axes to the same',
216-
'alignmentgroup. This controls whether bars compute their positional',
217-
'range dependently or independently.'
218-
].join(' ')
219-
},
199+
offsetgroup: scatterAttrs.offsetgroup,
200+
alignmentgroup: scatterAttrs.alignmentgroup,
220201

221202
selected: {
222203
marker: {

src/traces/bar/defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var Registry = require('../../registry');
77
var handleXYDefaults = require('../scatter/xy_defaults');
88
var handlePeriodDefaults = require('../scatter/period_defaults');
99
var handleStyleDefaults = require('./style_defaults');
10-
var handleGroupingDefaults = require('./grouping_defaults');
10+
var handleGroupingDefaults = require('../scatter/grouping_defaults');
1111
var attributes = require('./attributes');
1212

1313
var coerceFont = Lib.coerceFont;

src/traces/box/defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var Lib = require('../../lib');
44
var Registry = require('../../registry');
55
var Color = require('../../components/color');
66
var handlePeriodDefaults = require('../scatter/period_defaults');
7-
var handleGroupingDefaults = require('../bar/grouping_defaults');
7+
var handleGroupingDefaults = require('../scatter/grouping_defaults');
88
var autoType = require('../../plots/cartesian/axis_autotype');
99
var attributes = require('./attributes');
1010

src/traces/funnel/defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var Lib = require('../../lib');
44

5-
var handleGroupingDefaults = require('../bar/grouping_defaults');
5+
var handleGroupingDefaults = require('../scatter/grouping_defaults');
66
var handleText = require('../bar/defaults').handleText;
77
var handleXYDefaults = require('../scatter/xy_defaults');
88
var handlePeriodDefaults = require('../scatter/period_defaults');

src/traces/histogram/cross_trace_defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var Lib = require('../../lib');
44
var axisIds = require('../../plots/cartesian/axis_ids');
55

66
var traceIs = require('../../registry').traceIs;
7-
var handleGroupingDefaults = require('../bar/grouping_defaults');
7+
var handleGroupingDefaults = require('../scatter/grouping_defaults');
88

99
var nestedProperty = Lib.nestedProperty;
1010
var getAxisGroup = require('../../plots/cartesian/constraints').getAxisGroup;

src/traces/scatter/attributes.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,29 @@ module.exports = {
123123
xhoverformat: axisHoverFormat('x'),
124124
yhoverformat: axisHoverFormat('y'),
125125

126+
offsetgroup: {
127+
valType: 'string',
128+
dflt: '',
129+
editType: 'calc',
130+
description: [
131+
'Set several traces linked to the same position axis',
132+
'or matching axes to the same',
133+
'offsetgroup where bars of the same position coordinate will line up.'
134+
].join(' ')
135+
},
136+
137+
alignmentgroup: {
138+
valType: 'string',
139+
dflt: '',
140+
editType: 'calc',
141+
description: [
142+
'Set several traces linked to the same position axis',
143+
'or matching axes to the same',
144+
'alignmentgroup. This controls whether bars compute their positional',
145+
'range dependently or independently.'
146+
].join(' ')
147+
},
148+
126149
stackgroup: {
127150
valType: 'string',
128151
dflt: '',

src/traces/scatter/cross_trace_defaults.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
'use strict';
22

3+
var Lib = require('../../lib');
4+
var handleGroupingDefaults = require('./grouping_defaults');
5+
var attributes = require('./attributes');
36

47
// remove opacity for any trace that has a fill or is filled to
5-
module.exports = function crossTraceDefaults(fullData) {
6-
for(var i = 0; i < fullData.length; i++) {
8+
module.exports = function crossTraceDefaults(fullData, fullLayout) {
9+
var traceIn, traceOut, i;
10+
11+
function coerce(attr) {
12+
return Lib.coerce(traceOut._input, traceOut, attributes, attr);
13+
}
14+
15+
if(fullLayout.scattermode === 'group') {
16+
for(i = 0; i < fullData.length; i++) {
17+
traceOut = fullData[i];
18+
19+
if(traceOut.type === 'scatter') {
20+
traceIn = traceOut._input;
21+
handleGroupingDefaults(traceIn, traceOut, fullLayout, coerce);
22+
}
23+
}
24+
}
25+
26+
for(i = 0; i < fullData.length; i++) {
727
var tracei = fullData[i];
828
if(tracei.type !== 'scatter') continue;
929

src/traces/waterfall/defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var Lib = require('../../lib');
44

5-
var handleGroupingDefaults = require('../bar/grouping_defaults');
5+
var handleGroupingDefaults = require('../scatter/grouping_defaults');
66
var handleText = require('../bar/defaults').handleText;
77
var handleXYDefaults = require('../scatter/xy_defaults');
88
var handlePeriodDefaults = require('../scatter/period_defaults');

test/plot-schema.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42935,6 +42935,12 @@
4293542935
"scatter": {
4293642936
"animatable": true,
4293742937
"attributes": {
42938+
"alignmentgroup": {
42939+
"description": "Set several traces linked to the same position axis or matching axes to the same alignmentgroup. This controls whether bars compute their positional range dependently or independently.",
42940+
"dflt": "",
42941+
"editType": "calc",
42942+
"valType": "string"
42943+
},
4293842944
"cliponaxis": {
4293942945
"description": "Determines whether or not markers and text nodes are clipped about the subplot axes. To show markers and text nodes above axis lines and tick labels, make sure to set `xaxis.layer` and `yaxis.layer` to *below traces*.",
4294042946
"dflt": true,
@@ -44893,6 +44899,12 @@
4489344899
"editType": "style",
4489444900
"valType": "string"
4489544901
},
44902+
"offsetgroup": {
44903+
"description": "Set several traces linked to the same position axis or matching axes to the same offsetgroup where bars of the same position coordinate will line up.",
44904+
"dflt": "",
44905+
"editType": "calc",
44906+
"valType": "string"
44907+
},
4489644908
"opacity": {
4489744909
"description": "Sets the opacity of the trace.",
4489844910
"dflt": 1,

0 commit comments

Comments
 (0)