Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathmake_trace_groups.js
More file actions
Latest commit
33 lines (26 loc) · 1.11 KB
/
Copy pathmake_trace_groups.js
File metadata and controls
33 lines (26 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
vard3=require('@plotly/d3');
/**
* General helper to manage trace groups based on calcdata
*
* @param {d3.selection} traceLayer: a selection containing a single group
* to draw these traces into
* @param {array} cdModule: array of calcdata items for this
* module and subplot combination. Assumes the calcdata item for each
* trace is an array with the fullData trace attached to the first item.
* @param {string} cls: the class attribute to give each trace group
* so you can give multiple classes separated by spaces
*/
module.exports=functionmakeTraceGroups(traceLayer,cdModule,cls){
vartraces=traceLayer.selectAll('g.'+cls.replace(/\s/g,'.'))
.data(cdModule,function(cd){returncd[0].trace.uid;});
traces.exit().remove();
traces.enter().append('g')
.attr('class',cls);
traces.order();
// stash ref node to trace group in calcdata,
// useful for (fast) styleOnSelect
vark=traceLayer.classed('rangeplot') ? 'nodeRangePlot3' : 'node3';
traces.each(function(cd){cd[0][k]=d3.select(this);});
returntraces;
};