Skip to content

Commit dd5ff48

Browse files
committed
add funnel - changes to src plot plot_api and legend style
1 parent 3832e01 commit dd5ff48

File tree

6 files changed

+28
-11
lines changed

6 files changed

+28
-11
lines changed

src/components/drawing/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ drawing.hideOutsideRangePoints = function(traceGroups, subplot) {
110110
var trace = d[0].trace;
111111
var xcalendar = trace.xcalendar;
112112
var ycalendar = trace.ycalendar;
113-
var selector = trace.type === 'bar' ? '.bartext' :
113+
var selector =
114+
trace.type === 'bar' ? '.bartext' :
114115
trace.type === 'waterfall' ? '.bartext,.line' :
116+
trace.type === 'funnel' ? '.bartext,.line,.region' :
115117
'.point,.textpoint';
116118

117119
traceGroups.selectAll(selector).each(function(d) {

src/components/legend/style.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ module.exports = function style(s, gd) {
8484
.classed('legendpoints', true);
8585
})
8686
.each(styleWaterfalls)
87+
.each(styleFunnels)
8788
.each(styleBars)
8889
.each(styleBoxes)
8990
.each(stylePies)
@@ -306,14 +307,25 @@ module.exports = function style(s, gd) {
306307
}
307308

308309
function styleBars(d) {
310+
styleBarFamily(d, this);
311+
}
312+
313+
function styleFunnels(d) {
314+
styleBarFamily(d, this, 'funnel');
315+
}
316+
317+
function styleBarFamily(d, lThis, desiredType) {
309318
var trace = d[0].trace;
310319
var marker = trace.marker || {};
311320
var markerLine = marker.line || {};
312321

313-
var barpath = d3.select(this).select('g.legendpoints')
314-
.selectAll('path.legendbar')
315-
.data(Registry.traceIs(trace, 'bar') ? [d] : []);
316-
barpath.enter().append('path').classed('legendbar', true)
322+
var selection = (!desiredType) ? Registry.traceIs(trace, 'bar') :
323+
(trace.type === desiredType && trace.visible);
324+
325+
var barpath = d3.select(lThis).select('g.legendpoints')
326+
.selectAll('path.legend' + desiredType)
327+
.data(selection ? [d] : []);
328+
barpath.enter().append('path').classed('legend' + desiredType, true)
317329
.attr('d', 'M6,6H-6V-6H6Z')
318330
.attr('transform', 'translate(20,0)');
319331
barpath.exit().remove();

src/plot_api/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ exports.cleanData = function(data) {
328328
trace.scene = Plots.subplotsRegistry.gl3d.cleanId(trace.scene);
329329
}
330330

331-
if(!traceIs(trace, 'pie') && !traceIs(trace, 'bar') && trace.type !== 'waterfall') {
331+
if(!traceIs(trace, 'pie') && !traceIs(trace, 'bar') && trace.type !== 'waterfall' && trace.type !== 'funnel') {
332332
if(Array.isArray(trace.textposition)) {
333333
for(i = 0; i < trace.textposition.length; i++) {
334334
trace.textposition[i] = cleanTextPosition(trace.textposition[i]);

src/plots/cartesian/axes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,7 +1647,7 @@ axes.drawOne = function(gd, ax, opts) {
16471647
vals[i].axInfo = axInfo;
16481648
}
16491649

1650-
if(!ax.visible) return;
1650+
if(!ax.visible || ax._hide) return;
16511651

16521652
// stash selections to avoid DOM queries e.g.
16531653
// - stash tickLabels selection, so that drawTitle can use it to scoot title
@@ -2813,7 +2813,7 @@ function hasBarsOrFill(gd, ax) {
28132813

28142814
if(trace.visible === true && (trace.xaxis + trace.yaxis) === subplot) {
28152815
if(
2816-
(Registry.traceIs(trace, 'bar') || trace.type === 'waterfall') &&
2816+
(Registry.traceIs(trace, 'bar') || trace.type === 'waterfall' || trace.type === 'funnel') &&
28172817
trace.orientation === {x: 'h', y: 'v'}[axLetter]
28182818
) return true;
28192819

src/plots/cartesian/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ module.exports = {
6565
traceLayerClasses: [
6666
'heatmaplayer',
6767
'contourcarpetlayer', 'contourlayer',
68-
'waterfalllayer', 'barlayer',
68+
'funnellayer', 'waterfalllayer', 'barlayer',
6969
'carpetlayer',
7070
'violinlayer',
7171
'boxlayer',

src/plots/cartesian/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,10 @@ function plotOne(gd, plotinfo, cdSubplot, transitionOpts, makeOnCompleteCallback
260260
);
261261

262262
// layers that allow `cliponaxis: false`
263-
if(className !== 'scatterlayer' && className !== 'barlayer' && className !== 'waterfalllayer') {
263+
if(className !== 'scatterlayer' &&
264+
className !== 'barlayer' &&
265+
className !== 'funnellayer' &&
266+
className !== 'waterfalllayer') {
264267
Drawing.setClipUrl(sel, plotinfo.layerClipId, gd);
265268
}
266269
});
@@ -276,7 +279,7 @@ function plotOne(gd, plotinfo, cdSubplot, transitionOpts, makeOnCompleteCallback
276279
if(!gd._context.staticPlot) {
277280
if(plotinfo._hasClipOnAxisFalse) {
278281
plotinfo.clipOnAxisFalseTraces = plotinfo.plot
279-
.selectAll('.scatterlayer, .barlayer, .waterfalllayer')
282+
.selectAll('.scatterlayer, .barlayer, .funnellayer, .waterfalllayer')
280283
.selectAll('.trace');
281284
}
282285

0 commit comments

Comments
 (0)