From fd74ede9bea254d100b5319d695aed24f65b1997 Mon Sep 17 00:00:00 2001 From: Bart Mesuere Date: Sun, 25 Aug 2019 16:36:34 +0200 Subject: [PATCH 1/5] remove old build system --- .babelrc | 4 ---- Gruntfile.js | 54 --------------------------------------------------- package.json | 21 ++------------------ renovate.json | 5 ----- 4 files changed, 2 insertions(+), 82 deletions(-) delete mode 100644 .babelrc delete mode 100644 Gruntfile.js delete mode 100644 renovate.json diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 3c3b968..0000000 --- a/.babelrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "presets": ["es2015"], - "plugins": ["transform-object-assign"] -} diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index de9deb2..0000000 --- a/Gruntfile.js +++ /dev/null @@ -1,54 +0,0 @@ -module.exports = function (grunt) { - grunt.initConfig({ - pkg: grunt.file.readJSON("package.json"), - webpack: { - dist: { - entry: "./src/index.js", - output: { - path: "dist/", - filename: "<%= pkg.name %>.js", - }, - devtool: "source-map", - module: { - loaders: [ - { - loader: "babel-loader", - }, - ], - }, - }, - }, - eslint: { - src: ["src/**/*.js"], - }, - uglify: { - options: { - // the banner is inserted at the top of the output - banner: "/*! <%= pkg.name %> <%= pkg.version %> <%= grunt.template.today(\"dd-mm-yyyy\") %> */\n", - }, - dist: { - files: { - "dist/<%= pkg.name %>.min.js": ["dist/<%= pkg.name %>.es5.js"], - }, - }, - }, - babel: { - options: { - sourceMap: true, - }, - dist: { - files: { - "dist/<%= pkg.name %>.es5.js": ["dist/<%= pkg.name %>.js"], - }, - }, - }, - }); - - grunt.loadNpmTasks("grunt-contrib-uglify"); - grunt.loadNpmTasks("grunt-babel"); - grunt.loadNpmTasks("grunt-webpack"); - grunt.loadNpmTasks("gruntify-eslint"); - - // the default task can be run just by typing "grunt" on the command line - grunt.registerTask("default", ["eslint", "webpack", "babel", "uglify"]); -}; diff --git a/package.json b/package.json index f24c825..70e7ca3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unipept-visualizations", - "version": "1.7.3", + "version": "2.0b", "description": "Unipept visualisation tools", "main": "index.js", "scripts": { @@ -14,23 +14,6 @@ ], "author": "Bart Mesuere", "license": "MIT", - "devDependencies": { - "babel-cli": "^6.18.0", - "babel-core": "^6.21.0", - "babel-loader": "^6.2.10", - "babel-plugin-transform-object-assign": "^6.8.0", - "babel-preset-es2015": "^6.18.0", - "eslint": "^3.13.1", - "eslint-config-google": "^0.7.1", - "eslint-plugin-import": "^2.2.0", - "grunt": "^1.0.1", - "grunt-babel": "^6.0.0", - "grunt-contrib-uglify": "^2.0.0", - "grunt-webpack": "^1.0.18", - "gruntify-eslint": "^3.1.0", - "load-grunt-tasks": "^3.5.2", - "webpack": "^1.14.0", - "webpack-dev-server": "^3.1.14" - }, + "devDependencies": {}, "dependencies": {} } diff --git a/renovate.json b/renovate.json deleted file mode 100644 index f45d8f1..0000000 --- a/renovate.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": [ - "config:base" - ] -} From 47359138f25b8914a7b355893d250e15d71bc8d5 Mon Sep 17 00:00:00 2001 From: Bart Mesuere Date: Sun, 25 Aug 2019 17:28:07 +0200 Subject: [PATCH 2/5] set up new build system --- .babelrc | 12 + .eslintrc | 79 +- .gitignore | 1 + dist/bundle.js | 113 + dist/index.d.ts | 0 dist/unipept-visualizations.es5.js | 2096 ------ dist/unipept-visualizations.es5.js.map | 1 - dist/unipept-visualizations.js | 1923 ------ dist/unipept-visualizations.js.map | 1 - dist/unipept-visualizations.min.js | 4 - package.json | 43 +- {src => src-old}/index.js | 0 {src => src-old}/shared/maxcountheap.js | 0 {src => src-old}/shared/node.js | 0 {src => src-old}/shared/univis.js | 0 {src => src-old}/sunburst/sunburst.js | 0 {src => src-old}/sunburst/sunburstNode.js | 0 {src => src-old}/treemap/treemap.js | 0 {src => src-old}/treemap/treemapNode.js | 0 {src => src-old}/treeview/treeview.js | 0 {src => src-old}/treeview/treeviewNode.js | 0 src/index.ts | 0 tsconfig.json | 61 + webpack.config.js | 28 + yarn.lock | 7047 +++++++++++++-------- 25 files changed, 4716 insertions(+), 6693 deletions(-) create mode 100644 .babelrc create mode 100644 dist/bundle.js create mode 100644 dist/index.d.ts delete mode 100644 dist/unipept-visualizations.es5.js delete mode 100644 dist/unipept-visualizations.es5.js.map delete mode 100644 dist/unipept-visualizations.js delete mode 100644 dist/unipept-visualizations.js.map delete mode 100644 dist/unipept-visualizations.min.js rename {src => src-old}/index.js (100%) rename {src => src-old}/shared/maxcountheap.js (100%) rename {src => src-old}/shared/node.js (100%) rename {src => src-old}/shared/univis.js (100%) rename {src => src-old}/sunburst/sunburst.js (100%) rename {src => src-old}/sunburst/sunburstNode.js (100%) rename {src => src-old}/treemap/treemap.js (100%) rename {src => src-old}/treemap/treemapNode.js (100%) rename {src => src-old}/treeview/treeview.js (100%) rename {src => src-old}/treeview/treeviewNode.js (100%) create mode 100644 src/index.ts create mode 100644 tsconfig.json create mode 100644 webpack.config.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..3db41c1 --- /dev/null +++ b/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": [ + [ + "@babel/preset-env", + { + "targets": { + "browsers": ["last 2 versions"] + } + } + ] + ] +} diff --git a/.eslintrc b/.eslintrc index bd60054..84fdf64 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,35 +1,48 @@ { - "parserOptions": { - "ecmaVersion": 6, - "sourceType": "module" - }, - "extends": ["eslint:recommended", "google"], - "plugins": ["import"], - "rules": { - "arrow-parens": ["error", "as-needed"], - "no-underscore-dangle": "off", - "no-use-before-define": "off", - "no-confusing-arrow": "off", - "no-unused-vars": "off", - "no-plusplus": "off", - "no-else-return": "off", - "one-var": "off", - "require-jsdoc": "off", - "valid-jsdoc": "off", - "space-before-function-paren": ["error", {"anonymous": "always", "named": "never", "asyncArrow": "always"}], - "no-param-reassign": ["error", { "props": false }], - "indent": ["error", 4], - "max-len": "off", - "quotes": ["error", "double"], - "new-cap": "off", - "no-invalid-this": "off", - "no-console": "off", - }, - "env": { - "browser": true - }, - "globals": { - "d3": false, - "$": false - } + "plugins": ["jest", "@typescript-eslint"], + "extends": [ + "plugin:@typescript-eslint/recommended", + "plugin:jest/recommended" + ], + "parser": "@typescript-eslint/parser", + "rules": { + "@typescript-eslint/explicit-member-accessibility": "off", + "@typescript-eslint/explicit-function-return-type": [ + "error", + { + "allowExpressions": true + } + ], + "@typescript-eslint/no-parameter-properties": "off", + "arrow-parens": ["error", "as-needed"], + "indent": ["error", 4], + "max-len": [ + "warn", + { + "code": 100 + } + ], + "no-invalid-this": "warn", + "no-param-reassign": [ + "error", + { + "props": false + } + ], + "object-curly-spacing": ["error", "always"], + "quotes": ["error", "double"], + "require-jsdoc": "off", + "space-before-function-paren": [ + "error", + { + "anonymous": "always", + "named": "never", + "asyncArrow": "always" + } + ] + }, + "env": { + "browser": true, + "jest/globals": true + } } diff --git a/.gitignore b/.gitignore index ce380c6..6a2153b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/* .DS_Store +yarn-error.log diff --git a/dist/bundle.js b/dist/bundle.js new file mode 100644 index 0000000..8c503f3 --- /dev/null +++ b/dist/bundle.js @@ -0,0 +1,113 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["Heatmap"] = factory(); + else + root["Heatmap"] = factory(); +})(window, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = "./src/index.ts"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "./src/index.ts": +/*!**********************!*\ + !*** ./src/index.ts ***! + \**********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +/***/ }) + +/******/ }); +}); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly9IZWF0bWFwL3dlYnBhY2svdW5pdmVyc2FsTW9kdWxlRGVmaW5pdGlvbiIsIndlYnBhY2s6Ly9IZWF0bWFwL3dlYnBhY2svYm9vdHN0cmFwIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBLENBQUM7QUFDRCxPO1FDVkE7UUFDQTs7UUFFQTtRQUNBOztRQUVBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQTtRQUNBOztRQUVBO1FBQ0E7O1FBRUE7UUFDQTs7UUFFQTtRQUNBO1FBQ0E7OztRQUdBO1FBQ0E7O1FBRUE7UUFDQTs7UUFFQTtRQUNBO1FBQ0E7UUFDQSwwQ0FBMEMsZ0NBQWdDO1FBQzFFO1FBQ0E7O1FBRUE7UUFDQTtRQUNBO1FBQ0Esd0RBQXdELGtCQUFrQjtRQUMxRTtRQUNBLGlEQUFpRCxjQUFjO1FBQy9EOztRQUVBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQSx5Q0FBeUMsaUNBQWlDO1FBQzFFLGdIQUFnSCxtQkFBbUIsRUFBRTtRQUNySTtRQUNBOztRQUVBO1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cbiBcdC8vIE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbFxuIFx0X193ZWJwYWNrX3JlcXVpcmVfXy5vID0gZnVuY3Rpb24ob2JqZWN0LCBwcm9wZXJ0eSkgeyByZXR1cm4gT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKG9iamVjdCwgcHJvcGVydHkpOyB9O1xuXG4gXHQvLyBfX3dlYnBhY2tfcHVibGljX3BhdGhfX1xuIFx0X193ZWJwYWNrX3JlcXVpcmVfXy5wID0gXCJcIjtcblxuXG4gXHQvLyBMb2FkIGVudHJ5IG1vZHVsZSBhbmQgcmV0dXJuIGV4cG9ydHNcbiBcdHJldHVybiBfX3dlYnBhY2tfcmVxdWlyZV9fKF9fd2VicGFja19yZXF1aXJlX18ucyA9IFwiLi9zcmMvaW5kZXgudHNcIik7XG4iXSwic291cmNlUm9vdCI6IiJ9 \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..e69de29 diff --git a/dist/unipept-visualizations.es5.js b/dist/unipept-visualizations.es5.js deleted file mode 100644 index 0997407..0000000 --- a/dist/unipept-visualizations.es5.js +++ /dev/null @@ -1,2096 +0,0 @@ -"use strict"; - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -/******/(function (modules) { - // webpackBootstrap - /******/ // The module cache - /******/var installedModules = {}; - /******/ - /******/ // The require function - /******/function __webpack_require__(moduleId) { - /******/ - /******/ // Check if module is in cache - /******/if (installedModules[moduleId]) - /******/return installedModules[moduleId].exports; - /******/ - /******/ // Create a new module (and put it into the cache) - /******/var module = installedModules[moduleId] = { - /******/exports: {}, - /******/id: moduleId, - /******/loaded: false - /******/ }; - /******/ - /******/ // Execute the module function - /******/modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); - /******/ - /******/ // Flag the module as loaded - /******/module.loaded = true; - /******/ - /******/ // Return the exports of the module - /******/return module.exports; - /******/ - } - /******/ - /******/ - /******/ // expose the modules object (__webpack_modules__) - /******/__webpack_require__.m = modules; - /******/ - /******/ // expose the module cache - /******/__webpack_require__.c = installedModules; - /******/ - /******/ // __webpack_public_path__ - /******/__webpack_require__.p = ""; - /******/ - /******/ // Load entry module and return exports - /******/return __webpack_require__(0); - /******/ -})( -/************************************************************************/ -/******/[ -/* 0 */ -/***/function (module, exports, __webpack_require__) { - - "use strict"; - - var _treeview = __webpack_require__(1); - - var _treeview2 = _interopRequireDefault(_treeview); - - var _treemap = __webpack_require__(6); - - var _treemap2 = _interopRequireDefault(_treemap); - - var _sunburst = __webpack_require__(8); - - var _sunburst2 = _interopRequireDefault(_sunburst); - - function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : { default: obj }; - } - - /***/ -}, -/* 1 */ -/***/function (module, exports, __webpack_require__) { - - "use strict"; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _extends = Object.assign || function (target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i];for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } - }return target; - }; /** - * Zoomable treeview, inspiration from - * - http://bl.ocks.org/mbostock/4339083 - * - https://gist.github.com/robschmuecker/7880033 - * - http://www.brightpointinc.com/interactive/budget/index.html?source=d3js - */ - - exports.default = TreeView; - - var _univis = __webpack_require__(2); - - var _univis2 = _interopRequireDefault(_univis); - - var _maxcountheap = __webpack_require__(3); - - var _maxcountheap2 = _interopRequireDefault(_maxcountheap); - - var _treeviewNode = __webpack_require__(4); - - var _treeviewNode2 = _interopRequireDefault(_treeviewNode); - - function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : { default: obj }; - } - - function TreeView(element, data) { - var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - - var that = {}; - - var MARGIN = { - top: 5, - right: 5, - bottom: 5, - left: 5 - }, - DURATION = 750, - COLOR_SCALE = d3.scale.category10(), - DEFAULTS = { - height: 300, - width: 600, - nodeDistance: 180, - levelsToExpand: 2, - minNodeSize: 2, - maxNodeSize: 105, - - countAccessor: function countAccessor(d) { - return d.data.count; - }, - rerootCallback: undefined, - - colors: function colors(d) { - return COLOR_SCALE(d.name); - }, - nodeFillColor: nodeFillColor, - nodeStrokeColor: nodeStrokeColor, - linkStrokeColor: linkStrokeColor, - - enableInnerArcs: true, - enableExpandOnClick: true, - enableRightClick: true, - - enableLabels: true, - getLabel: function getLabel(d) { - return d.name; - }, - - enableTooltips: true, - getTooltip: getTooltip, - getTooltipTitle: _univis2.default.getTooltipTitle, - getTooltipText: _univis2.default.getTooltipText, - enableAutoExpand: false - }; - - var settings = void 0; - - var visibleRoot = void 0, - tooltipTimer = void 0; - - var nodeId = 0, - root = void 0; - - var tree = void 0, - tooltip = void 0, - diagonal = void 0, - widthScale = void 0, - innerArc = void 0, - zoomListener = void 0, - svg = void 0; - - function init() { - settings = _extends({}, DEFAULTS, options); - _treeviewNode2.default.settings = settings; - - settings.width = settings.width - MARGIN.right - MARGIN.left; - settings.height = settings.height - MARGIN.top - MARGIN.bottom; - - if (settings.enableTooltips) { - initTooltip(); - } - - if (settings.enableInnerArcs) { - initInnerArcs(); - } - - tree = d3.layout.tree().nodeSize([2, 10]).separation(function (a, b) { - var width = nodeSize(a) + nodeSize(b), - distance = width / 2 + 4; - return a.parent === b.parent ? distance : distance + 4; - }); - - diagonal = d3.svg.diagonal().projection(function (d) { - return [d.y, d.x]; - }); - - widthScale = d3.scale.linear().range([settings.minNodeSize, settings.maxNodeSize]); - - // define the zoomListener which calls the zoom function on the "zoom" event constrained within the scaleExtents - zoomListener = d3.behavior.zoom().scaleExtent([0.1, 3]).on("zoom", function () { - svg.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")"); - }); - - svg = d3.select(element).append("svg").attr("version", "1.1").attr("xmlns", "http://www.w3.org/2000/svg").attr("viewBox", "0 0 " + (settings.width + MARGIN.right + MARGIN.left) + " " + (settings.height + MARGIN.top + MARGIN.bottom)).attr("width", settings.width + MARGIN.right + MARGIN.left).attr("height", settings.height + MARGIN.top + MARGIN.bottom).style("font-family", "'Helvetica Neue', Helvetica, Arial, sans-serif").call(zoomListener).append("g").attr("transform", "translate(" + MARGIN.left + "," + MARGIN.top + ")").append("g"); - - draw(_treeviewNode2.default.createNode(data)); - } - - function initTooltip() { - tooltip = d3.select("body").append("div").attr("id", element.id + "-tooltip").attr("class", "tip").style("position", "absolute").style("z-index", "10").style("visibility", "hidden").style("background-color", "white").style("padding", "2px").style("border", "1px solid #dddddd").style("border-radius", "3px;"); - } - - function initInnerArcs() { - var arcScale = d3.scale.linear().range([0, 2 * Math.PI]); - - innerArc = d3.svg.arc().outerRadius(nodeSize).startAngle(0).endAngle(function (d) { - return arcScale(d.data.self_count / d.data.count) || 0; - }); - } - - function draw(data) { - var _this = this; - - widthScale.domain([0, data.data.count]); - - root = data; - root.x0 = settings.height / 2; - root.y0 = 0; - - // set everything visible - root.setSelected(true); - - root.children.forEach(function (d, i) { - d.color = d3.functor(settings.colors).call(_this, d, i); - d.setRecursiveProperty("color", d.color); - }); - - if (settings.enableExpandOnClick) { - root.collapseAll(); - initialExpand(root); - } else { - root.expandAll(); - } - - update(root); - centerNode(root); - } - - function initialExpand(root) { - if (!settings.enableAutoExpand) { - root.expand(); - return; - } - - root.expand(1); - var allowedCount = root.data.count * (Number.isFinite(settings.enableAutoExpand) ? settings.enableAutoExpand : 0.8); - var pq = new _maxcountheap2.default(root.children || []); - while (allowedCount > 0 && pq.size > 0) { - var toExpand = pq.remove(); - allowedCount -= toExpand.data.count; - toExpand.expand(1); - (toExpand.children || []).forEach(function (c) { - return pq.add(c); - }); - } - } - - function update(source) { - // Compute the new tree layout. - var nodes = tree.nodes(root).reverse(), - links = tree.links(nodes); - - // Normalize for fixed-depth. - nodes.forEach(function (d) { - d.y = d.depth * settings.nodeDistance; - }); - - // Update the nodes… - var node = svg.selectAll("g.node").data(nodes, function (d) { - return d.id || (d.id = ++nodeId); - }); - - // Enter any new nodes at the parent's previous position. - var nodeEnter = node.enter().append("g").attr("class", "node").style("cursor", "pointer").attr("transform", function (d) { - return "translate(" + (source.y || 0) + "," + (source.x0 || 0) + ")"; - }).on("click", click).on("mouseover", tooltipIn).on("mouseout", tooltipOut).on("contextmenu", rightClick); - - nodeEnter.append("circle").attr("r", 1e-6).style("stroke-width", "1.5px").style("stroke", settings.nodeStrokeColor).style("fill", settings.nodeFillColor); - - if (settings.enableInnerArcs) { - nodeEnter.append("path").attr("d", innerArc).style("fill", settings.nodeStrokeColor).style("fill-opacity", 0); - } - - if (settings.enableLabels) { - nodeEnter.append("text").attr("x", function (d) { - return d.isLeaf() ? 10 : -10; - }).attr("dy", ".35em").attr("text-anchor", function (d) { - return d.isLeaf() ? "start" : "end"; - }).text(settings.getLabel).style("font", "10px sans-serif").style("fill-opacity", 1e-6); - } - - // Transition nodes to their new position. - var nodeUpdate = node.transition().duration(DURATION).attr("transform", function (d) { - return "translate(" + d.y + "," + d.x + ")"; - }); - - nodeUpdate.select("circle").attr("r", nodeSize).style("fill-opacity", function (d) { - return d._children ? 1 : 0; - }).style("stroke", settings.nodeStrokeColor).style("fill", settings.nodeFillColor); - - if (settings.enableLabels) { - nodeUpdate.select("text").style("fill-opacity", 1); - } - - if (settings.enableInnerArcs) { - nodeUpdate.select("path").duration(DURATION).attr("d", innerArc).style("fill-opacity", 0.8); - } - - // Transition exiting nodes to the parent's new position. - var nodeExit = node.exit().transition().duration(DURATION).attr("transform", function (d) { - return "translate(" + source.y + "," + source.x + ")"; - }).remove(); - - nodeExit.select("circle").attr("r", 1e-6); - - nodeExit.select("path").style("fill-opacity", 1e-6); - - nodeExit.select("text").style("fill-opacity", 1e-6); - - // Update the links… - var link = svg.selectAll("path.link").data(links, function (d) { - return d.target.id; - }); - - // Enter any new links at the parent's previous position. - link.enter().insert("path", "g").attr("class", "link").style("fill", "none").style("stroke-opacity", "0.5").style("stroke-linecap", "round").style("stroke", settings.linkStrokeColor).style("stroke-width", 1e-6).attr("d", function (d) { - var o = { - x: source.x0 || 0, - y: source.y0 || 0 - }; - return diagonal({ - source: o, - target: o - }); - }); - - // Transition links to their new position. - link.transition().duration(DURATION).attr("d", diagonal).style("stroke", settings.linkStrokeColor).style("stroke-width", function (d) { - if (d.source.selected) { - return widthScale(d.target.data.count) + "px"; - } else { - return "4px"; - } - }); - - // Transition exiting nodes to the parent's new position. - link.exit().transition().duration(DURATION).style("stroke-width", 1e-6).attr("d", function (d) { - var o = { - x: source.x, - y: source.y - }; - return diagonal({ - source: o, - target: o - }); - }).remove(); - - // Stash the old positions for transition. - nodes.forEach(function (d) { - var _ref = [d.x, d.y]; - d.x0 = _ref[0]; - d.y0 = _ref[1]; - }); - } - - function nodeSize(d) { - if (d.selected) { - return widthScale(d.data.count) / 2; - } else { - return 2; - } - } - - // Toggle children on click. - function click(d) { - if (!settings.enableExpandOnClick) { - return; - } - - // check if click is triggered by panning on a node - if (d3.event.defaultPrevented) { - return; - } - - if (d3.event.shiftKey) { - d.expandAll(); - } else if (d.children) { - d.collapse(); - } else { - d.expand(); - } - update(d); - centerNode(d); - } - - function rightClick(d) { - if (settings.enableRightClick) { - reroot(d); - } - } - - // Sets the width of the right clicked node to 100% - function reroot(d) { - if (d === visibleRoot && d !== root) { - reroot(root); - return; - } - visibleRoot = d; - - // set Selection properties - root.setSelected(false); - d.setSelected(true); - - // scale the lines - widthScale.domain([0, d.data.count]); - - d.expand(); - - // redraw - if (d3.event !== null) { - d3.event.preventDefault(); - } - update(d); - centerNode(d); - - if (settings.rerootCallback) { - settings.rerootCallback.call(null, d); - } - } - - // Center a node - function centerNode(source) { - var scale = zoomListener.scale(), - x = -source.y0, - y = -source.x0; - - x = x * scale + settings.width / 4; - y = y * scale + settings.height / 2; - svg.transition().duration(DURATION).attr("transform", "translate(" + x + "," + y + ")scale(" + scale + ")"); - zoomListener.scale(scale); - zoomListener.translate([x, y]); - } - - // tooltip functions - function tooltipIn(d, i) { - if (!settings.enableTooltips) { - return; - } - tooltip.html(settings.getTooltip(d)).style("top", d3.event.pageY - 5 + "px").style("left", d3.event.pageX + 15 + "px"); - - tooltipTimer = setTimeout(function () { - tooltip.style("visibility", "visible"); - }, 1000); - } - - function tooltipOut(d, i) { - if (!settings.enableTooltips) { - return; - } - clearTimeout(tooltipTimer); - tooltip.style("visibility", "hidden"); - } - - /** ************ Default methods ***************/ - // set fill color - function nodeFillColor(d) { - if (d.selected) { - return d._children ? d.color || "#aaa" : "#fff"; - } else { - return "#aaa"; - } - } - - // set node stroke color - function nodeStrokeColor(d) { - if (d.selected) { - return d.color || "#aaa"; - } else { - return "#aaa"; - } - } - - // set link stroke color - function linkStrokeColor(d) { - if (d.source.selected) { - return d.target.color; - } else { - return "#aaa"; - } - } - - function getTooltip(d) { - return "

" + settings.getTooltipTitle(d) + "

" + settings.getTooltipText(d) + "

"; - } - - /** ************* Public methods ***************/ - that.reset = function reset() { - zoomListener.scale(1); - reroot(root); - }; - - /** - * Sets the visualisation in full screen mode - * - * @param isFullScreen indicates if we're in full screen mode - */ - that.setFullScreen = function setFullScreen(isFullScreen) { - // the delay is because the event fires before we're in fullscreen - // so the height en width functions don't give a correct result - // without the delay - setTimeout(function () { - var _ref2 = [settings.width, settings.height], - w = _ref2[0], - h = _ref2[1]; - - if (isFullScreen) { - w = $(window).width(); - h = $(window).height() - 44; - } - $(element).children("svg").attr("width", w).attr("height", h); - }, 1000); - }; - - /** - * Get the root of the visual tree - * - * @return {TreeviewNode} The root node of the visualisation - */ - that.getRoot = function getRoot() { - return root; - }; - - /** - * Apply changes made to the tree or its data - */ - that.update = update; - - /** - * Center a node of the tree - */ - that.centerNode = centerNode; - - // initialize the object - init(); - - // return the object - return that; - } - - $.fn.treeview = function (data, options) { - return new TreeView(this.get(0), data, options); - }; - - /***/ -}, -/* 2 */ -/***/function (module, exports) { - - "use strict"; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { - function defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); - } - }return function (Constructor, protoProps, staticProps) { - if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; - }; - }(); - - function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } - } - - var Univis = function () { - function Univis() { - _classCallCheck(this, Univis); - } - - _createClass(Univis, null, [{ - key: "stringHash", - - /** - * Hash function for strings from - * http://stackoverflow.com/a/15710692/865696 - */ - value: function stringHash(s) { - return s.split("").reduce(function (a, b) { - var c = (a << 5) - a + b.charCodeAt(0); - return c & c; - }, 0); - } - - /* - * Returns the readable text color based on the brightness of a given backgroud color - */ - - }, { - key: "getReadableColorFor", - value: function getReadableColorFor(color) { - var textColor = "#000"; - try { - textColor = Univis.brightness(d3.rgb(color)) < 125 ? "#eee" : "#000"; - } catch (err) {/* go on */} - return textColor; - } - - /* - * Returns the brightness of an rgb-color - * from: http:// www.w3.org/WAI/ER/WD-AERT/#color-contrast - */ - - }, { - key: "brightness", - value: function brightness(rgb) { - return rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114; - } - }, { - key: "getTooltipTitle", - value: function getTooltipTitle(d) { - return d.name; - } - }, { - key: "getTooltipText", - value: function getTooltipText(d) { - return d.data.count + " hits"; - } - }]); - - return Univis; - }(); - - exports.default = Univis; - - /***/ -}, -/* 3 */ -/***/function (module, exports) { - - "use strict"; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { - function defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); - } - }return function (Constructor, protoProps, staticProps) { - if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; - }; - }(); - - function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } - } - - /* - * A priority qeueue that works with Nodes. - * Based on https://github.com/gkz/es-collections - */ - - /* eslint-disable require-jsdoc, no-param-reassign */ - - var comp = function comp(a, b) { - return b.data.count - a.data.count; - }; - - function heapify(data) { - for (var i = Math.floor((data.length - 2) / 2); i >= 0; i--) { - sink(data, i); - } - return data; - } - - function bubbleUp(data, index) { - var value = data[index]; - - while (index > 0) { - var parentIndex = Math.floor((index - 1) / 2); - var parent = data[parentIndex]; - if (comp(value, parent) < 0) { - data[index] = parent; - } else { - break; - } - index = parentIndex; - } - data[index] = value; - return index; - } - - function sink(data, index) { - var value = data[index]; - var size = data.length; - - while (2 * index + 1 < size) { - var targetIndex = 2 * index + 1; - if (targetIndex < size - 1 && comp(data[targetIndex + 1], data[targetIndex]) < 0) { - targetIndex++; - } - if (comp(value, data[targetIndex]) <= 0) { - break; - } - data[index] = data[targetIndex]; - index = targetIndex; - } - data[index] = value; - return index; - } - - var MaxCountHeap = function () { - function MaxCountHeap() { - var iterable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - - _classCallCheck(this, MaxCountHeap); - - this._data = heapify(Array.from(iterable)); - } - - _createClass(MaxCountHeap, [{ - key: "add", - value: function add(item) { - this._data.push(item); - bubbleUp(this._data, this.size - 1); - return this; - } - }, { - key: "peek", - value: function peek() { - return this._data[0]; - } - }, { - key: "remove", - value: function remove() { - var output = this._data[0]; - if (this.size > 1) { - this._data[0] = this._data.pop(); - sink(this._data, 0); - } else { - this._data.pop(); - } - return output; - } - }, { - key: "clear", - value: function clear() { - this._data = []; - } - }, { - key: "size", - get: function get() { - return this._data.length; - } - }]); - - return MaxCountHeap; - }(); - - exports.default = MaxCountHeap; - - /***/ -}, -/* 4 */ -/***/function (module, exports, __webpack_require__) { - - "use strict"; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { - function defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); - } - }return function (Constructor, protoProps, staticProps) { - if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; - }; - }(); - - var _node = __webpack_require__(5); - - var _node2 = _interopRequireDefault(_node); - - function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : { default: obj }; - } - - function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } - } - - function _possibleConstructorReturn(self, call) { - if (!self) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - }return call && ((typeof call === "undefined" ? "undefined" : _typeof(call)) === "object" || typeof call === "function") ? call : self; - } - - function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : _typeof(superClass))); - }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; - } - - var TreeviewNode = function (_Node) { - _inherits(TreeviewNode, _Node); - - function TreeviewNode() { - var node = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - _classCallCheck(this, TreeviewNode); - - var _this = _possibleConstructorReturn(this, (TreeviewNode.__proto__ || Object.getPrototypeOf(TreeviewNode)).call(this, node)); - - _this.settings = TreeviewNode.settings; - _this.setCount(); - return _this; - } - - _createClass(TreeviewNode, [{ - key: "setCount", - value: function setCount() { - if (this.settings.countAccessor(this)) { - this.data.count = this.settings.countAccessor(this); - } else if (this.children) { - this.data.count = this.children.reduce(function (sum, c) { - return sum + c.data.count; - }, 0); - } else { - this.data.count = 0; - } - } - }, { - key: "setSelected", - value: function setSelected(value) { - this.setRecursiveProperty("selected", value); - } - - // collapse everything - - }, { - key: "collapseAll", - value: function collapseAll() { - if (this.children && this.children.length === 0) { - this.children = null; - } - if (this.children) { - this._children = this.children; - this._children.forEach(function (c) { - c.collapseAll(); - }); - this.children = null; - } - } - - // Collapses a node - - }, { - key: "collapse", - value: function collapse() { - if (this.children) { - this._children = this.children; - this.children = null; - } - } - }, { - key: "expandAll", - value: function expandAll() { - this.expand(100); - } - - // Expands a node and its children - - }, { - key: "expand", - value: function expand() { - var i = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.settings.levelsToExpand; - - if (i > 0) { - if (this._children) { - this.children = this._children; - this._children = null; - } - if (this.children) { - this.children.forEach(function (c) { - c.expand(i - 1); - }); - } - } - } - }], [{ - key: "new", - value: function _new() { - var node = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - return new TreeviewNode(node); - } - }, { - key: "createNode", - value: function createNode(node) { - return _node2.default.createNode(node, TreeviewNode.new); - } - }]); - - return TreeviewNode; - }(_node2.default); - - exports.default = TreeviewNode; - - /***/ -}, -/* 5 */ -/***/function (module, exports) { - - "use strict"; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _extends = Object.assign || function (target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i];for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } - }return target; - }; - - var _createClass = function () { - function defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); - } - }return function (Constructor, protoProps, staticProps) { - if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; - }; - }(); - - function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } - } - - var Node = function () { - function Node() { - var node = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - _classCallCheck(this, Node); - - this.data = {}; - _extends(this, node); - } - - _createClass(Node, [{ - key: "setRecursiveProperty", - - // sets a property for a node and all its children - value: function setRecursiveProperty(property, value) { - this[property] = value; - if (this.children) { - this.children.forEach(function (c) { - c.setRecursiveProperty(property, value); - }); - } else if (this._children) { - this._children.forEach(function (c) { - c.setRecursiveProperty(property, value); - }); - } - } - - // Returns true if a node is a leaf - - }, { - key: "isLeaf", - value: function isLeaf() { - return !this.children && !this._children || this.children && this.children.length === 0 || this._children && this._children.length === 0; - } - }, { - key: "getHeight", - value: function getHeight() { - if (this._height === undefined) { - if (this.isLeaf()) { - this._height = 0; - } else { - this._height = d3.max(this.children, function (c) { - return c.getHeight(); - }) + 1; - } - } - return this._height; - } - }, { - key: "getDepth", - value: function getDepth() { - if (this._depth === undefined) { - if (this.parent === undefined) { - this._depth = 0; - } else { - this._depth = this.parent.getDepth() + 1; - } - } - return this._depth; - } - }], [{ - key: "new", - value: function _new() { - var node = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - return new Node(node); - } - }, { - key: "createNode", - value: function createNode(node) { - var construct = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Node.new; - - if (node.children) { - node.children = node.children.map(function (n) { - return Node.createNode(n, construct); - }); - } - return construct.call(null, node); - } - }]); - - return Node; - }(); - - exports.default = Node; - - /***/ -}, -/* 6 */ -/***/function (module, exports, __webpack_require__) { - - "use strict"; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _extends = Object.assign || function (target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i];for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } - }return target; - }; /** - * Interactive treemap - */ - - exports.default = TreeMap; - - var _univis = __webpack_require__(2); - - var _univis2 = _interopRequireDefault(_univis); - - var _treemapNode = __webpack_require__(7); - - var _treemapNode2 = _interopRequireDefault(_treemapNode); - - function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : { default: obj }; - } - - function TreeMap(element, data) { - var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - - var that = {}; - - var MARGIN = { - top: 0, - right: 0, - bottom: 0, - left: 0 - }, - DEFAULTS = { - height: 300, - width: 600, - - className: "unipept-treemap", - levels: undefined, - getLevel: function getLevel(d) { - return d.getDepth(); - }, - - countAccessor: function countAccessor(d) { - return d.data.self_count; - }, - rerootCallback: undefined, - - getBreadcrumbTooltip: function getBreadcrumbTooltip(d) { - return d.name; - }, - colorRoot: "#104B7D", - colorLeaf: "#fdffcc", - colorBreadcrumbs: "#FF8F00", - - labelHeight: 10, - getLabel: function getLabel(d) { - return d.name; - }, - - enableTooltips: true, - getTooltip: getTooltip, - getTooltipTitle: _univis2.default.getTooltipTitle, - getTooltipText: _univis2.default.getTooltipText - }; - - var settings = void 0; - - var root = void 0, - nodeId = 0, - current = void 0, - treemapLayout = void 0, - breadcrumbs = void 0, - treemap = void 0, - tooltip = void 0, - colorScale = void 0; - - /** - * Initializes Treemap - */ - function init() { - settings = _extends({}, DEFAULTS, options); - - root = _treemapNode2.default.createNode(data); - - settings.width = settings.width - MARGIN.right - MARGIN.left; - settings.height = settings.height - MARGIN.top - MARGIN.bottom; - - settings.levels = settings.levels || root.getHeight(); - - if (settings.enableTooltips) { - initTooltip(); - } - - initCSS(); - - // setup the visualisation - draw(root); - reroot(root, false); - } - - function initTooltip() { - tooltip = d3.select("body").append("div").attr("id", element.id + "-tooltip").attr("class", "tip").style("position", "absolute").style("z-index", "10").style("visibility", "hidden").style("background-color", "white").style("padding", "2px").style("border", "1px solid #dddddd").style("border-radius", "3px;"); - } - - function initCSS() { - var elementClass = settings.className; - $(element).addClass(elementClass); - $("