Skip to content

Commit

Permalink
hiddenslices -> hiddenlabels
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcjohnson committed Jul 24, 2015
1 parent 2965494 commit 6a98087
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion image_server/test/mocks/pie_scale_textpos_hideslices.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@
"width": 600,
"showlegend": true,
"font": {"size": 20},
"hiddenslices": ["x","y"]
"hiddenlabels": ["x","y"]
}
}
2 changes: 1 addition & 1 deletion shelly/plotlyjs/static/plotlyjs/src/graph_obj.js
Original file line number Diff line number Diff line change
Expand Up @@ -3101,7 +3101,7 @@ Plotly.relayout = function relayout (gd, astr, val) {
// 3d or geo at this point just needs to redraw.
if (p.parts[0].indexOf('scene') === 0) doplot = true;
else if (p.parts[0].indexOf('geo') === 0) doplot = true;
else if(ai === 'hiddenslices') docalc = true;
else if(ai === 'hiddenlabels') docalc = true;
else if(p.parts[0].indexOf('legend')!==-1) dolegend = true;
else if(ai.indexOf('title')!==-1) doticks = true;
else if(p.parts[0].indexOf('bgcolor')!==-1) dolayoutstyle = true;
Expand Down
4 changes: 2 additions & 2 deletions shelly/plotlyjs/static/plotlyjs/src/legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ legend.draw = function(td, showlegend) {

var opts = fullLayout.legend,
legendData = legend.getLegendData(td.calcdata, opts),
hiddenSlices = fullLayout.hiddenslices || [];
hiddenSlices = fullLayout.hiddenlabels || [];

if(!showlegend || !legendData.length) {
fullLayout._infolayer.selectAll('.legend').remove();
Expand Down Expand Up @@ -537,7 +537,7 @@ legend.draw = function(td, showlegend) {
if(thisLabelIndex === -1) newHiddenSlices.push(thisLabel);
else newHiddenSlices.splice(thisLabelIndex, 1);

Plotly.relayout(td, 'hiddenslices', newHiddenSlices);
Plotly.relayout(td, 'hiddenlabels', newHiddenSlices);
} else {
if(legendgroup === '') {
traceIndicesInGroup = [trace.index];
Expand Down
12 changes: 6 additions & 6 deletions shelly/plotlyjs/static/plotlyjs/src/pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pie.attributes = {
dflt: ''
},

// labels (legend is handled by plots.attributes.showlegend and layout.hiddenslices)
// labels (legend is handled by plots.attributes.showlegend and layout.hiddenlabels)
textinfo: {
type: 'flaglist',
flags: ['label', 'text', 'value', 'percent'],
Expand Down Expand Up @@ -230,18 +230,18 @@ pie.supplyDefaults = function(traceIn, traceOut, defaultColor, layout) {

pie.layoutAttributes = {
/**
* hiddenslices is the pie chart analog of visible:'legendonly'
* hiddenlabels is the pie chart analog of visible:'legendonly'
* but it can contain many labels, and can hide slices
* from several pies simultaneously
*/
hiddenslices: {type: 'data_array'}
hiddenlabels: {type: 'data_array'}
};

pie.supplyLayoutDefaults = function(layoutIn, layoutOut) {
function coerce(attr, dflt) {
return Plotly.Lib.coerce(layoutIn, layoutOut, pie.layoutAttributes, attr, dflt);
}
coerce('hiddenslices');
coerce('hiddenlabels');
};

pie.calc = function(gd, trace) {
Expand All @@ -253,7 +253,7 @@ pie.calc = function(gd, trace) {
allThisTraceLabels = {},
needDefaults = false,
vTotal = 0,
hiddenSlices = fullLayout.hiddenslices || [],
hiddenLabels = fullLayout.hiddenlabels || [],
i,
v,
label,
Expand Down Expand Up @@ -297,7 +297,7 @@ pie.calc = function(gd, trace) {
needDefaults = true;
}

hidden = hiddenSlices.indexOf(label) !== -1;
hidden = hiddenLabels.indexOf(label) !== -1;

if(!hidden) vTotal += v;

Expand Down

2 comments on commit 6a98087

@Braintelligence
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexcjohnson Hi there. Due to the nature of hidden = hiddenLabels.indexOf(label) you can't have labels with the same name and expect to filter them independently.
This leads to a problem for #689 where even if legend group titles are implemented, you couldn't aggregate same labels under different legend group titles without keeping a sane filtering function.

@alexcjohnson
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Braintelligence Interesting - I see you opened #3089 related to this, there's also #2858 that has some similar concerns. Seems like we may want the items we're filtering / coloring to be composites of label and legendgroup... lets discuss in issues though, either those two or another if the topic is sufficiently distinct.

Please sign in to comment.