10000 Add `visible` attribute to layout container items. by etpinard · Pull Request #1110 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Add visible attribute to layout container items. #1110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Nov 7, 2016
Next Next commit
lib: generalize filterVisible utils
- so that all array containers (not just gd.data) can use it.
  • Loading branch information
etpinard committed Nov 3, 2016
commit de5075623430b0b7a3f1e1e391f906947e00182f
19 changes: 13 additions & 6 deletions src/lib/filter_visible.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@

'use strict';

module.exports = function filterVisible(dataIn) {
var dataOut = [];
/** Filter out object items with visible !== true
* insider array container.
*
* @param {array of objects} container
* @return {array of objects} of length <= container
*
*/
module.exports = function filterVisible(container) {
var out = [];

for(var i = 0; i < dataIn.length; i++) {
var trace = dataIn[i];
for(var i = 0; i < container.length; i++) {
var item = container[i];

if(trace.visible === true) dataOut.push(trace);
if(item.visible === true) out.push(item);
}

return dataOut;
return out;
};
2 changes: 2 additions & 0 deletions src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ lib.error = loggersModule.error;
lib.notifier = require('./notifier');

lib.filterUnique = require('./filter_unique');
lib.filterVisible = require('./filter_visible');


/**
* swap x and y of the same attribute in container cont
Expand Down
3 changes: 1 addition & 2 deletions src/plots/ternary/ternary.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ var Drawing = require('../../components/drawing');
var setConvert = require('../cartesian/set_convert');
var extendFlat = require('../../lib/extend').extendFlat;
var Axes = require('../cartesian/axes');
var filterVisible = require('../../lib/filter_visible');
var dragElement = require('../../components/dragelement');
var Titles = require('../../components/titles');
var prepSelect = require('../cartesian/select');
Expand Down Expand Up @@ -94,7 +93,7 @@ proto.plot = function(ternaryData, fullLayout) {
var moduleData = traceHash[moduleNames[i]];
var _module = moduleData[0]._module;

_module.plot(_this, filterVisible(moduleData), ternaryLayout);
_module.plot(_this, Lib.filterVisible(moduleData), ternaryLayout);
}

_this.traceHash = traceHash;
Expand Down
0