|
!function(n){function t(a){if(e[a])return e[a].exports;var g=e[a]={i:a,l:!1,exports:{}};return n[a].call(g.exports,g,g.exports,t),g.l=!0,g.exports}var e={};t.m=n,t.c=e,t.i=function(n){return n},t.d=function(n,e,a){t.o(n,e)||Object.defineProperty(n,e,{configurable:!1,enumerable:!0,get:a})},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},t.p="",t(t.s=1)}([function(module,exports,__webpack_require__){"use strict";eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nfunction _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }\n\nvar d3 = window.d3;\n\nexports.default = function () {\n var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4;\n\n // list of clusters\n var clusters = createClusters(amount);\n // have a root node to start with\n var data = [{ name: 'root', parent: null }];\n\n clusters.forEach(function (d) {\n var r = Math.floor(d3.randomUniform(2, 40)());\n var children = createChildren(r, d);\n // pass in the parent items\n data.push({ name: d, parent: 'root' });\n // pass in some children\n data = data.concat(children);\n });\n\n return data;\n};\n\n// create clusters\n\n\nfunction createClusters() {\n var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4;\n var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'cluster_';\n\n var list = [].concat(_toConsumableArray(Array(amount).keys())).map(function (d) {\n return name + d;\n });\n return list;\n}\n\n// add some dummy data to each cluster\nfunction createChildren() {\n var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;\n var cluster = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'c_1';\n\n var o = [].concat(_toConsumableArray(Array(amount).keys())).map(function (d, i) {\n return {\n name: cluster + ' | item_' + i,\n parent: cluster\n };\n });\n return o;\n}//# sourceURL=[module]\n//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dGVyXG5mdW5jdGlvbiBjcmVhdGVDaGlsZHJlbiAoYW1vdW50ID0gMTAsIGNsdXN0ZXIgPSAnY18xJykge1xuICBjb25zdCBvID0gWy4uLkFycmF5KGFtb3VudCkua2V5cygpXS5tYXAoKGQsIGkpID0+IHtcbiAgICByZXR1cm4ge1xuICAgICAgbmFtZTogYCR7Y2x1c3Rlcn0gfCBpdGVtXyR7aX1gLFxuICAgICAgcGFyZW50OiBjbHVzdGVyXG4gICAgfVxuICB9KVxuICByZXR1cm4gb1xufVxuXG5cblxuLy8gV0VCUEFDSyBGT09URVIgLy9cbi8vIGR1bW15RGF0YS5qcyJdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7QUFBQTtBQUNBO0FBQ0E7QUFBQTtBQUNBO0FBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUdBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQURBO0FBQUE7QUFBQTtBQUNBO0FBQUE7QUFBQTtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUFBO0FBQUE7QUFDQTtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBRkE7QUFJQTtBQUNBO0FBQ0EiLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///0\n")},function(module,exports,__webpack_require__){"use strict";eval("\n\nvar _dummyData = __webpack_require__(0);\n\nvar _dummyData2 = _interopRequireDefault(_dummyData);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar d3 = window.d3;\n\nfunction enclosureDiagram(bind, flatData, config) {\n config = {\n width: 960,\n height: 800,\n radius: 5,\n padding: 5\n };\n\n var _config = config,\n width = _config.width,\n height = _config.height;\n\n var selection = d3.select(bind);\n\n // initialize tooltip after a destroy\n d3.selectAll('.d3-tip').remove();\n var tip = d3.tip().attr('class', 'd3-tip').html(function (d) {\n return d.data.id;\n }).offset([-10, 1]);\n // invoke the tip in the context of your visualization\n selection.call(tip);\n\n // convert the flat data into a hierarchy\n var data = d3.stratify().id(function (d) {\n return d.name;\n }).parentId(function (d) {\n return d.parent;\n })(flatData);\n\n var packLayout = d3.pack().size([width, height]).radius(function () {\n return config.radius;\n }).padding(config.padding);\n\n var rootNode = d3.hierarchy(data);\n\n // run .sum() on the hierarchy; return 1 for size of leaf nodes\n rootNode.sum(function () {\n return 1;\n });\n\n packLayout(rootNode);\n\n renderCircles(rootNode.descendants());\n\n function renderCircles(nodes) {\n var circles = selection.selectAll('circle').data(nodes, function (d) {\n return d.data.id;\n });\n circles.exit().remove();\n circles.enter().append('circle').attr('class', function (d) {\n if (d.depth === 0) {\n return 'root';\n } else if (d.depth === 1) {\n return 'cluster';\n } else {\n return 'item';\n }\n }).merge(circles).attr('cx', function (d) {\n return d.x;\n }).attr('cy', function (d) {\n return d.y;\n }).attr('r', function (d) {\n return d.r;\n })\n // .on('mouseover', tip.show)\n .on('mouseover', function (d) {\n // use a timeout/delay to stop crazy flickering\n var context = this;\n var args = [].slice.call(arguments);\n var timeout = null;\n args.push(this);\n clearTimeout(timeout);\n timeout = setTimeout(function () {\n tip.show.apply(context, args);\n }, 100);\n }).on('mouseout', tip.hide);\n }\n}\n\n// run the visualisation\nvar chart = enclosureDiagram;\nchart('g#vis', (0, _dummyData2.default)(27));\n\n// when the input range changes re-render (set in index.html)\nd3.select('#cluster-amount').on('input', function () {\n d3.select('#slider-amount').text(+this.value);\n chart('g#vis', (0, _dummyData2.default)(+this.value));\n});//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9zY3JpcHQuanM/OWE5NSJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgZHVtbXlEYXRhIGZyb20gJy4vZHVtbXlE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