Skip to content

Instantly share code, notes, and snippets.

@timelyportfolio
Last active January 16, 2020 14:19
Show Gist options
  • Save timelyportfolio/d4fba79cbbc7f4dcd7db6915ba44e209 to your computer and use it in GitHub Desktop.
Save timelyportfolio/d4fba79cbbc7f4dcd7db6915ba44e209 to your computer and use it in GitHub Desktop.
d3 parallel coordinates with outside filters
license: mit

assembled with blockbuilder.org but built in R


Working on a project that would like outside categorical filtering to work with d3 parallel-coordinates, so I poked, prodded, and hacked to end up with this proof of concept.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="data:application/x-javascript;base64,KGZ1bmN0aW9uKCkgewogIC8vIElmIHdpbmRvdy5IVE1MV2lkZ2V0cyBpcyBhbHJlYWR5IGRlZmluZWQsIHRoZW4gdXNlIGl0OyBvdGhlcndpc2UgY3JlYXRlIGEKICAvLyBuZXcgb2JqZWN0LiBUaGlzIGFsbG93cyBwcmVjZWRpbmcgY29kZSB0byBzZXQgb3B0aW9ucyB0aGF0IGFmZmVjdCB0aGUKICAvLyBpbml0aWFsaXphdGlvbiBwcm9jZXNzICh0aG91Z2ggbm9uZSBjdXJyZW50bHkgZXhpc3QpLgogIHdpbmRvdy5IVE1MV2lkZ2V0cyA9IHdpbmRvdy5IVE1MV2lkZ2V0cyB8fCB7fTsKCiAgLy8gU2VlIGlmIHdlJ3JlIHJ1bm5pbmcgaW4gYSB2aWV3ZXIgcGFuZS4gSWYgbm90LCB3ZSdyZSBpbiBhIHdlYiBicm93c2VyLgogIHZhciB2aWV3ZXJNb2RlID0gd2luZG93LkhUTUxXaWRnZXRzLnZpZXdlck1vZGUgPQogICAgICAvXGJ2aWV3ZXJfcGFuZT0xXGIvLnRlc3Qod2luZG93LmxvY2F0aW9uKTsKCiAgLy8gU2VlIGlmIHdlJ3JlIHJ1bm5pbmcgaW4gU2hpbnkgbW9kZS4gSWYgbm90LCBpdCdzIGEgc3RhdGljIGRvY3VtZW50LgogIC8vIE5vdGUgdGhhdCBzdGF0aWMgd2lkZ2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oZXNlQXJncyA9IHRoZXNlQXJncy5jb25jYXQoW3Rhc2suZGF0YV0pOwogICAgICAgICAgdGFzayA9IHRhc2suY29kZTsKICAgICAgICB9CiAgICAgICAgdmFyIHRhc2tGdW5jID0gZXZhbCgiKCIgKyB0YXNrICsgIikiKTsKICAgICAgICBpZiAodHlwZW9mKHRhc2tGdW5jKSAhPT0gImZ1bmN0aW9uIikgewogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJUYXNrIG11c3QgYmUgYSBmdW5jdGlvbiEgU291cmNlOlxuIiArIHRhc2spOwogICAgICAgIH0KICAgICAgICB0YXNrRnVuYy5hcHBseSh0YXJnZXQsIHRoZXNlQXJncyk7CiAgICAgIH0pOwogICAgfQogIH0KCiAgZnVuY3Rpb24gaW5pdFNpemluZyhlbCkgewogICAgdmFyIHNpemluZyA9IHNpemluZ1BvbGljeShlbCk7CiAgICBpZiAoIXNpemluZykKICAgICAgcmV0dXJuOwoKICAgIHZhciBjZWwgPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgiaHRtbHdpZGdldF9jb250YWluZXIiKTsKICAgIGlmICghY2VsKQogICAgICByZXR1cm47CgogICAgaWYgKHR5cGVvZihzaXppbmcucGFkZGluZykgIT09ICJ1bmRlZmluZWQiKSB7CiAgICAgIGRvY3VtZW50LmJvZHkuc3R5bGUubWFyZ2luID0gIjAiOwogICAgICBkb2N1bWVudC5ib2R5LnN0eWxlLnBhZGRpbmcgPSBwYWRkaW5nVG9Dc3ModW5wYWNrUGFkZGluZyhzaXppbmcucGFkZGluZykpOwogICAgfQoKICAgIGlmIChzaXppbmcuZmlsbCkgewogICAgICBkb2N1bWVudC5ib2R5LnN0eWxlLm92ZXJmbG93ID0gImhpZGRlbiI7CiAgICAgIGRvY3VtZW50LmJvZHkuc3R5bGUud2lkdGggPSAiMTAwJSI7CiAgICAgIGRvY3VtZW50LmJvZHkuc3R5bGUuaGVpZ2h0ID0gIjEwMCUiOwogICAgICBkb2N1bWVudC5kb2N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IHVubmVjZXNzYXJ5IHNjcm9sbGJhcnMgdG8gYXBwZWFyIGFuZCBtYWtpbmcgaXQgaW1wb3NzaWJsZSBmb3IKICAgICAgICAgICAgLy8gdGhlIGVsZW1lbnQgdG8gc2hyaW5rOyBzbyB1c2UgbWF4LXdpZHRoIGluc3RlYWQKICAgICAgICAgICAgLmNzcygibWF4V2lkdGgiLCBlbC5vZmZzZXRXaWR0aCkKICAgICAgICAgICAgLmNzcygiaGVpZ2h0IiwgZWwub2Zmc2V0SGVpZ2h0KTsKICAgICAgICAgIGVycm9yRGl2LnRleHQoZXJyLm1lc3NhZ2UpOwogICAgICAgICAgJGVsLmFmdGVyKGVycm9yRGl2KTsKCiAgICAgICAgICAvLyBSZWFsbHkgZHVtYiB3YXkgdG8ga2VlcCB0aGUgc2l6ZS9wb3NpdGlvbiBvZiB0aGUgZXJyb3IgaW4gc3luYyB3aXRoCiAgICAgICAgICAvLyB0aGUgcGFyZW50IGVsZW1lbnQgYXMgdGhlIHdpbmRvdyBpcyByZXNpemVkIG9yIHdoYXRldmVyLgogICAgICAgICAgdmFyIGludElkID0gc2V0SW50ZXJ2YWwoZnVuY3Rpb24oKSB7CiAgICAgICAgICAgIGlmICghZXJyb3JEaXZbMF0ucGFyZW50RWxlbWVudCkgewogICAgICAgICAgICAgIGNsZWFySW50ZXJ2YWwoaW50SWQpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBlcnJvckRpdgogICAgICAgICAgICAgIC5jc3MoInRvcCIsIGVsLm9mZnNldFRvcCkKICAgICAgICAgICAgICAuY3NzKCJsZWZ0IiwgZWwub2Zmc2V0TGVmdCkKICAgICAgICAgICAgICAuY3NzKCJtYXhXaWR0aCIsIGVsLm9mZnNldFdpZHRoKQogICAgICAgICAgICAgIC5jc3MoImhlaWdodCIsIGVsLm9mZnNldEhlaWdodCk7CiAgICAgICAgICB9LCA1MDApOwogICAgICAgIH0KICAgICAgfQogICAgfSwKICAgIGNsZ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RyaW5ncyBtYXJrZWQgYXMgamF2YXNjcmlwdCBsaXRlcmFscyB0byBvYmplY3RzCiAgICAgICAgaWYgKCEoZGF0YS5ldmFscyBpbnN0YW5jZW9mIEFycmF5KSkgZGF0YS5ldmFscyA9IFtkYXRhLmV2YWxzXTsKICAgICAgICBmb3IgKHZhciBpID0gMDsgZGF0YS5ldmFscyAmJiBpIDwgZGF0YS5ldmFscy5sZW5ndGg7IGkrKykgewogICAgICAgICAgd2luZG93LkhUTUxXaWRnZXRzLmV2YWx1YXRlU3RyaW5nTWVtYmVyKGRhdGEueCwgZGF0YS5ldmFsc1tpXSk7CiAgICAgICAgfQogICAgICAgIGlmICghYmluZGluZ0RlZi5yZW5kZXJPbk51bGxWYWx1ZSkgewogICAgICAgICAgaWYgKGRhdGEueCA9PT0gbnVsbCkgewogICAgICAgICAgICBlbC5zdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGVsLnN0eWxlLnZpc2liaWxpdHkgPSAiaW5oZXJpdCI7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmICghZWxlbWVudERhdGEoZWwsICJpbml0aWFsaXplZCIpKSB7CiAgICAgICAgICBpbml0U2l6aW5nKGVsKTsKCiAgICAgICAgICBlbGVtZW50RGF0YShlbCwgImluaXRpYWxpemVkIiwgdHJ1ZSk7CiAgICAgICAgICBpZiAoYmluZGluZ0RlZi5pbml0aWFsaXplKSB7CiAgICAgICAgICAgIHZhciByZXN1bHQgPSBiaW5kaW5nRGVmLmluaXRpYWxpemUoZWwsIGVsLm9mZnNldFdpZHRoLAogICAgICAgICAgICAgIGVsLm9mZnNldEhlaWdodCk7CiAgICAgICAgICAgIGVsZW1lbnREYXRhKGVsLCAiaW5pdF9yZXN1bHQiLCByZXN1bHQpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBiaW5kaW5nRGVmLnJlbmRlclZ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RXaWR0aCgpIDogZWwub2Zmc2V0V2lkdGgsCiAgICAgICAgICAgIHNpemVPYmogPyBzaXplT2JqLmdldEhlaWdodCgpIDogZWwub2Zmc2V0SGVpZ2h0CiAgICAgICAgICApOwogICAgICAgICAgZWxlbWVudERhdGEoZWwsICJpbml0X3Jlc3VsdCIsIGluaXRSZXN1bHQpOwogICAgICAgIH0KCiAgICAgICAgaWYgKGJpbmRpbmcucmVzaXplKSB7CiAgICAgICAgICB2YXIgbGFzdFNpemUgPSB7fTsKICAgICAgICAgIHZhciByZXNpemVIYW5kbGVyID0gZnVuY3Rpb24oZSkgewogICAgICAgICAgICB2YXIgc2l6ZSA9IHsKICAgICAgICAgICAgICB3OiBzaXplT2JqID8gc2l6ZU9iai5nZXRXaWR0aCgpIDogZWwub2Zmc2V0V2lkdGgsCiAgICAgICAgICAgICAgaDogc2l6ZU9iaiA/IHNpemVPYmouZ2V0SGVpZ2h0KCkgOiBlbC5vZmZzZXRIZWlnaHQKICAgICAgICAgICAgfTsKICAgICAgICAgICAgaWYgKHNpemUudyA9PT0gMCAmJiBzaXplLmggPT09IDApCiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICBpZiAoc2l6ZS53ID09PSBsYXN0U2l6ZS53ICYmIHNpemUuaCA9PT0gbGFzdFNpemUuaCkKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIGxhc3RTaXplID0gc2l6ZTsKICAgICAgICAgICAgYmluZGluZy5yZXNpemUoZWwsIHNpemUudywgc2l6ZS5oLCBpbml0UmVzdWx0KTsKICAgICAgICAgIH07CgogICAgICAgICAgb24od2luZG93LCAicmVzaXplIiwgcmVzaXplSGFuZGxlcik7CgogICAgICAgICAgLy8gVGhpcyBpcyBuZWVkZWQgZm9yIGNhc2VzIHdoZXJlIHdlJ3JlIHJ1bm5pbmcgaW4gYSBTaGlueQogICAgICAgICAgLy8gYXBwLCBidXQgdGhlIHdpZGdldCBpdHNlbGYgaXMgbm90IGEgU2hpbnk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ICB2YXIgcmVzdWx0ID0gewogICAgICBuYW1lOiBkZWZuLm5hbWUsCiAgICAgIHR5cGU6IGRlZm4udHlwZSwKICAgICAgaW5pdGlhbGl6ZTogZnVuY3Rpb24oZWwsIHdpZHRoLCBoZWlnaHQpIHsKICAgICAgICByZXR1cm4gZGVmbi5mYWN0b3J5KGVsLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgfSwKICAgICAgcmVuZGVyVmFsdWU6IGZ1bmN0aW9uKGVsLCB4LCBpbnN0YW5jZSkgewogICAgICAgIHJldHVybiBpbnN0YW5jZS5yZW5kZXJWYWx1ZSh4KTsKICAgICAgfSwKICAgICAgcmVzaXplOiBmdW5jdGlvbihlbCwgd2lkdGgsIGhlaWdodCwgaW5zdGFuY2UpIHsKICAgICAgICByZXR1cm4gaW5zdGFuY2UucmVzaXplKHdpZHRoLCBoZWlnaHQpOwogICAgICB9CiAgICB9OwoKICAgIGlmIChkZWZuLmZpbmQpCiAgICAgIHJlc3VsdC5maW5kID0gZGVmbi5maW5kOwogICAgaWYgKGRlZm4ucmVuZGVyRXJyb3IpCiAgICAgIHJlc3VsdC5yZW5kZXJFcnJvciA9IGRlZm4ucmVuZGVyRXJyb3I7CiAgICBpZiAoZGVmbi5jbGVhckVycm9yKQogICAgICByZXN1bHQuY2xlYXJFcnJvciA9IGRlZm4uY2xlYXJFcnJvcjsKCiAgICByZXR1cm4gcmVzdWx0OwogIH0KfSkoKTsKCg=="></script>
<script src="data:application/x-javascript;base64,IWZ1bmN0aW9uKCl7ZnVuY3Rpb24gbihuKXtyZXR1cm4gbiYmKG4ub3duZXJEb2N1bWVudHx8bi5kb2N1bWVudHx8bikuZG9jdW1lbnRFbGVtZW50fWZ1bmN0aW9uIHQobil7cmV0dXJuIG4mJihuLm93bmVyRG9jdW1lbnQmJm4ub3duZXJEb2N1bWVudC5kZWZhdWx0Vmlld3x8bi5kb2N1bWVudCYmbnx8bi5kZWZhdWx0Vmlldyl9ZnVuY3Rpb24gZShuLHQ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E%20svg%2C%20%2Eparcoords%20%3E%20canvas%20%7B%0Afont%3A%2014px%20sans%2Dserif%3B%0Aposition%3A%20absolute%3B%0A%7D%0A%2Eparcoords%20%3E%20canvas%20%7B%0Apointer%2Devents%3A%20none%3B%0A%7D%0A%2Eparcoords%20text%2Elabel%20%7B%0Acursor%3A%20default%3B%0A%7D%0A%2Eparcoords%20rect%2Ebackground%20%7B%0Afill%3A%20transparent%3B%0A%7D%0A%2Eparcoords%20rect%2Ebackground%3Ahover%20%7B%0Afill%3A%20rgba%28120%2C120%2C120%2C0%2E2%29%3B%0A%7D%0A%2Eparcoords%20%2Eresize%20rect%20%7B%0Afill%3A%20rgba%280%2C0%2C0%2C0%2E1%29%3B%0A%7D%0A%2Eparcoords%20rect%2Eextent%20%7B%0Afill%3A%20rgba%28255%2C255%2C255%2C0%2E25%29%3B%0Astroke%3A%20rgba%280%2C0%2C0%2C0%2E6%29%3B%0A%7D%0A%2Eparcoords%20%2Eaxis%20line%2C%20%2Eparcoords%20%2Eaxis%20path%20%7B%0Afill%3A%20none%3B%0Astroke%3A%20%23222%3B%0Ashape%2Drendering%3A%20crispEdges%3B%0A%7D%0A%2Eparcoords%20canvas%20%7B%0Aopacity%3A%201%3B%0A%2Dmoz%2Dtransition%3A%20opacity%200%2E3s%3B%0A%2Dwebkit%2Dtransition%3A%20opacity%200%2E3s%3B%0A%2Do%2Dtransition%3A%20opacity%200%2E3s%3B%0A%7D%0A%2Eparcoords%20canvas%2Efaded%20%7B%0Aopacity%3A%200%2E25%3B%0A%7D%0A%2Eparcoords%20%7B%0A%2Dwebkit%2Dtouch%2Dcallout%3A%20none%3B%0A%2Dwebkit%2Duser%2Dselect%3A%20none%3B%0A%2Dkhtml%2Duser%2Dselect%3A%20none%3B%0A%2Dmoz%2Duser%2Dselect%3A%20none%3B%0A%2Dms%2Duser%2Dselect%3A%20none%3B%0Auser%2Dselect%3A%20none%3B%0Abackground%2Dcolor%3A%20white%3B%0A%7D%0A" rel="stylesheet" />
<script src="data:application/x-javascript;base64,KGZ1bmN0aW9uICgpIHsNCiAgZDMuc3ZnLm11bHRpYnJ1c2ggPSBmdW5jdGlvbigpIHsNCg0KICAgIC8vIEZyb20gZDMvc2NhbGUvc2NhbGUuanMNCiAgICBmdW5jdGlvbiBkM19zY2FsZUV4dGVudChkb21haW4pIHsNCiAgICAgIHZhciBzdGFydCA9IGRvbWFpblswXSwgc3RvcCA9IGRvbWFpbltkb21haW4ubGVuZ3RoIC0gMV07DQogICAgICByZXR1cm4gc3RhcnQgPCBzdG9wID8gWyBzdGFydCwgc3RvcCBdIDogWyBzdG9wLCBzdGFydCBdOw0KICAgIH0NCiAgICBmdW5jdGlvbiBkM19zY2FsZVJhbmdlKHNjYWxlKSB7DQogICAgICByZXR1cm4gc2NhbGUucmFuZ2VFeHRlbnQgPyBzY2FsZS5yYW5nZUV4dGVudCgpIDogZDNfc2NhbGVFeHRlbnQoc2NhbGUucmFuZ2UoKSk7DQogICAgfQ0KDQogICAgLy8gRnJvbSBkMw0KICAgIHZhciBkM19kb2N1bWVudCA9IHRoaXMuZG9jdW1lbnQ7DQogICAgZnVuY3Rpb24gZDNfZG9jdW1lbnRFbGVtZW50KG5vZGUpIHsNCiAgICAgIHJldHVybiBub2RlICYmIChub2RlLm93bmVyRG9jdW1lbnQgfHwgbm9kZS5kb2N1bWVudCB8fCBub2RlKS5kb2N1bWVudEVsZW1lbnQ7DQogICAgfQ0KICAgIGZ1bmN0aW9uIGQzX3dpbmRvdyhub2RlKSB7DQogICAgICByZXR1cm4gbm9kZSAmJiAobm9kZS5vd25lckRvY3VtZW50ICYmIG5vZGUub3duZXJEb2N1bWVudC5kZWZhdWx0VmlldyB8fCBub2RlLmRvY3VtZW50ICYmIG5vZGUgfHwgbm9kZS5kZWZhdWx0Vmlldyk7DQogICAgfQ0KICAgIGlmIChkM19kb2N1bWVudCkgew0KICAgICAgdHJ5IHsNCiAgICAgICAgZDNfYXJyYXkoZDNfZG9jdW1lbnQuZG9jdW1l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gICAgICByZXNpemVzID0gZDNfc3ZnX2JydXNoUmVzaXplc1swXSwNCiAgICAgICAgcmVzaXplQWRhcHRpb24gPSBmdW5jdGlvbiAoKSB7fSwgLy8gRnVuY3Rpb24gdG8gJ2NhbGwnIG9uIG5ldyByZXNpemUgc2VsZWN0aW9uDQogICAgICAgIGV4dGVudEFkYXB0aW9uID0gZnVuY3Rpb24gKCkge307IC8vIEZ1bmN0aW9uIHRvICdjYWxsJyBvbiBuZXcgZXh0ZW50IHNlbGVjdGlvbg0KDQogICAgZXZlbnQub2YgPSBmdW5jdGlvbih0aGl6LCBhcmd1bWVudHopIHsNCiAgICAgIHJldHVybiBmdW5jdGlvbihlMSkgew0KICAgICAgICB0cnkgew0KICAgICAgICAgIHZhciBlMCA9DQogICAgICAgICAgZTEuc291cmNlRXZlbnQgPSBkMy5ldmVudDsNCiAgICAgICAgICBlMS50YXJnZXQgPSBicnVzaDsNCiAgICAgICAgICBkMy5ldmVudCA9IGUxOw0KICAgICAgICAgIGV2ZW50W2UxLnR5cGVdLmFwcGx5KHRoaXosIGFyZ3VtZW50eik7DQogICAgICAgIH0gZmluYWxseSB7DQogICAgICAgICAgZDMuZXZlbnQgPSBlMDsNCiAgICAgICAgfQ0KICAgICAgfTsNCiAgICB9Ow0KDQogICAgZnVuY3Rpb24gYnJ1c2goZykgew0KICAgICAgZy5lYWNoKGZ1bmN0aW9uKCkgew0KDQogICAgICAgIC8vIFByZXBhcmUgdGhlIGJydXNoIGNvbnRhaW5lciBmb3IgZXZlbnRzLg0KICAgICAgICB2YXIgZyA9IGQzLnNlbGVjdCh0aGlzKQ0KICAgICAgICAgICAgLnN0eWxlKCJwb2ludGVyLWV2ZW50cyIsICJhbGwiKQ0KICAgICAgICAgICAgLnN0eWxlKCItd2Via2l0LXRhcC1oaWdobGlnaHQtY29sb3IiLCAicmdiYSgwLDAsMCwwKSIpDQogICAgICAgICAgICAub24oIm1vdXNlZG93bi5icnVzaCIsIGJydXNoc3RhcnQpDQogICA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ICAgIGV2ZW50Xyh7dHlwZTogImJydXNoc3RhcnQifSk7DQogICAgICAgICAgICAgIH0pDQogICAgICAgICAgICAgIC50d2VlbigiYnJ1c2g6YnJ1c2giLCBmdW5jdGlvbigpIHsNCiAgICAgICAgICAgICAgICAvLyBUT0RPOiB0cmFuc2l0aW9ucyBmb3IgYWxsIGV4dGVudHMNCiAgICAgICAgICAgICAgICB2YXIgeGkgPSBkM19pbnRlcnBvbGF0ZUFycmF5KHhFeHRlbnRbMF0sIGV4dGVudDEueFswXSksDQogICAgICAgICAgICAgICAgICAgIHlpID0gZDNfaW50ZXJwb2xhdGVBcnJheSh5RXh0ZW50WzBdLCBleHRlbnQxLnlbMF0pOw0KICAgICAgICAgICAgICAgIHhFeHRlbnREb21haW5bMF0gPSB5RXh0ZW50RG9tYWluWzBdID0gbnVsbDsgLy8gdHJhbnNpdGlvbiBzdGF0ZQ0KICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbih0KSB7DQogICAgICAgICAgICAgICAgICB4RXh0ZW50WzBdID0gZXh0ZW50MS54WzBdID0geGkodCk7DQogICAgICAgICAgICAgICAgICB5RXh0ZW50WzBdID0gZXh0ZW50MS55WzBdID0geWkodCk7DQogICAgICAgICAgICAgICAgICBldmVudF8oe3R5cGU6ICJicnVzaCIsIG1vZGU6ICJyZXNpemUifSk7DQogICAgICAgICAgICAgICAgfTsNCiAgICAgICAgICAgICAgfSkNCiAgICAgICAgICAgICAgLmVhY2goImVuZC5icnVzaCIsIGZ1bmN0aW9uKCkgew0KICAgICAgICAgICAgICAgIHhFeHRlbnREb21haW4gPSBleHRlbnQxLmk7IC8vIHBvc3QtdHJhbnNpdGlvbiBzdGF0ZQ0KICAgICAgICAgICAgICAgIHlFeHRlbnREb21haW4gPSBleHRlbnQxLmo7DQogICAgICAgICAgICAgICAgZXZlbnRfKHt0eXBlOiAiYnJ1c2giLCBtb2RlOiAicmVzaXplIn0pOw0KICAgICAgICAgICAgICAgIGV2ZW50Xyh7dHl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m4geUV4dGVudFtkXVsxXSAtIHlFeHRlbnRbZF1bMF07IH0pOw0KICAgIH0NCg0KICAgIGZ1bmN0aW9uIGJydXNoc3RhcnQoKSB7DQogICAgICB2YXIgdGFyZ2V0ID0gdGhpcywNCiAgICAgICAgICBldmVudFRhcmdldCA9IGQzLnNlbGVjdChkMy5ldmVudC50YXJnZXQpLA0KICAgICAgICAgIGV2ZW50XyA9IGV2ZW50Lm9mKHRhcmdldCwgYXJndW1lbnRzKSwNCiAgICAgICAgICBnID0gZDMuc2VsZWN0KHRhcmdldCksDQogICAgICAgICAgcmVzaXppbmcgPSBldmVudFRhcmdldC5kYXR1bSgpWzBdLA0KICAgICAgICAgIHJlc2l6aW5nWCA9ICEvXihufHMpJC8udGVzdChyZXNpemluZykgJiYgeCwNCiAgICAgICAgICByZXNpemluZ1kgPSAhL14oZXx3KSQvLnRlc3QocmVzaXppbmcpICYmIHksDQogICAgICAgICAgZHJhZ2dpbmcgPSBldmVudFRhcmdldC5jbGFzc2VkKCJleHRlbnQiKSwNCiAgICAgICAgICBkcmFnUmVzdG9yZSA9IGQzX2V2ZW50X2RyYWdTdXBwcmVzcyh0YXJnZXQpLA0KICAgICAgICAgIGNlbnRlciwNCiAgICAgICAgICBvcmlnaW4gPSBkMy5tb3VzZSh0YXJnZXQpLA0KICAgICAgICAgIG9mZnNldCwNCiAgICAgICAgICBpOw0KDQogICAgICB2YXIgdyA9IGQzLnNlbGVjdCh3aW5kb3cpDQogICAgICAgICAgLm9uKCJrZXlkb3duLmJydXNoIiwga2V5ZG93bikNCiAgICAgICAgICAub24oImtleXVwLmJydXNoIiwga2V5dXApOw0KDQogICAgICBpZiAoZDMuZXZlbnQuY2hhbmdlZFRvdWNoZXMpIHsNCiAgICAgICAgdy5vbigidG91Y2htb3ZlLmJydXNoIiwgYnJ1c2htb3ZlKS5vbigidG91Y2hlbmQuYnJ1c2giLCBicnVzaGVuZCk7DQogICAgICB9IGVsc2Ugew0KICAgICAgICB3Lm9uKCJt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kgew0KICAgICAgICBpZiAoZDMuZXZlbnQua2V5Q29kZSA9PSAzMikgew0KICAgICAgICAgIGlmICghZHJhZ2dpbmcpIHsNCiAgICAgICAgICAgIGNlbnRlciA9IG51bGw7DQogICAgICAgICAgICBvcmlnaW5bMF0gLT0geEV4dGVudFtpXVsxXTsNCiAgICAgICAgICAgIG9yaWdpblsxXSAtPSB5RXh0ZW50W2ldWzFdOw0KICAgICAgICAgICAgZHJhZ2dpbmcgPSAyOw0KICAgICAgICAgIH0NCiAgICAgICAgICBkMy5ldmVudC5wcmV2ZW50RGVmYXVsdCgpOw0KICAgICAgICB9DQogICAgICB9DQoNCiAgICAgIGZ1bmN0aW9uIGtleXVwKCkgew0KICAgICAgICBpZiAoZDMuZXZlbnQua2V5Q29kZSA9PSAzMiAmJiBkcmFnZ2luZyA9PSAyKSB7DQogICAgICAgICAgb3JpZ2luWzBdICs9IHhFeHRlbnRbaV1bMV07DQogICAgICAgICAgb3JpZ2luWzFdICs9IHlFeHRlbnRbaV1bMV07DQogICAgICAgICAgZHJhZ2dpbmcgPSAwOw0KICAgICAgICAgIGQzLmV2ZW50LnByZXZlbnREZWZhdWx0KCk7DQogICAgICAgIH0NCiAgICAgIH0NCg0KICAgICAgZnVuY3Rpb24gYnJ1c2htb3ZlKCkgew0KICAgICAgICB2YXIgcG9pbnQgPSBkMy5tb3VzZSh0YXJnZXQpLA0KICAgICAgICAgICAgbW92ZWQgPSBmYWxzZTsNCg0KICAgICAgICAvLyBQcmVzZXJ2ZSB0aGUgb2Zmc2V0IGZvciB0aGljayByZXNpemVycy4NCiAgICAgICAgaWYgKG9mZnNldCkgew0KICAgICAgICAgIHBvaW50WzBdICs9IG9mZnNldFswXTsNCiAgICAgICAgICBwb2ludFsxXSArPSBvZmZzZXRbMV07DQogICAgICAgIH0NCg0KICAgICAgICBpZiAoIWRyYWdnaW5nKSB7DQoNCiAgICAgICAgICAvLyBJZiBuZWVkZWQsIGRldGVybWluZSB0aGUgY2VudGVyIGZy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gICAgaWYgKGRyYWdnaW5nKSB7DQogICAgICAgICAgbWF4ID0gKG1pbiArPSBwb3NpdGlvbikgKyBzaXplOw0KICAgICAgICB9IGVsc2Ugew0KDQogICAgICAgICAgLy8gSWYgdGhlIEFMVCBrZXkgaXMgcHJlc3NlZCwgdGhlbiBwcmVzZXJ2ZSB0aGUgY2VudGVyIG9mIHRoZSBleHRlbnQuDQogICAgICAgICAgaWYgKGNlbnRlcikgcG9zaXRpb24gPSBNYXRoLm1heChyMCwgTWF0aC5taW4ocjEsIDIgKiBjZW50ZXJbal0gLSBtaW4pKTsNCg0KICAgICAgICAgIC8vIENvbXB1dGUgdGhlIG1pbiBhbmQgbWF4IG9mIHRoZSBwb3NpdGlvbiBhbmQgcG9pbnQuDQogICAgICAgICAgaWYgKHBvc2l0aW9uIDwgbWluKSB7DQogICAgICAgICAgICBtYXggPSBtaW47DQogICAgICAgICAgICBtaW4gPSBwb3NpdGlvbjsNCiAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgbWF4ID0gcG9zaXRpb247DQogICAgICAgICAgfQ0KICAgICAgICB9DQoNCiAgICAgICAgLy8gVXBkYXRlIHRoZSBzdG9yZWQgYm91bmRzLg0KICAgICAgICBpZiAoZXh0ZW50WzBdICE9IG1pbiB8fCBleHRlbnRbMV0gIT0gbWF4KSB7DQogICAgICAgICAgaWYgKGopIHlFeHRlbnREb21haW5baV0gPSBudWxsOw0KICAgICAgICAgIGVsc2UgeEV4dGVudERvbWFpbltpXSA9IG51bGw7DQogICAgICAgICAgZXh0ZW50WzBdID0gbWluOw0KICAgICAgICAgIGV4dGVudFsxXSA9IG1heDsNCiAgICAgICAgICByZXR1cm4gdHJ1ZTsNCiAgICAgICAgfQ0KICAgICAgfQ0KDQogICAgICBmdW5jdGlvbiBicnVzaGVuZCgpIHsNCiAgICAgICAgYnJ1c2htb3ZlKCk7DQoNCiAgICAgICAgLy8gSWYgdGhlIGN1cnJlbnQgZXh0ZW50IGlzIGVtcHR5LCBjbGVhciBldmVyeXRoaW5nLg0KICAgICAgICBpZih4ICYmIHhFeHRlbnRbaV1bMF0gPT0geEV4dGVudFtpXVsxXSB8fA0KICAgICAgICAgICB5ICYmIHlFeHRlbnRbaV1bMF0gPT0geUV4dGVudFtpXVsxXSkgew0KICAgICAgICAgIGJydXNoLmNsZWFyKCk7DQogICAgICAgIH0NCg0KICAgICAgICAvLyByZXNldCB0aGUgY3Vyc29yIHN0eWxlcw0KICAgICAgICBnLnN0eWxlKCJwb2ludGVyLWV2ZW50cyIsICJhbGwiKS5zZWxlY3RBbGwoIi5yZXNpemUiKS5zdHlsZSgiZGlzcGxheSIsIGZ1bmN0aW9uKGQpIHsgcmV0dXJuIGJydXNoLmVtcHR5KGRbMV0pID8gIm5vbmUiIDogbnVsbDsgfSk7DQogICAgICAgIGQzLnNlbGVjdCgiYm9keSIpLnN0eWxlKCJjdXJzb3IiLCBudWxsKTsNCg0KICAgICAgICB3IC5vbigibW91c2Vtb3ZlLmJydXNoIiwgbnVsbCkNCiAgICAgICAgICAub24oIm1vdXNldXAuYnJ1c2giLCBudWxsKQ0KICAgICAgICAgIC5vbigidG91Y2htb3ZlLmJydXNoIiwgbnVsbCkNCiAgICAgICAgICAub24oInRvdWNoZW5kLmJydXNoIiwgbnVsbCkNCiAgICAgICAgICAub24oImtleWRvd24uYnJ1c2giLCBudWxsKQ0KICAgICAgICAgIC5vbigia2V5dXAuYnJ1c2giLCBudWxsKTsNCg0KICAgICAgICBkcmF3RXh0ZW50cygpOw0KDQogICAgICAgIGRyYWdSZXN0b3JlKCk7DQogICAgICAgIGV2ZW50Xyh7dHlwZTogImJydXNoZW5kIn0pOw0KICAgICAgfQ0KICAgIH0NCg0KICAgIGJydXNoLnggPSBmdW5jdGlvbih6KSB7DQogICAgICBpZiAoIWFyZ3VtZW50cy5sZW5ndGgpIHJldHVybiB4Ow0KICAgICAgeCA9IHo7DQogICAgICByZXNpemVzID0gZDNfc3ZnX2JydXNoUmVzaXplc1sheCA8PC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bih6KSB7DQogICAgICB2YXIgeDAsIHgxLCB5MCwgeTEsIHQ7DQogICAgICB2YXIgeE91dHB1dCwgeU91dHB1dCwgeHlPdXRwdXQgPSBbXTsNCg0KICAgICAgLy8gSW52ZXJ0IHRoZSBwaXhlbCBleHRlbnQgdG8gZGF0YS1zcGFjZS4NCiAgICAgIGlmICghYXJndW1lbnRzLmxlbmd0aCkgew0KICAgICAgICBpZiAoeCkgew0KICAgICAgICAgIGlmICh4RXh0ZW50RG9tYWluWzBdKSB7DQogICAgICAgICAgICB4T3V0cHV0ID0geEV4dGVudERvbWFpbjsNCiAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgeE91dHB1dCA9IHhFeHRlbnQubWFwKGZ1bmN0aW9uIChkKSB7DQogICAgICAgICAgICAgIGlmICh4LmludmVydCkgcmV0dXJuIFsgeC5pbnZlcnQoZFswXSksIHguaW52ZXJ0KGRbMV0pIF07DQogICAgICAgICAgICAgIHJldHVybiBkOw0KICAgICAgICAgICAgfSkubWFwKGZ1bmN0aW9uIChkKSB7DQogICAgICAgICAgICAgIGlmIChkWzFdIDwgZFswXSkgcmV0dXJuIFsgZFsxXSwgZFswXSBdOw0KICAgICAgICAgICAgICByZXR1cm4gZDsNCiAgICAgICAgICAgIH0pLmZpbHRlcihmdW5jdGlvbiAoZCkgeyByZXR1cm4gZFsxXSAtIGRbMF0gIT0gMDsgfSk7DQogICAgICAgICAgfQ0KICAgICAgICB9DQogICAgICAgIGlmICh5KSB7DQogICAgICAgICAgaWYgKHlFeHRlbnREb21haW5bMF0pIHsNCiAgICAgICAgICAgIHlPdXRwdXQgPSB5RXh0ZW50RG9tYWluOw0KICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICB5T3V0cHV0ID0geUV4dGVudC5tYXAoZnVuY3Rpb24gKGQpIHsNCiAgICAgICAgICAgICAgaWYoeS5pbnZlcnQpIHJldHVybiBbIHkuaW52ZXJ0KGRbMF0pLCB5LmludmVydChkWzFdKSBdOw0KICAgICAgICAgICAgICByZXR1cm4gZDsNCiAgICAgICAgICAgIH0pLm1hcChmdW5jdGlvbiAoZCkgew0KICAgICAgICAgICAgICBpZiAoZFsxXSA8IGRbMF0pIHJldHVybiBbIGRbMV0sIGRbMF0gXTsNCiAgICAgICAgICAgICAgcmV0dXJuIGQ7DQogICAgICAgICAgICB9KS5maWx0ZXIoZnVuY3Rpb24gKGQpIHsgcmV0dXJuIGRbMV0gLSBkWzBdICE9IDA7IH0pOw0KICAgICAgICAgIH0NCiAgICAgICAgfQ0KICAgICAgICBpZih4ICYmIHkpIHsNCiAgICAgICAgICB4T3V0cHV0LmZvckVhY2goZnVuY3Rpb24gKGQsIGkpIHsNCiAgICAgICAgICAgIHh5T3V0cHV0LnB1c2goW1tkWzBdLCB5T3V0cHV0W2ldWzBdXSwgW2RbMV0sIHlPdXRwdXRbaV1bMV1dXSk7DQogICAgICAgICAgfSk7DQogICAgICAgIH0NCiAgICAgICAgcmV0dXJuIHggJiYgeSA/IHh5T3V0cHV0IDogeCA/IHhPdXRwdXQgOiB5ICYmIHlPdXRwdXQ7DQogICAgICB9DQoNCiAgICAgIC8vIFNjYWxlIHRoZSBkYXRhLXNwYWNlIGV4dGVudCB0byBwaXhlbHMuDQogICAgICBpZiAoeCkgew0KICAgICAgICB4T3V0cHV0ID0gejsNCiAgICAgICAgaWYgKHkpIHhPdXRwdXQgPSB4T3V0cHV0Lm1hcChmdW5jdGlvbiAoZCkgew0KICAgICAgICAgIHJldHVybiBbZFswXVswXSwgZFsxXVswXV07DQogICAgICAgIH0pOw0KICAgICAgICB4RXh0ZW50RG9tYWluID0geE91dHB1dDsNCiAgICAgICAgeE91dHB1dCA9IHhPdXRwdXQubWFwKGZ1bmN0aW9uIChkKSB7DQogICAgICAgICAgaWYgKHguaW52ZXJ0KSByZXR1cm4gW3goZFswXSksIHgoZFsxXSldOw0KICAgICAgICAgIHJldHVybiBkOw0KICAgICAgICB9KS5tYXAoZnVuY3Rpb24gKGQpIHsNCiA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nc6ICJud3NlLXJlc2l6ZSIsDQogICAgbmU6ICJuZXN3LXJlc2l6ZSIsDQogICAgc2U6ICJud3NlLXJlc2l6ZSIsDQogICAgc3c6ICJuZXN3LXJlc2l6ZSINCiAgfTsNCg0KICB2YXIgZDNfc3ZnX2JydXNoUmVzaXplcyA9IFsNCiAgICBbIm4iLCAiZSIsICJzIiwgInciLCAibnciLCAibmUiLCAic2UiLCAic3ciXSwNCiAgICBbImUiLCAidyJdLA0KICAgIFsibiIsICJzIl0sDQogICAgW10NCiAgXTsNCn0pKCk7DQo="></script>
<script src="data:application/x-javascript;base64,ZDMucGFyY29vcmRzID0gZnVuY3Rpb24oY29uZmlnKSB7DQogIHZhciBfXyA9IHsNCiAgICBkYXRhOiBbXSwNCiAgICBoaWdobGlnaHRlZDogW10sDQogICAgZGltZW5zaW9uczoge30sDQogICAgZGltZW5zaW9uVGl0bGVSb3RhdGlvbjogMCwNCiAgICBicnVzaGVkOiBmYWxzZSwNCiAgICBicnVzaGVkQ29sb3I6IG51bGwsDQogICAgYWxwaGFPbkJydXNoZWQ6IDAuMCwNCiAgICBtb2RlOiAiZGVmYXVsdCIsDQogICAgcmF0ZTogMjAsDQogICAgd2lkdGg6IDYwMCwNCiAgICBoZWlnaHQ6IDMwMCwNCiAgICBtYXJnaW46IHsgdG9wOiAyNCwgcmlnaHQ6IDAsIGJvdHRvbTogMTIsIGxlZnQ6IDAgfSwNCiAgICBudWxsVmFsdWVTZXBhcmF0b3I6ICJ1bmRlZmluZWQiLCAvLyBzZXQgdG8gInRvcCIgb3IgImJvdHRvbSINCiAgICBudWxsVmFsdWVTZXBhcmF0b3JQYWRkaW5nOiB7IHRvcDogOCwgcmlnaHQ6IDAsIGJvdHRvbTogOCwgbGVmdDogMCB9LA0KICAgIGNvbG9yOiAiIzA2OSIsDQogICAgY29tcG9zaXRlOiAic291cmNlLW92ZXIiLA0KICAgIGFscGhhOiAwLjcsDQogICAgYnVuZGxpbmdTdHJlbmd0aDogMC41LA0K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PyBkW2tdLmdldFRpbWUoKSA6IG51bGw7DQogICAgICB9KTsNCg0KICAgICAgLy8gc3BlY2lhbCBjYXNlIGlmIHNpbmdsZSB2YWx1ZQ0KICAgICAgaWYgKGV4dGVudFswXSA9PT0gZXh0ZW50WzFdKSB7DQogICAgICAgIHJldHVybiBkMy5zY2FsZS5vcmRpbmFsKCkNCiAgICAgICAgICAuZG9tYWluKFtleHRlbnRbMF1dKQ0KICAgICAgICAgIC5yYW5nZVBvaW50cyhnZXRSYW5nZSgpKTsNCiAgICAgIH0NCg0KICAgICAgcmV0dXJuIGQzLnRpbWUuc2NhbGUoKQ0KICAgICAgICAuZG9tYWluKGV4dGVudCkNCiAgICAgICAgLnJhbmdlKGdldFJhbmdlKCkpOw0KICAgIH0sDQogICAgIm51bWJlciI6IGZ1bmN0aW9uKGspIHsNCiAgICAgIHZhciBleHRlbnQgPSBkMy5leHRlbnQoX18uZGF0YSwgZnVuY3Rpb24oZCkgeyByZXR1cm4gK2Rba107IH0pOw0KDQogICAgICAvLyBzcGVjaWFsIGNhc2UgaWYgc2luZ2xlIHZhbHVlDQogICAgICBpZiAoZXh0ZW50WzBdID09PSBleHRlbnRbMV0pIHsNCiAgICAgICAgcmV0dXJuIGQzLnNjYWxlLm9yZGluYWwoKQ0KICAgICAgICAgIC5kb21haW4oW2V4dGVudFswXV0pDQogICAgICAgICAgLnJhbmdlUG9pbnRzKGdldFJhbmdlKCkpOw0KICAgICAgfQ0KDQogICAgICByZXR1cm4gZDMuc2NhbGUubGluZWFyKCkNCiAgICAgICAgLmRvbWFpbihleHRlbnQpDQogICAgICAgIC5yYW5nZShnZXRSYW5nZSgpKTsNCiAgICB9LA0KICAgICJzdHJpbmciOiBmdW5jdGlvbihrKSB7DQogICAgICB2YXIgY291bnRzID0ge30sDQogICAgICAgICAgZG9tYWluID0gW107DQoNCiAgICAgIC8vIExldCdzIGdldCB0aGUgY291bnQgZm9yIGVhY2ggdmFsdWUgc28gdGhhdCB3ZSBjYW4gc29ydCB0aGUgZG9tYWluIGJhc2VkDQogICAgICAvLyBvbiB0aGUgbnVtYmVyIG9mIGl0ZW1zIGZvciBlYWNoIHZhbHVlLg0KICAgICAgX18uZGF0YS5tYXAoZnVuY3Rpb24ocCkgew0KICAgICAgICBpZiAocFtrXSA9PT0gdW5kZWZpbmVkICYmIF9fLm51bGxWYWx1ZVNlcGFyYXRvciE9PSAidW5kZWZpbmVkIil7DQogICAgICAgICAgcmV0dXJuOyAvLyBudWxsIHZhbHVlcyB3aWxsIGJlIGRyYXduIGJleW9uZCB0aGUgaG9yaXpvbnRhbCBudWxsIHZhbHVlIHNlcGFyYXRvciENCiAgICAgICAgfQ0KICAgICAgICBpZiAoY291bnRzW3Bba11dID09PSB1bmRlZmluZWQpIHsNCiAgICAgICAgICBjb3VudHNbcFtrXV0gPSAxOw0KICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgIGNvdW50c1twW2tdXSA9IGNvdW50c1twW2tdXSArIDE7DQogICAgICAgIH0NCiAgICAgIH0pOw0KDQogICAgICBkb21haW4gPSBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyhjb3VudHMpLnNvcnQoZnVuY3Rpb24oYSwgYikgew0KICAgICAgICByZXR1cm4gY291bnRzW2FdIC0gY291bnRzW2JdOw0KICAgICAgfSk7DQoNCiAgICAgIHJldHVybiBkMy5zY2FsZS5vcmRpbmFsKCkNCiAgICAgICAgLmRvbWFpbihkb21haW4pDQogICAgICAgIC5yYW5nZVBvaW50cyhnZXRSYW5nZSgpKTsNCiAgICB9DQogIH07DQoNCiAgZDMua2V5cyhfXy5kaW1lbnNpb25zKS5mb3JFYWNoKGZ1bmN0aW9uKGspIHsNCiAgICBpZiAoIV9fLmRpbWVuc2lvbnNba10ueXNjYWxlKXsNCiAgICAgIF9fLmRpbWVuc2lvbnNba10ueXNjYWxlID0gZGVmYXVsdFNjYWxlc1tfXy5kaW1lbnNpb25zW2tdLnR5cGVdKGspOw0KICAgIH0NCiAgfSk7DQoN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Cn07DQpwYy5kZXRlY3REaW1lbnNpb25zID0gZnVuY3Rpb24oKSB7DQogIHBjLmRpbWVuc2lvbnMocGMuYXBwbHlEaW1lbnNpb25EZWZhdWx0cygpKTsNCiAgcmV0dXJuIHRoaXM7DQp9Ow0KDQpwYy5hcHBseURpbWVuc2lvbkRlZmF1bHRzID0gZnVuY3Rpb24oZGltcykgew0KICB2YXIgdHlwZXMgPSBwYy5kZXRlY3REaW1lbnNpb25UeXBlcyhfXy5kYXRhKTsNCiAgZGltcyA9IGRpbXMgPyBkaW1zIDogZDMua2V5cyh0eXBlcyk7DQogIHZhciBuZXdEaW1zID0ge307DQogIHZhciBjdXJySW5kZXggPSAwOw0KICBkaW1zLmZvckVhY2goZnVuY3Rpb24oaykgew0KICAgIG5ld0RpbXNba10gPSBfXy5kaW1lbnNpb25zW2tdID8gX18uZGltZW5zaW9uc1trXSA6IHt9Ow0KICAgIC8vU2V0IHVwIGRlZmF1bHRzDQogICAgbmV3RGltc1trXS5vcmllbnQ9IG5ld0RpbXNba10ub3JpZW50ID8gbmV3RGltc1trXS5vcmllbnQgOiAnbGVmdCc7DQogICAgbmV3RGltc1trXS50aWNrcz0gbmV3RGltc1trXS50aWNrcyAhPSBudWxsID8gbmV3RGltc1trXS50aWNrcyA6IDU7DQogICAgbmV3RGltc1trXS5pbm5lclRpY2tTaXplPSBuZXdEaW1zW2tdLmlubmVyVGlja1NpemUgIT0gbnVsbCA/IG5ld0RpbXNba10uaW5uZXJUaWNrU2l6ZSA6IDY7DQogICAgbmV3RGltc1trXS5vdXRlclRpY2tTaXplPSBuZXdEaW1zW2tdLm91dGVyVGlja1NpemUgIT0gbnVsbCA/IG5ld0RpbXNba10ub3V0ZXJUaWNrU2l6ZSA6IDA7DQogICAgbmV3RGltc1trXS50aWNrUGFkZGluZz0gbmV3RGltc1trXS50aWNrUGFkZGluZyAhPSBudWxsID8gbmV3RGltc1trXS50aWNrUGFkZGluZyA6IDM7DQogICAgbmV3RGltc1trXS50eXBl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dHlsZSgic2hhcGUtcmVuZGVyaW5nIiwgImNyaXNwRWRnZXMiKTsNCg0KICAgICAgICBheGlzRWxlbWVudC5zZWxlY3RBbGwoImxpbmUiKQ0KICAgICAgICAgICAgLnN0eWxlKCJmaWxsIiwgIm5vbmUiKQ0KICAgICAgICAgICAgLnN0eWxlKCJzdHJva2UiLCAiIzIyMiIpDQogICAgICAgICAgICAuc3R5bGUoInNoYXBlLXJlbmRlcmluZyIsICJjcmlzcEVkZ2VzIik7DQogICAgICB9KQ0KICAgIC5hcHBlbmQoInN2Zzp0ZXh0IikNCiAgICAgIC5hdHRyKHsNCiAgICAgICAgInRleHQtYW5jaG9yIjogIm1pZGRsZSIsDQogICAgICAgICJ5IjogMCwNCiAgICAgICAgInRyYW5zZm9ybSI6ICJ0cmFuc2xhdGUoMCwtNSkgcm90YXRlKCIgKyBfXy5kaW1lbnNpb25UaXRsZVJvdGF0aW9uICsgIikiLA0KICAgICAgICAieCI6IDAsDQogICAgICAgICJjbGFzcyI6ICJsYWJlbCINCiAgICAgIH0pDQogICAgICAudGV4dChkaW1lbnNpb25MYWJlbHMpDQogICAgICAub24oImRibGNsaWNrIiwgZmxpcEF4aXNBbmRVcGRhdGVQQ1ApDQogICAgICAub24oIndoZWVsIiwgcm90YXRlTGFiZWxzKTsNCg0KICBpZiAoX18ubnVsbFZhbHVlU2VwYXJhdG9yPT0idG9wIikgew0KICAgIHBjLnN2Zy5hcHBlbmQoImxpbmUiKQ0KICAgICAgLmF0dHIoIngxIiwgMCkNCiAgICAgIC5hdHRyKCJ5MSIsIDErX18ubnVsbFZhbHVlU2VwYXJhdG9yUGFkZGluZy50b3ApDQogICAgICAuYXR0cigieDIiLCB3KCkpDQogICAgICAuYXR0cigieTIiLCAxK19fLm51bGxWYWx1ZVNlcGFyYXRvclBhZGRpbmcudG9wKQ0KICAgICAgLmF0dHIoInN0cm9rZS13aWR0aCIsIDEpDQogICAgICAuYXR0cigic3Ryb2tlIiwgIiM3NzciKQ0KICAg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ogICAgICB9DQogICAgfSk7DQogIH07DQoNCiAgZnVuY3Rpb24gYnJ1c2hFeHRlbnRzKGV4dGVudHMpIHsNCiAgICBpZiAodHlwZW9mKGV4dGVudHMpID09PSAndW5kZWZpbmVkJykgew0KICAgICAgZXh0ZW50cyA9IHt9Ow0KICAgICAgZDMua2V5cyhfXy5kaW1lbnNpb25zKS5mb3JFYWNoKGZ1bmN0aW9uIChkKSB7DQogICAgICAgIHZhciBicnVzaCA9IGJydXNoZXNbZF07DQogICAgICAgIGlmIChicnVzaCAhPT0gdW5kZWZpbmVkICYmICFicnVzaC5lbXB0eSgpKSB7DQogICAgICAgICAgdmFyIGV4dGVudCA9IGJydXNoLmV4dGVudCgpOw0KICAgICAgICAgIGV4dGVudHNbZF0gPSBleHRlbnQ7DQogICAgICAgIH0NCiAgICAgIH0pOw0KICAgICAgcmV0dXJuIGV4dGVudHM7DQogICAgfQ0KICAgIGVsc2Ugew0KICAgICAgLy9maXJzdCBnZXQgYWxsIHRoZSBicnVzaCBzZWxlY3Rpb25zDQogICAgICB2YXIgYnJ1c2hTZWxlY3Rpb25zID0ge307DQogICAgICBnLnNlbGVjdEFsbCgnLmJydXNoJykNCiAgICAgICAgICAuZWFjaChmdW5jdGlvbiAoZCkgew0KICAgICAgICAgICAgYnJ1c2hTZWxlY3Rpb25zW2RdID0gZDMuc2VsZWN0KHRoaXMpOw0KICAgICAgICAgIH0pOw0KDQogICAgICAvLyBsb29wIG92ZXIgZWFjaCBkaW1lbnNpb24gYW5kIHVwZGF0ZSBhcHByb3ByaWF0ZWx5IChpZiBpdCB3YXMgcGFzc2VkIGluIHRocm91Z2ggZXh0ZW50cykNCiAgICAgIGQzLmtleXMoX18uZGltZW5zaW9ucykuZm9yRWFjaChmdW5jdGlvbiAoZCkgew0KICAgICAgICBpZiAoZXh0ZW50c1tkXSA9PT0gdW5kZWZpbmVkKSB7DQogICAgICAgICAgcmV0dXJuOw0KICAgICAgICB9DQoNCiAgICAgICAgdmFyIGJydXN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1haW5pbmcgPSBmdW5jdGlvbigpIHsNCiAgICByZXR1cm4gX3F1ZXVlLmxlbmd0aCAtIF9pOw0KICB9Ow0KDQogIC8vIGNsZWFyIHRoZSBjYW52YXMNCiAgcnEuY2xlYXIgPSBmdW5jdGlvbihmdW5jKSB7DQogICAgaWYgKCFhcmd1bWVudHMubGVuZ3RoKSB7DQogICAgICBfY2xlYXIoKTsNCiAgICAgIHJldHVybiBycTsNCiAgICB9DQogICAgX2NsZWFyID0gZnVuYzsNCiAgICByZXR1cm4gcnE7DQogIH07DQoNCiAgcnEuaW52YWxpZGF0ZSA9IGZ1bmN0aW9uKCkge307DQoNCiAgcmV0dXJuIHJxOw0KfSk7DQo="></script>
<script src="data:application/x-javascript;base64,SFRNTFdpZGdldHMud2lkZ2V0KHsNCg0KICBuYW1lOiAncGFyY29vcmRzJywNCg0KICB0eXBlOiAnb3V0cHV0JywNCg0KICBmYWN0b3J5OiBmdW5jdGlvbihlbCwgd2lkdGgsIGhlaWdodCkgew0KDQogICAgdmFyIGluc3RhbmNlID0geyB9Ow0KDQogICAgdmFyIGRyYXcgPSBmdW5jdGlvbihlbCwgaW5zdGFuY2Upew0KDQogICAgICB2YXIgeCA9IGluc3RhbmNlLng7DQoNCiAgICAgIC8vdWdseSBidXQgY3VycmVudGx5IGhhdmUgdG8gY2xlYXIgb3V0DQogICAgICAvLyAgZWFjaCB0aW1lIHRvIGdldCBwcm9wZXIgcmVuZGVyDQogICAgICAvLyBkZWxldGUgYWxsIGNoaWxkcmVuIG9mIGVsDQogICAgICAvLyAgcG9zc2libHkgcmV2aXNpdCB0byBzZWUgaWYgd2Ugc2hvdWxkIGJlIGEgbGl0dGxlIG1vcmUgZGVsaWNhdGUNCiAgICAgIGQzLnNlbGVjdCggZWwgKS5zZWxlY3RBbGwoIioiKS5yZW1vdmUoKTsNCg0KICAgICAgLy8gaWYgaGVpZ2h0IG9yIHdpZHRoID0gMCB0aGVuIGJhaWwNCiAgICAgIC8vICAgdGhpcyBp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b29yZHMub24oInJlbmRlciIsIGZ1bmN0aW9uKCkgew0KICAgICAgICAgIHZhciBpZHMgPSBbXTsNCiAgICAgICAgICBpZigNCiAgICAgICAgICAgIHRoaXMuYnJ1c2hlZCgpICYmDQogICAgICAgICAgICB0aGlzLmJydXNoZWQoKS5sZW5ndGggPCBwYXJjb29yZHMuZGF0YSgpLmxlbmd0aA0KICAgICAgICAgICl7DQogICAgICAgICAgICBpZHMgPSB0aGlzLmJydXNoZWQoKS5tYXAoZnVuY3Rpb24oZCl7DQogICAgICAgICAgICAgIHJldHVybiBkLmtleV87DQogICAgICAgICAgICB9KQ0KICAgICAgICAgICAgLy8gYWRkIGJydXNoZWQgdG8gZmlsdGVyDQogICAgICAgICAgICBjdF9zZWwuc2V0KGlkcyk7DQogICAgICAgICAgICB0aGlzLmhpZ2hsaWdodCh0aGlzLmJydXNoZWQoKSk7DQogICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgIHBhcmNvb3Jkcy51bmhpZ2hsaWdodCgpOw0KICAgICAgICAgICAgLy8gaW5zdGVhZCBzZXQgdG8gZW1wdHkgYXJyYXkNCiAgICAgICAgICAgIC8vIGZpcnN0IGNoZWNrIHRvIG1ha2Ugc3VyZSBwYXJjb29yZHMgaW5pdGlhdGVkDQogICAgICAgICAgICAvLyAgYmVmb3JlIGNsZWFyaW5nDQogICAgICAgICAgICBpZih0eXBlb2YocGFyY29vcmRzLmJydXNoUmVzZXR0ZXIpICE9PSAidW5kZWZpbmVkIiAmJg0KICAgICAgICAgICAgICAgIHBhcmNvb3Jkcy5icnVzaFJlc2V0dGVyID09PSAic2VsZiINCiAgICAgICAgICAgICkgew0KICAgICAgICAgICAgICAvLyBzZWVtcyB0aGlzIHNldHMgdG8gdW5kZWZpbmVkDQogICAgICAgICAgICAgIC8vICAgd2hpY2ggUGxvdGx5IGRvZXMgbm90IGN1cnJlbnRseSBoYW5kbGUNCiAgICAgICAgICAgICAgLy9jdF9zZWwuY2xlYXIoKTsNCiAg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W9ucw0KICAgICAgT2JqZWN0LmtleXMoIHgub3B0aW9ucyApLmZpbHRlcihmdW5jdGlvbihrKXsgcmV0dXJuIGsgIT09ICJyZW9yZGVyYWJsZSIgJiYgayAhPT0gImJydXNoTW9kZSIgJiYgayAhPT0gImJydXNoUHJlZGljYXRlIiAmJiBrIT09ICJjb2xvciIgJiYgayE9PSJyb3duYW1lcyJ9KS5tYXAoIGZ1bmN0aW9uKGspIHsNCiAgICAgICAgLy8gaWYgdGhlIGtleSBleGlzdHMgd2l0aGluIHBhcmNvb3Jkcw0KICAgICAgICBpZiAoIHBhcmNvb3Jkc1trXSApew0KICAgICAgICAgIGlmKCB0eXBlb2YgeC5vcHRpb25zW2tdID09PSAiYm9vbGVhbiIgKXsNCiAgICAgICAgICAgIHRyeSB7DQogICAgICAgICAgICAgIHBhcmNvb3Jkc1trXSgpOw0KICAgICAgICAgICAgfSBjYXRjaChlKSB7DQogICAgICAgICAgICAgIGNvbnNvbGUubG9nKCAia2V5L29wdGlvbjogIiArIGsgKyAiIGRpZCBub3Qgd29yayBzbyBpZ25vcmUgZm9yIG5vdy4iICkNCiAgICAgICAgICAgIH0NCiAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgdHJ5ew0KICAgICAgICAgICAgICBwYXJjb29yZHNba10oIHgub3B0aW9uc1trXSApOw0KICAgICAgICAgICAgfSBjYXRjaChlKSB7DQogICAgICAgICAgICAgIGNvbnNvbGUubG9nKCAia2V5L29wdGlvbjogIiArIGsgKyAiIHdpdGggdmFsdWUgIiArIHgub3B0aW9uc1trXSArICJkaWQgbm90IHdvcmsgc28gaWdub3JlIGZvciBub3cuIiApDQogICAgICAgICAgICB9DQogICAgICAgICAgfQ0KICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgIGNvbnNvbGUubG9nKCAia2V5L29wdGlvbjogIiArIGsgKyAiIGlzIG5vdCBhdmFpbGFibGUgZm9yIGN1c3RvbWl6YXRpb24uIiApDQogICAgICAgIH0NCiAgICAgI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GVmaW5lZCIgfHwNCiAgICAgICAgICAgIGN0X3NlbC52YWx1ZSA9PT0gbnVsbCB8fA0KICAgICAgICAgICAgKEFycmF5LmlzQXJyYXkoY3Rfc2VsLnZhbHVlKSAmJiBjdF9zZWwudmFsdWUubGVuZ3RoID09PSAwKQ0KICAgICAgICAgICkpIHsNCiAgICAgICAgICAgIHZhciBzZWxlY3RlZCA9IGN0X3NlbC52YWx1ZTsNCg0KICAgICAgICAgICAgLy8gaGFuZGxlIG5vbi1hcnJheSBzaW5nbGUtdmFsdWUNCiAgICAgICAgICAgIGlmKCFBcnJheS5pc0FycmF5KHNlbGVjdGVkKSkgew0KICAgICAgICAgICAgICBzZWxlY3RlZCA9IFtzZWxlY3RlZF07DQogICAgICAgICAgICB9DQogICAgICAgICAgICBpZihzZWwuc2VuZGVyID09PSBjdF9zZWwpew0KICAgICAgICAgICAgICAvLyBkbyBub3RoaW5nIGZvciBub3cNCiAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgIC8vIGNsZWFyIGJydXNoZXMNCiAgICAgICAgICAgICAgaWYocGFyY29vcmRzLmJydXNoZWQoKSl7DQogICAgICAgICAgICAgICAgLy8gbmFzdHkgd2F5IG9mIGRldGVybWluaW5nIHNvdXJjZSBvZiBicnVzaCByZXNldA0KICAgICAgICAgICAgICAgIC8vICAgbmVlZCB0aGlzIHRvIGtub3cgd2hldGhlciB0byBjaGFuZ2UNCiAgICAgICAgICAgICAgICAvLyAgIGNyb3NzdGFsayBzZWxlY3Rpb24gb3IgaWYgdGhlIGJydXNoIHJlc2V0DQogICAgICAgICAgICAgICAgLy8gICBpcyBhbiBvdXRjb21lIGNhdXNlZCBieSBzb21ldGhpbmcgb3RoZXIgdGhhbg0KICAgICAgICAgICAgICAgIC8vICAgdGhpcyBwYXJjb29yZHMgY2hhbmdpbmcgdGhlIHNlbGVjdGlvbg0KICAgICAgICAgICAgICAgIHBhcmNvb3Jkcy5icnVzaFJlc2V0dGVyID0gIm90aGVyIjsNCiAgICAgICAgICAgICAgICBwYXJjb29yZHMuYnJ1c2hSZXNldCgpOw0KICAgICAgICAgICAgICAgIHBhcmNvb3Jkcy5icnVzaFJlc2V0dGVyID0gInNlbGYiOw0KICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgIC8vIHVzZSBoaWdobGlnaHQgdG8gc2hvdyB0aGUgc2VsZWN0aW9uDQogICAgICAgICAgICAgIHBhcmNvb3Jkcy5oaWdobGlnaHQocGFyY29vcmRzLmRhdGEoKS5maWx0ZXIoZnVuY3Rpb24oZCxpKSB7DQogICAgICAgICAgICAgICAgcmV0dXJuIHNlbGVjdGVkLmluZGV4T2YoZC5rZXlfKSA+PSAwOw0KICAgICAgICAgICAgICB9KSk7DQogICAgICAgICAgICB9DQogICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgIHBhcmNvb3Jkcy51bmhpZ2hsaWdodCgpOw0KICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgICB9DQoNCiAgICAgIHJldHVybiBpbnN0YW5jZTsNCg0KICAgIH07DQoNCiAgICByZXR1cm4gew0KDQogICAgICByZW5kZXJWYWx1ZTogZnVuY3Rpb24oeCkgew0KDQogICAgICAgIC8vIGJhc2ljIGNoZWNrIG9mIGRhdGEgdG8gbWFrZSBzdXJlIHdlIHJlY2VpdmVkDQogICAgICAgIC8vICAgaW4gY29sdW1uIGZvcm1hdCBvciBvYmplY3Qgb2YgYXJyYXlzDQogICAgICAgIC8vICAgd2hpY2ggaXMgdGhlIGRlZmF1bHQgYmVoYXZpb3Igb2YgaHRtbHdpZGdldHMNCiAgICAgICAgLy8gICByZWFzb24gZm9yIHRoaXMgY2hlY2sgaXMNCiAgICAgICAgLy8gICAgICBmdXR1cmUtcHJvb2ZpbmcgaWYgYmVoYXZpb3IgY2hhbmdlcw0KICAgICAgICAvLyAgICAgIHNvbWVvbmUgc3VwcGxpZXMgZGF0YSBpbiBhbiBhdHlwaWNhbCB3YXkNCiAgICAgICAgaWYoIHguZGF0YS5jb25zdHJ1Y3Rvci5uYW1lID09PSAiT2JqZWN0IiApew0KICAgICAgICAgIC8vIHVzZSBIVE1MV2lkZ2V0cyBmdW5jdGlvbiB0byBjb252ZXJ0IHRvIGFuIGFycmF5IG9mIG9iamVjdHMgKHJvdyBmb3JtYXQpDQogICAgICAgICAgeC5kYXRhID0gSFRNTFdpZGdldHMuZGF0YWZyYW1lVG9EMyggeC5kYXRhICkNCiAgICAgICAgfQ0KDQogICAgICAgIGluc3RhbmNlLnggPSB4Ow0KDQogICAgICAgIGluc3RhbmNlID0gZHJhdyhlbCwgaW5zdGFuY2UpOw0KDQogICAgICB9LA0KDQogICAgICByZXNpemU6IGZ1bmN0aW9uKHdpZHRoLCBoZWlnaHQpIHsNCg0KICAgICAgICAvLyBvbmx5IHJlc2l6ZSBpZiBhdXRvcmVzaXplIHNldCB0byBUUlVFDQogICAgICAgIC8vICAgcmVzaXplIHdpbGwgY2F1c2UgdGhlIGVudGlyZSBwYXJjb29yZHMgdG8gcmUtcmVuZGVyDQogICAgICAgIC8vICAgc28gYnJ1c2hlZCBzZWxlY3Rpb25zLCBldGMuIHdpbGwgYmUgbG9zdA0KICAgICAgICAvLyAgIGFuZCBpbiBldmVudCBvZiBiaWdnZXIgZGF0YSwgZXhwZW5zaXZlIHJlLXJlbmRlcg0KICAgICAgICAvLyAgIHdpbGwgb2NjdXINCiAgICAgICAgaWYoaW5zdGFuY2UueC5hdXRvcmVzaXplKXsNCg0KICAgICAgICAgIGluc3RhbmNlID0gZHJhdyhlbCwgaW5zdGFuY2UpOw0KDQogICAgICAgIH0NCg0KICAgICAgfSwNCg0KICAgICAgaW5zdGFuY2U6IGluc3RhbmNlDQoNCiAgICB9Ow0KICB9DQp9KTsNCg=="></script>
</head>
<body style="background-color:white;">
<select name="cyl" id="select-cyl" multiple="true"> <option>4</option> <option>6</option> <option>8</option> </select>
<div id="htmlwidget-098fa33a6b9854897de0" class="parcoords html-widget" style="width:960px;height:400px;">
</div>
<script type="application/json" data-for="htmlwidget-098fa33a6b9854897de0">{"x":{"data":{"names":["Mazda RX4","Mazda RX4 Wag","Datsun 710","Hornet 4 Drive","Hornet Sportabout","Valiant","Duster 360","Merc 240D","Merc 230","Merc 280","Merc 280C","Merc 450SE","Merc 450SL","Merc 450SLC","Cadillac Fleetwood","Lincoln Continental","Chrysler Imperial","Fiat 128","Honda Civic","Toyota Corolla","Toyota Corona","Dodge Challenger","AMC Javelin","Camaro Z28","Pontiac Firebird","Fiat X1-9","Porsche 914-2","Lotus Europa","Ford Pantera L","Ferrari Dino","Maserati Bora","Volvo 142E"],"mpg":[21,21,22.8,21.4,18.7,18.1,14.3,24.4,22.8,19.2,17.8,16.4,17.3,15.2,10.4,10.4,14.7,32.4,30.4,33.9,21.5,15.5,15.2,13.3,19.2,27.3,26,30.4,15.8,19.7,15,21.4],"cyl":[6,6,4,6,8,6,8,4,4,6,6,8,8,8,8,8,8,4,4,4,4,8,8,8,8,4,4,4,8,6,8,4],"disp":[160,160,108,258,360,225,360,146.7,140.8,167.6,167.6,275.8,275.8,275.8,472,460,440,78.7,75.7,71.1,120.1,318,304,350,400,79,120.3,95.1,351,145,301,121],"hp":[110,110,93,110,175,105,245,62,95,123,123,180,180,180,205,215,230,66,52,65,97,150,150,245,175,66,91,113,264,175,335,109],"drat":[3.9,3.9,3.85,3.08,3.15,2.76,3.21,3.69,3.92,3.92,3.92,3.07,3.07,3.07,2.93,3,3.23,4.08,4.93,4.22,3.7,2.76,3.15,3.73,3.08,4.08,4.43,3.77,4.22,3.62,3.54,4.11],"wt":[2.62,2.875,2.32,3.215,3.44,3.46,3.57,3.19,3.15,3.44,3.44,4.07,3.73,3.78,5.25,5.424,5.345,2.2,1.615,1.835,2.465,3.52,3.435,3.84,3.845,1.935,2.14,1.513,3.17,2.77,3.57,2.78],"qsec":[16.46,17.02,18.61,19.44,17.02,20.22,15.84,20,22.9,18.3,18.9,17.4,17.6,18,17.98,17.82,17.42,19.47,18.52,19.9,20.01,16.87,17.3,15.41,17.05,18.9,16.7,16.9,14.5,15.5,14.6,18.6],"vs":[0,0,1,1,0,1,0,1,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1,0,1,0,0,0,1],"am":[1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1],"gear":[4,4,4,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,3,3,3,3,3,4,5,5,5,5,5,4],"carb":[4,4,1,1,2,1,4,2,2,4,4,3,3,3,4,4,4,1,2,1,1,2,2,4,2,1,2,2,4,6,8,2]},"options":{"rownames":true,"brushMode":"1D-axes","brushPredicate":"AND","reorderable":false,"margin":{"top":50,"bottom":50,"left":100,"right":50},"mode":false},"autoresize":false,"tasks":null},"evals":[],"jsHooks":[]}</script>
<script>
d3.select('#select-cyl').on('change', function() {
var pc = HTMLWidgets.find('.parcoords').instance.parcoords
var selected = []
d3.select(this).selectAll('option:checked').each(function(d){
selected.push(+this.value)
})
var filters = pc.outsideFilters() || {}
if(selected.length > 0) {
filters.cyl = selected
pc.outsideFilters(filters)
} else {
delete filters.cyl
pc.outsideFilters(filters)
}
// now update
pc.brushUpdated(pc.selected())
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment