From f13fed78dd60c633915ee5c2db2063dc4d0bd5e2 Mon Sep 17 00:00:00 2001 From: Susie Lu Date: Thu, 9 Mar 2017 09:38:26 -0800 Subject: [PATCH] fix build for rollup --- .gitignore | 3 +- indexRollup.js | 3268 ++++++++++++++++++++-------------------- indexRollup.js.map | 2 +- indexRollup.mjs | 1909 ----------------------- indexRollup.mjs.map | 1 - indexRollupNext.js | 1852 +++++++++++++++++++++++ indexRollupNext.js.map | 1 + package.json | 10 +- rollup.config.js | 21 +- src/Types-d3.js | 1 - 10 files changed, 3476 insertions(+), 3592 deletions(-) delete mode 100644 indexRollup.mjs delete mode 100644 indexRollup.mjs.map create mode 100644 indexRollupNext.js create mode 100644 indexRollupNext.js.map diff --git a/.gitignore b/.gitignore index 8b1fb68..3fe9c46 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ bower_components npm .vscode gifs -*.psd \ No newline at end of file +*.psd +*.zip \ No newline at end of file diff --git a/indexRollup.js b/indexRollup.js index 5817c04..18cda87 100644 --- a/indexRollup.js +++ b/indexRollup.js @@ -1,1940 +1,1868 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-selection'), require('d3-drag'), require('d3-shape'), require('d3-dispatch')) : - typeof define === 'function' && define.amd ? define(['exports', 'd3-selection', 'd3-drag', 'd3-shape', 'd3-dispatch'], factory) : - (factory((global.indexRollup = global.indexRollup || {}),global.d3Selection,global.d3Drag,global.d3Shape,global.d3Dispatch)); -}(this, function (exports,d3Selection,d3Drag,d3Shape,d3Dispatch) { 'use strict'; - - var asyncGenerator = function () { - function AwaitValue(value) { - this.value = value; - } - - function AsyncGenerator(gen) { - var front, back; - - function send(key, arg) { - return new Promise(function (resolve, reject) { - var request = { - key: key, - arg: arg, - resolve: resolve, - reject: reject, - next: null - }; - - if (back) { - back = back.next = request; - } else { - front = back = request; - resume(key, arg); - } - }); - } + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-selection'), require('d3-drag'), require('d3-shape'), require('d3-dispatch')) : + typeof define === 'function' && define.amd ? define(['exports', 'd3-selection', 'd3-drag', 'd3-shape', 'd3-dispatch'], factory) : + (factory((global.d3 = global.d3 || {}),global.d3,global.d3,global.d3,global.d3)); +}(this, (function (exports,d3Selection,d3Drag,d3Shape,d3Dispatch) { 'use strict'; + +var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +}; + +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); + } + } - function resume(key, arg) { - try { - var result = gen[key](arg); - var value = result.value; + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; +}(); - if (value instanceof AwaitValue) { - Promise.resolve(value.value).then(function (arg) { - resume("next", arg); - }, function (arg) { - resume("throw", arg); - }); - } else { - settle(result.done ? "return" : "normal", result.value); - } - } catch (err) { - settle("throw", err); - } - } - function settle(type, value) { - switch (type) { - case "return": - front.resolve({ - value: value, - done: true - }); - break; - case "throw": - front.reject(value); - break; - default: - front.resolve({ - value: value, - done: false - }); - break; - } - front = front.next; - if (front) { - resume(front.key, front.arg); - } else { - back = null; - } - } - this._invoke = send; +var _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; - if (typeof gen.return !== "function") { - this.return = undefined; + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; } } + } - if (typeof Symbol === "function" && Symbol.asyncIterator) { - AsyncGenerator.prototype[Symbol.asyncIterator] = function () { - return this; - }; - } - - AsyncGenerator.prototype.next = function (arg) { - return this._invoke("next", arg); - }; - - AsyncGenerator.prototype.throw = function (arg) { - return this._invoke("throw", arg); - }; + return target; +}; - AsyncGenerator.prototype.return = function (arg) { - return this._invoke("return", arg); - }; +var get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); - return { - wrap: function (fn) { - return function () { - return new AsyncGenerator(fn.apply(this, arguments)); - }; - }, - await: function (value) { - return new AwaitValue(value); - } - }; - }(); + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); - var classCallCheck = function (instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); } - }; + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; - 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); - } + if (getter === undefined) { + return undefined; } - return function (Constructor, protoProps, staticProps) { - if (protoProps) defineProperties(Constructor.prototype, protoProps); - if (staticProps) defineProperties(Constructor, staticProps); - return Constructor; - }; - }(); - - 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 getter.call(receiver); + } +}; + +var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + 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; +}; - return target; - }; - var get = function get(object, property, receiver) { - if (object === null) object = Function.prototype; - var desc = Object.getOwnPropertyDescriptor(object, property); - if (desc === undefined) { - var parent = Object.getPrototypeOf(object); - if (parent === null) { - return undefined; - } else { - return get(parent, property, receiver); - } - } else if ("value" in desc) { - return desc.value; - } else { - var getter = desc.get; - if (getter === undefined) { - return undefined; - } - return getter.call(receiver); - } - }; - var inherits = function (subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function, not " + 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 possibleConstructorReturn = function (self, call) { - if (!self) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - return call && (typeof call === "object" || typeof call === "function") ? call : self; - }; - var toConsumableArray = function (arr) { - if (Array.isArray(arr)) { - for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; +var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } - return arr2; - } else { - return Array.from(arr); - } - }; + return call && (typeof call === "object" || typeof call === "function") ? call : self; +}; - var Annotation = function () { - function Annotation(_ref) { - var _ref$x = _ref.x, - x = _ref$x === undefined ? 0 : _ref$x, - _ref$y = _ref.y, - y = _ref$y === undefined ? 0 : _ref$y, - _ref$dy = _ref.dy, - dy = _ref$dy === undefined ? 0 : _ref$dy, - _ref$dx = _ref.dx, - dx = _ref$dx === undefined ? 0 : _ref$dx, - data = _ref.data, - type = _ref.type, - subject = _ref.subject, - connector = _ref.connector, - note = _ref.note, - disable = _ref.disable, - id = _ref.id, - className = _ref.className; - classCallCheck(this, Annotation); - this._dx = dx; - this._dy = dy; - this._x = x; - this._y = y; - this.id = id; - this._className = className || ''; - this.type = type || ''; - this.data = data; - this.note = note || {}; - this.connector = connector || {}; - this.subject = subject || {}; - this.disable = disable || []; - } - createClass(Annotation, [{ - key: 'updatePosition', - value: function updatePosition() { - if (this.type.setPosition) { - this.type.setPosition(); - if (this.type.subject.selectAll(':not(.handle)').nodes().length !== 0) { - this.type.redrawSubject(); - } - } - } - }, { - key: 'updateOffset', - value: function updateOffset() { - if (this.type.setOffset) { - this.type.setOffset(); - if (this.type.connector.selectAll(':not(.handle)').nodes().length !== 0) { - this.type.redrawConnector(); - } - this.type.redrawNote(); - } - } - }, { - key: 'className', - get: function get() { - return this._className; - }, - set: function set(className) { - this._className = className; - if (this.type.setClassName) this.type.setClassName(); - } - }, { - key: 'x', - get: function get() { - return this._x; - }, - set: function set(x) { - this._x = x; - this.updatePosition(); - } - }, { - key: 'y', - get: function get() { - return this._y; - }, - set: function set(y) { - this._y = y; - this.updatePosition(); - } - }, { - key: 'dx', - get: function get() { - return this._dx; - }, - set: function set(dx) { - this._dx = dx; - this.updateOffset(); - } - }, { - key: 'dy', - get: function get() { - return this._dy; - }, - set: function set(dy) { - this._dy = dy; - this.updateOffset(); - } - }, { - key: 'offset', - get: function get() { - return { x: this._dx, y: this._dy }; - }, - set: function set(_ref2) { - var x = _ref2.x, - y = _ref2.y; - - this._dx = x; - this._dy = y; - this.updateOffset(); - } - }, { - key: 'position', - get: function get() { - return { x: this._x, y: this._y }; - }, - set: function set(_ref3) { - var x = _ref3.x, - y = _ref3.y; - - this._x = x; - this._y = y; - this.updatePosition(); - } - }, { - key: 'translation', - get: function get() { - return { - x: this._x + this._dx, - y: this._y + this._dy - }; - } - }, { - key: 'json', - get: function get() { - var json = { - x: this._x, - y: this._y, - dx: this._dx, - dy: this._dy - }; - - if (this.data && Object.keys(this.data).length > 0) json.data = this.data; - if (this.type) json.type = this.type; - if (this._className) json.className = this._className; - - if (Object.keys(this.connector).length > 0) json.connector = this.connector; - if (Object.keys(this.subject).length > 0) json.subject = this.subject; - if (Object.keys(this.note).length > 0) json.note = this.note; - return json; - } - }]); - return Annotation; - }(); - - var AnnotationCollection = function () { - function AnnotationCollection(_ref) { - var annotations = _ref.annotations, - accessors = _ref.accessors, - accessorsInverse = _ref.accessorsInverse; - classCallCheck(this, AnnotationCollection); - - this.accessors = accessors; - this.accessorsInverse = accessorsInverse; - this.annotations = annotations; - } - - createClass(AnnotationCollection, [{ - key: "clearTypes", - value: function clearTypes(newSettings) { - this.annotations.forEach(function (d) { - d.type = undefined; - d.subject = newSettings && newSettings.subject || d.subject; - d.connector = newSettings && newSettings.connector || d.connector; - d.note = newSettings && newSettings.note || d.note; - }); - } - }, { - key: "setPositionWithAccessors", - value: function setPositionWithAccessors() { - var _this = this; - this.annotations.forEach(function (d) { - d.type.setPositionWithAccessors(_this.accessors); - }); - } - }, { - key: "editMode", - value: function editMode(_editMode) { - this.annotations.forEach(function (a) { - if (a.type) { - a.type.editMode = _editMode; - a.type.updateEditMode(); - } - }); - } - }, { - key: "updateDisable", - value: function updateDisable(disable) { - this.annotations.forEach(function (a) { - a.disable = disable; - if (a.type) { - disable.forEach(function (d) { - if (a.type[d]) { - a.type[d].remove && a.type[d].remove(); - a.type[d] = undefined; - } - }); - } - }); - } - }, { - key: "updateTextWrap", - value: function updateTextWrap(textWrap) { - this.annotations.forEach(function (a) { - if (a.type && a.type.updateTextWrap) { - a.type.updateTextWrap(textWrap); - } - }); - } - }, { - key: "updateNotePadding", - value: function updateNotePadding(notePadding) { - this.annotations.forEach(function (a) { - if (a.type) { - a.type.notePadding = notePadding; - } - }); - } - }, { - key: "json", - get: function get() { - var _this2 = this; - - return this.annotations.map(function (a) { - var json = a.json; - if (_this2.accessorsInverse && a.data) { - json.data = {}; - Object.keys(_this2.accessorsInverse).forEach(function (k) { - json.data[k] = _this2.accessorsInverse[k]({ x: a.x, y: a.y }); - - //TODO make this feasible to map back to data for other types of subjects - }); - } - return json; - }); - } - }, { - key: "noteNodes", - get: function get() { - return this.annotations.map(function (a) { - return _extends({}, a.type.getNoteBBoxOffset(), { positionX: a.x, positionY: a.y }); - }); - } - //TODO: come back and rethink if a.x and a.y are applicable in all situations - // get connectorNodes() { - // return this.annotations.map(a => ({ ...a.type.getConnectorBBox(), startX: a.x, startY: a.y})) - // } - // get subjectNodes() { - // return this.annotations.map(a => ({ ...a.type.getSubjectBBox(), startX: a.x, startY: a.y})) - // } - // get annotationNodes() { - // return this.annotations.map(a => ({ ...a.type.getAnnotationBBox(), startX: a.x, startY: a.y})) - // } - }]); - return AnnotationCollection; - }(); - var pointHandle = function pointHandle(_ref) { - var _ref$cx = _ref.cx, - cx = _ref$cx === undefined ? 0 : _ref$cx, - _ref$cy = _ref.cy, - cy = _ref$cy === undefined ? 0 : _ref$cy; - return { move: { x: cx, y: cy } }; - }; - var circleHandles = function circleHandles(_ref2) { - var _ref2$cx = _ref2.cx, - cx = _ref2$cx === undefined ? 0 : _ref2$cx, - _ref2$cy = _ref2.cy, - cy = _ref2$cy === undefined ? 0 : _ref2$cy, - r1 = _ref2.r1, - r2 = _ref2.r2, - padding = _ref2.padding; - var h = { move: { x: cx, y: cy } }; +var toConsumableArray = function (arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; - if (r1 !== undefined) { - h.r1 = { x: cx + r1 / Math.sqrt(2), y: cy + r1 / Math.sqrt(2) }; - } + return arr2; + } else { + return Array.from(arr); + } +}; - if (r2 !== undefined) { - h.r2 = { x: cx + r2 / Math.sqrt(2), y: cy + r2 / Math.sqrt(2) }; - } +var Annotation = function () { + function Annotation(_ref) { + var _ref$x = _ref.x, + x = _ref$x === undefined ? 0 : _ref$x, + _ref$y = _ref.y, + y = _ref$y === undefined ? 0 : _ref$y, + _ref$dy = _ref.dy, + dy = _ref$dy === undefined ? 0 : _ref$dy, + _ref$dx = _ref.dx, + dx = _ref$dx === undefined ? 0 : _ref$dx, + data = _ref.data, + type = _ref.type, + subject = _ref.subject, + connector = _ref.connector, + note = _ref.note, + disable = _ref.disable, + id = _ref.id, + className = _ref.className; + classCallCheck(this, Annotation); - if (padding !== undefined) { - h.padding = { x: cx + r1 + padding, y: cy }; - } - return h; - }; + this._dx = dx; + this._dy = dy; + this._x = x; + this._y = y; + this.id = id; + this._className = className || ''; - //arc handles - var addHandles = function addHandles(_ref5) { - var group = _ref5.group, - handles = _ref5.handles, - _ref5$r = _ref5.r, - r = _ref5$r === undefined ? 10 : _ref5$r; - - //give it a group and x,y to draw handles - //then give it instructions on what the handles change - var h = group.selectAll('circle.handle').data(handles); - - h.enter().append('circle').attr('class', 'handle').call(d3Drag.drag().container(d3Selection.select('g.annotations').node()).on('start', function (d) { - return d.start && d.start(d); - }).on('drag', function (d) { - return d.drag && d.drag(d); - }).on('end', function (d) { - return d.end && d.end(d); - })); - - group.selectAll('circle.handle').attr('cx', function (d) { - return d.x; - }).attr('cy', function (d) { - return d.y; - }).attr('r', function (d) { - return d.r || r; - }).attr('class', function (d) { - return 'handle ' + (d.className || ''); - }); + this.type = type || ''; + this.data = data; - h.exit().remove(); - }; + this.note = note || {}; + this.connector = connector || {}; + this.subject = subject || {}; - var leftRightDynamic = function leftRightDynamic(align, y) { - if (align == "dynamic" || align == "left" || align == "right") { - if (y < 0) { - align = "top"; - } else { - align = "bottom"; - } - } - return align; - }; + this.disable = disable || []; + } - var topBottomDynamic = function topBottomDynamic(align, x) { - if (align == "dynamic" || align == "top" || align == "bottom") { - if (x < 0) { - align = "right"; - } else { - align = "left"; + createClass(Annotation, [{ + key: 'updatePosition', + value: function updatePosition() { + if (this.type.setPosition) { + this.type.setPosition(); + if (this.type.subject.selectAll(':not(.handle)').nodes().length !== 0) { + this.type.redrawSubject(); + } } } - return align; - }; - - var noteAlignment = (function (_ref) { - var padding = _ref.padding, - bbox = _ref.bbox, - align = _ref.align, - orientation = _ref.orientation, - offset = _ref.offset; - - var x = -bbox.x; - var y = -bbox.y; - - if (orientation === "topBottom") { - align = topBottomDynamic(align, offset.x); - if (offset.y < 0) { - y -= bbox.height + padding; - } else { - y += padding; - } - - if (align === "middle") { - x -= bbox.width / 2; - } else if (align === "right") { - x -= bbox.width; - } - } else if (orientation === "leftRight") { - align = leftRightDynamic(align, offset.y); - if (offset.x < 0) { - x -= bbox.width + padding; - } else { - x += padding; - } + }, { + key: 'updateOffset', + value: function updateOffset() { + if (this.type.setOffset) { + this.type.setOffset(); + + if (this.type.connector.selectAll(':not(.handle)').nodes().length !== 0) { + this.type.redrawConnector(); + } - if (align === "middle") { - y -= bbox.height / 2; - } else if (align === "top") { - y -= bbox.height; + this.type.redrawNote(); } } + }, { + key: 'className', + get: function get$$1() { + return this._className; + }, + set: function set$$1(className) { + this._className = className; + if (this.type.setClassName) this.type.setClassName(); + } + }, { + key: 'x', + get: function get$$1() { + return this._x; + }, + set: function set$$1(x) { + this._x = x; + this.updatePosition(); + } + }, { + key: 'y', + get: function get$$1() { + return this._y; + }, + set: function set$$1(y) { + this._y = y; + this.updatePosition(); + } + }, { + key: 'dx', + get: function get$$1() { + return this._dx; + }, + set: function set$$1(dx) { + this._dx = dx; + this.updateOffset(); + } + }, { + key: 'dy', + get: function get$$1() { + return this._dy; + }, + set: function set$$1(dy) { + this._dy = dy; + this.updateOffset(); + } + }, { + key: 'offset', + get: function get$$1() { + return { x: this._dx, y: this._dy }; + }, + set: function set$$1(_ref2) { + var x = _ref2.x, + y = _ref2.y; + + this._dx = x; + this._dy = y; + this.updateOffset(); + } + }, { + key: 'position', + get: function get$$1() { + return { x: this._x, y: this._y }; + }, + set: function set$$1(_ref3) { + var x = _ref3.x, + y = _ref3.y; - return { x: x, y: y }; - }); + this._x = x; + this._y = y; + this.updatePosition(); + } + }, { + key: 'translation', + get: function get$$1() { + return { + x: this._x + this._dx, + y: this._y + this._dy + }; + } + }, { + key: 'json', + get: function get$$1() { + var json = { + x: this._x, + y: this._y, + dx: this._dx, + dy: this._dy + }; - var lineBuilder = function lineBuilder(_ref) { - var data = _ref.data, - _ref$curve = _ref.curve, - curve = _ref$curve === undefined ? d3Shape.curveLinear : _ref$curve, - canvasContext = _ref.canvasContext, - className = _ref.className; + if (this.data && Object.keys(this.data).length > 0) json.data = this.data; + if (this.type) json.type = this.type; + if (this._className) json.className = this._className; - var lineGen = d3Shape.line().curve(curve); + if (Object.keys(this.connector).length > 0) json.connector = this.connector; + if (Object.keys(this.subject).length > 0) json.subject = this.subject; + if (Object.keys(this.note).length > 0) json.note = this.note; - var builder = { - type: 'path', - className: className, - data: data - }; + return json; + } + }]); + return Annotation; +}(); + +var AnnotationCollection = function () { + function AnnotationCollection(_ref) { + var annotations = _ref.annotations, + accessors = _ref.accessors, + accessorsInverse = _ref.accessorsInverse; + classCallCheck(this, AnnotationCollection); + + this.accessors = accessors; + this.accessorsInverse = accessorsInverse; + this.annotations = annotations; + } + + createClass(AnnotationCollection, [{ + key: "clearTypes", + value: function clearTypes(newSettings) { + this.annotations.forEach(function (d) { + d.type = undefined; + d.subject = newSettings && newSettings.subject || d.subject; + d.connector = newSettings && newSettings.connector || d.connector; + d.note = newSettings && newSettings.note || d.note; + }); + } + }, { + key: "setPositionWithAccessors", + value: function setPositionWithAccessors() { + var _this = this; - if (canvasContext) { - lineGen.context(canvasContext); - builder.pathMethods = lineGen; - } else { - builder.attrs = { - d: lineGen(data) - }; + this.annotations.forEach(function (d) { + d.type.setPositionWithAccessors(_this.accessors); + }); + } + }, { + key: "editMode", + value: function editMode(_editMode) { + this.annotations.forEach(function (a) { + if (a.type) { + a.type.editMode = _editMode; + a.type.updateEditMode(); + } + }); + } + }, { + key: "updateDisable", + value: function updateDisable(disable) { + this.annotations.forEach(function (a) { + a.disable = disable; + if (a.type) { + disable.forEach(function (d) { + if (a.type[d]) { + a.type[d].remove && a.type[d].remove(); + a.type[d] = undefined; + } + }); + } + }); + } + }, { + key: "updateTextWrap", + value: function updateTextWrap(textWrap) { + this.annotations.forEach(function (a) { + if (a.type && a.type.updateTextWrap) { + a.type.updateTextWrap(textWrap); + } + }); + } + }, { + key: "updateNotePadding", + value: function updateNotePadding(notePadding) { + this.annotations.forEach(function (a) { + if (a.type) { + a.type.notePadding = notePadding; + } + }); + } + }, { + key: "json", + get: function get$$1() { + var _this2 = this; + + return this.annotations.map(function (a) { + var json = a.json; + if (_this2.accessorsInverse && a.data) { + json.data = {}; + Object.keys(_this2.accessorsInverse).forEach(function (k) { + json.data[k] = _this2.accessorsInverse[k]({ x: a.x, y: a.y }); + + //TODO make this feasible to map back to data for other types of subjects + }); + } + return json; + }); + } + }, { + key: "noteNodes", + get: function get$$1() { + return this.annotations.map(function (a) { + return _extends({}, a.type.getNoteBBoxOffset(), { positionX: a.x, positionY: a.y }); + }); } - return builder; - }; + //TODO: come back and rethink if a.x and a.y are applicable in all situations + // get connectorNodes() { + // return this.annotations.map(a => ({ ...a.type.getConnectorBBox(), startX: a.x, startY: a.y})) + // } - var arcBuilder = function arcBuilder(_ref2) { - var data = _ref2.data, - canvasContext = _ref2.canvasContext, - className = _ref2.className; + // get subjectNodes() { + // return this.annotations.map(a => ({ ...a.type.getSubjectBBox(), startX: a.x, startY: a.y})) + // } + // get annotationNodes() { + // return this.annotations.map(a => ({ ...a.type.getAnnotationBBox(), startX: a.x, startY: a.y})) + // } - var builder = { - type: 'path', - className: className, - data: data - }; + }]); + return AnnotationCollection; +}(); - var arcShape = d3Shape.arc().innerRadius(data.innerRadius || 0).outerRadius(data.outerRadius || data.radius || 2).startAngle(data.startAngle || 0).endAngle(data.endAngle || 2 * Math.PI); +var pointHandle = function pointHandle(_ref) { + var _ref$cx = _ref.cx, + cx = _ref$cx === undefined ? 0 : _ref$cx, + _ref$cy = _ref.cy, + cy = _ref$cy === undefined ? 0 : _ref$cy; - if (canvasContext) { - arcShape.context(canvasContext); - builder.pathMethods = lineGen; - } else { + return { move: { x: cx, y: cy } }; +}; - builder.attrs = { - d: arcShape() - }; - } +var circleHandles = function circleHandles(_ref2) { + var _ref2$cx = _ref2.cx, + cx = _ref2$cx === undefined ? 0 : _ref2$cx, + _ref2$cy = _ref2.cy, + cy = _ref2$cy === undefined ? 0 : _ref2$cy, + r1 = _ref2.r1, + r2 = _ref2.r2, + padding = _ref2.padding; - return builder; - }; + var h = { move: { x: cx, y: cy } }; - var noteVertical = (function (_ref) { - var align = _ref.align, - _ref$x = _ref.x, - x = _ref$x === undefined ? 0 : _ref$x, - _ref$y = _ref.y, - y = _ref$y === undefined ? 0 : _ref$y, - bbox = _ref.bbox, - offset = _ref.offset, - padding = _ref.padding; + if (r1 !== undefined) { + h.r1 = { x: cx + r1 / Math.sqrt(2), y: cy + r1 / Math.sqrt(2) }; + } - align = leftRightDynamic(align, offset.y); + if (r2 !== undefined) { + h.r2 = { x: cx + r2 / Math.sqrt(2), y: cy + r2 / Math.sqrt(2) }; + } - if (align == "top") { - y -= bbox.height; - } else if (align == "middle") { - y -= bbox.height / 2; - } + if (padding !== undefined) { + h.padding = { x: cx + r1 + padding, y: cy }; + } - var data = [[x, y], [x, y + bbox.height]]; - return { components: [lineBuilder({ data: data, className: "note-line" })] }; - }); + return h; +}; - var noteHorizontal = (function (_ref) { - var align = _ref.align, - _ref$x = _ref.x, - x = _ref$x === undefined ? 0 : _ref$x, - _ref$y = _ref.y, - y = _ref$y === undefined ? 0 : _ref$y, - offset = _ref.offset, - bbox = _ref.bbox, - padding = _ref.padding; - align = topBottomDynamic(align, offset.x); - if (align == "right") { - x -= bbox.width; - } else if (align == "middle") { - x -= bbox.width / 2; - } - var data = [[x, y], [x + bbox.width, y]]; - return { components: [lineBuilder({ data: data, className: "note-line" })] }; - }); - var lineSetup = function lineSetup(_ref) { - var type = _ref.type, - subjectType = _ref.subjectType; +//arc handles +var addHandles = function addHandles(_ref5) { + var group = _ref5.group, + handles = _ref5.handles, + _ref5$r = _ref5.r, + r = _ref5$r === undefined ? 10 : _ref5$r; - var annotation = type.annotation; - var offset = annotation.position; + //give it a group and x,y to draw handles + //then give it instructions on what the handles change + var h = group.selectAll('circle.handle').data(handles); - var x1 = annotation.x - offset.x, - x2 = x1 + annotation.dx, - y1 = annotation.y - offset.y, - y2 = y1 + annotation.dy; + h.enter().append('circle').attr('class', 'handle').call(d3Drag.drag().container(d3Selection.select('g.annotations').node()).on('start', function (d) { + return d.start && d.start(d); + }).on('drag', function (d) { + return d.drag && d.drag(d); + }).on('end', function (d) { + return d.end && d.end(d); + })); - var subjectData = annotation.subject; + group.selectAll('circle.handle').attr('cx', function (d) { + return d.x; + }).attr('cy', function (d) { + return d.y; + }).attr('r', function (d) { + return d.r || r; + }).attr('class', function (d) { + return 'handle ' + (d.className || ''); + }); - if (subjectType == "circle" && (subjectData.outerRadius || subjectData.radius)) { - var h = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); - var angle = Math.asin(-y2 / h); - var r = subjectData.outerRadius || subjectData.radius + (subjectData.radiusPadding || 0); + h.exit().remove(); +}; - x1 = Math.abs(Math.cos(angle) * r) * (x2 < 0 ? -1 : 1); - y1 = Math.abs(Math.sin(angle) * r) * (y2 < 0 ? -1 : 1); +var leftRightDynamic = function leftRightDynamic(align, y) { + if (align == "dynamic" || align == "left" || align == "right") { + if (y < 0) { + align = "top"; + } else { + align = "bottom"; + } + } + return align; +}; + +var topBottomDynamic = function topBottomDynamic(align, x) { + if (align == "dynamic" || align == "top" || align == "bottom") { + if (x < 0) { + align = "right"; + } else { + align = "left"; } + } + return align; +}; - if (subjectType == "rect") { - var width = subjectData.width, - height = subjectData.height; +var noteAlignment = (function (_ref) { + var padding = _ref.padding, + bbox = _ref.bbox, + align = _ref.align, + orientation = _ref.orientation, + offset = _ref.offset; + var x = -bbox.x; + var y = -bbox.y; - if (width > 0 && annotation.dx > 0 || width < 0 && annotation.dx < 0) { - if (Math.abs(width) > Math.abs(annotation.dx)) x1 = width / 2;else x1 = width; - } - if (height > 0 && annotation.dy > 0 || height < 0 && annotation.dy < 0) { - if (Math.abs(height) > Math.abs(annotation.dy)) y1 = height / 2;else y1 = height; - } - if (x1 == width / 2 && y1 == height / 2) { - x1 = x2;y1 = y2; - } + if (orientation === "topBottom") { + align = topBottomDynamic(align, offset.x); + if (offset.y < 0) { + y -= bbox.height + padding; + } else { + y += padding; } - return [[x1, y1], [x2, y2]]; - }; - - var connectorLine = (function (connectorData) { - var data = lineSetup(connectorData); - return { components: [lineBuilder({ data: data, className: "connector" })] }; - }); + if (align === "middle") { + x -= bbox.width / 2; + } else if (align === "right") { + x -= bbox.width; + } + } else if (orientation === "leftRight") { + align = leftRightDynamic(align, offset.y); + if (offset.x < 0) { + x -= bbox.width + padding; + } else { + x += padding; + } - var connectorElbow = (function (_ref) { - var type = _ref.type, - subjectType = _ref.subjectType; + if (align === "middle") { + y -= bbox.height / 2; + } else if (align === "top") { + y -= bbox.height; + } + } + return { x: x, y: y }; +}); - var annotation = type.annotation; - var offset = annotation.position; +var lineBuilder = function lineBuilder(_ref) { + var data = _ref.data, + _ref$curve = _ref.curve, + curve = _ref$curve === undefined ? d3Shape.curveLinear : _ref$curve, + canvasContext = _ref.canvasContext, + className = _ref.className; - var x1 = annotation.x - offset.x, - x2 = x1 + annotation.dx, - y1 = annotation.y - offset.y, - y2 = y1 + annotation.dy; + var lineGen = d3Shape.line().curve(curve); - var subjectData = annotation.subject; + var builder = { + type: 'path', + className: className, + data: data + }; - if (subjectType == "rect") { - var width = subjectData.width, - height = subjectData.height; + if (canvasContext) { + lineGen.context(canvasContext); + builder.pathMethods = lineGen; + } else { + builder.attrs = { + d: lineGen(data) + }; + } + return builder; +}; - if (width > 0 && annotation.dx > 0 || width < 0 && annotation.dx < 0) { - if (Math.abs(width) > Math.abs(annotation.dx)) x1 = width / 2;else x1 = width; - } - if (height > 0 && annotation.dy > 0 || height < 0 && annotation.dy < 0) { - if (Math.abs(height) > Math.abs(annotation.dy)) y1 = height / 2;else y1 = height; - } - if (x1 == width / 2 && y1 == height / 2) { - x1 = x2;y1 = y2; - } - } +var arcBuilder = function arcBuilder(_ref2) { + var data = _ref2.data, + canvasContext = _ref2.canvasContext, + className = _ref2.className; - var data = [[x1, y1], [x2, y2]]; - var diffY = y2 - y1; - var diffX = x2 - x1; - var xe = x2; - var ye = y2; - var opposite = y2 < y1 && x2 > x1 || x2 < x1 && y2 > y1 ? -1 : 1; + var builder = { + type: 'path', + className: className, + data: data + }; - if (Math.abs(diffX) < Math.abs(diffY)) { - xe = x2; - ye = y1 + diffX * opposite; - } else { - ye = y2; - xe = x1 + diffY * opposite; - } - - if (subjectType == "circle" && (subjectData.outerRadius || subjectData.radius)) { - var r = (subjectData.outerRadius || subjectData.radius) + (subjectData.radiusPadding || 0); - var length = r / Math.sqrt(2); - - if (Math.abs(diffX) > length && Math.abs(diffY) > length) { - x1 = length * (x2 < 0 ? -1 : 1); - y1 = length * (y2 < 0 ? -1 : 1); - data = [[x1, y1], [xe, ye], [x2, y2]]; - } else if (Math.abs(diffX) > Math.abs(diffY)) { - var angle = Math.asin(-y2 / r); - x1 = Math.abs(Math.cos(angle) * r) * (x2 < 0 ? -1 : 1); - data = [[x1, y2], [x2, y2]]; - } else { - var _angle = Math.acos(x2 / r); - y1 = Math.abs(Math.sin(_angle) * r) * (y2 < 0 ? -1 : 1); - data = [[x2, y1], [x2, y2]]; - } - } else { - data = [[x1, y1], [xe, ye], [x2, y2]]; - } + var arcShape = d3Shape.arc().innerRadius(data.innerRadius || 0).outerRadius(data.outerRadius || data.radius || 2).startAngle(data.startAngle || 0).endAngle(data.endAngle || 2 * Math.PI); - return { components: [lineBuilder({ data: data, className: "connector" })] }; - }); + if (canvasContext) { + arcShape.context(canvasContext); + builder.pathMethods = lineGen; + } else { - var connectorCurve = (function (_ref) { - var type = _ref.type, - connectorData = _ref.connectorData, - subjectType = _ref.subjectType; + builder.attrs = { + d: arcShape() + }; + } + + return builder; +}; + +var noteVertical = (function (_ref) { + var align = _ref.align, + _ref$x = _ref.x, + x = _ref$x === undefined ? 0 : _ref$x, + _ref$y = _ref.y, + y = _ref$y === undefined ? 0 : _ref$y, + bbox = _ref.bbox, + offset = _ref.offset, + padding = _ref.padding; + + align = leftRightDynamic(align, offset.y); + + if (align == "top") { + y -= bbox.height; + } else if (align == "middle") { + y -= bbox.height / 2; + } + + var data = [[x, y], [x, y + bbox.height]]; + return { components: [lineBuilder({ data: data, className: "note-line" })] }; +}); + +var noteHorizontal = (function (_ref) { + var align = _ref.align, + _ref$x = _ref.x, + x = _ref$x === undefined ? 0 : _ref$x, + _ref$y = _ref.y, + y = _ref$y === undefined ? 0 : _ref$y, + offset = _ref.offset, + bbox = _ref.bbox, + padding = _ref.padding; + + align = topBottomDynamic(align, offset.x); + + if (align == "right") { + x -= bbox.width; + } else if (align == "middle") { + x -= bbox.width / 2; + } + + var data = [[x, y], [x + bbox.width, y]]; + return { components: [lineBuilder({ data: data, className: "note-line" })] }; +}); + +var lineSetup = function lineSetup(_ref) { + var type = _ref.type, + subjectType = _ref.subjectType; + + var annotation = type.annotation; + var offset = annotation.position; + + var x1 = annotation.x - offset.x, + x2 = x1 + annotation.dx, + y1 = annotation.y - offset.y, + y2 = y1 + annotation.dy; + + var subjectData = annotation.subject; + + if (subjectType == "circle" && (subjectData.outerRadius || subjectData.radius)) { + var h = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); + var angle = Math.asin(-y2 / h); + var r = subjectData.outerRadius || subjectData.radius + (subjectData.radiusPadding || 0); + + x1 = Math.abs(Math.cos(angle) * r) * (x2 < 0 ? -1 : 1); + y1 = Math.abs(Math.sin(angle) * r) * (y2 < 0 ? -1 : 1); + } + + if (subjectType == "rect") { + var width = subjectData.width, + height = subjectData.height; - if (!connectorData) { - connectorData = {}; + if (width > 0 && annotation.dx > 0 || width < 0 && annotation.dx < 0) { + if (Math.abs(width) > Math.abs(annotation.dx)) x1 = width / 2;else x1 = width; } - if (!connectorData.points || typeof connectorData.points === "number") { - connectorData.points = createPoints(type.annotation.offset, connectorData.points); + if (height > 0 && annotation.dy > 0 || height < 0 && annotation.dy < 0) { + if (Math.abs(height) > Math.abs(annotation.dy)) y1 = height / 2;else y1 = height; } - if (!connectorData.curve) { - connectorData.curve = d3Shape.curveCatmullRom; + if (x1 == width / 2 && y1 == height / 2) { + x1 = x2;y1 = y2; } + } - var handles = []; + return [[x1, y1], [x2, y2]]; +}; - if (type.editMode) { - (function () { - var cHandles = connectorData.points.map(function (c, i) { - return _extends({}, pointHandle({ cx: c[0], cy: c[1] }), { index: i }); - }); - - var updatePoint = function updatePoint(index) { - connectorData.points[index][0] += d3Selection.event.dx; - connectorData.points[index][1] += d3Selection.event.dy; - type.redrawConnector(); - }; +var connectorLine = (function (connectorData) { + var data = lineSetup(connectorData); + return { components: [lineBuilder({ data: data, className: "connector" })] }; +}); - handles = type.mapHandles(cHandles.map(function (h) { - return _extends({}, h.move, { drag: updatePoint.bind(type, h.index) }); - })); - })(); - } +var connectorElbow = (function (_ref) { + var type = _ref.type, + subjectType = _ref.subjectType; - var data = lineSetup({ type: type, subjectType: subjectType }); - data = [data[0]].concat(toConsumableArray(connectorData.points), [data[1]]); - var components = [lineBuilder({ data: data, curve: connectorData.curve, className: "connector" })]; - return { components: components, handles: handles }; - }); + var annotation = type.annotation; + var offset = annotation.position; - var createPoints = function createPoints(offset) { - var anchors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2; + var x1 = annotation.x - offset.x, + x2 = x1 + annotation.dx, + y1 = annotation.y - offset.y, + y2 = y1 + annotation.dy; - var diff = { x: offset.x / (anchors + 1), y: offset.y / (anchors + 1) }; - var p = []; + var subjectData = annotation.subject; - var i = 1; - for (; i <= anchors; i++) { - p.push([diff.x * i + i % 2 * 20, diff.y * i - i % 2 * 20]); - } - return p; - }; + if (subjectType == "rect") { + var width = subjectData.width, + height = subjectData.height; - var connectorArrow = (function (_ref) { - var annotation = _ref.annotation, - start = _ref.start, - end = _ref.end; - var offset = annotation.position; - if (!start) { - start = [annotation.dx, annotation.dy]; - } else { - start = [-end[0] + start[0], -end[1] + start[1]]; + if (width > 0 && annotation.dx > 0 || width < 0 && annotation.dx < 0) { + if (Math.abs(width) > Math.abs(annotation.dx)) x1 = width / 2;else x1 = width; } - if (!end) { - end = [annotation.x - offset.x, annotation.y - offset.y]; + if (height > 0 && annotation.dy > 0 || height < 0 && annotation.dy < 0) { + if (Math.abs(height) > Math.abs(annotation.dy)) y1 = height / 2;else y1 = height; } - - var x1 = end[0], - y1 = end[1]; - - var dx = start[0]; - var dy = start[1]; - - var size = 10; - var angleOffset = 16 / 180 * Math.PI; - var angle = Math.atan(dy / dx); - - if (dx < 0) { - angle += Math.PI; + if (x1 == width / 2 && y1 == height / 2) { + x1 = x2;y1 = y2; } - - var data = [[x1, y1], [Math.cos(angle + angleOffset) * size + x1, Math.sin(angle + angleOffset) * size + y1], [Math.cos(angle - angleOffset) * size + x1, Math.sin(angle - angleOffset) * size + y1], [x1, y1]]; - - //TODO add in reverse - // if (canvasContext.arrowReverse){ - // data = [[x1, y1], - // [Math.cos(angle + angleOffset)*size, Math.sin(angle + angleOffset)*size], - // [Math.cos(angle - angleOffset)*size, Math.sin(angle - angleOffset)*size], - // [x1, y1] - // ] - // } else { - // data = [[x1, y1], - // [Math.cos(angle + angleOffset)*size, Math.sin(angle + angleOffset)*size], - // [Math.cos(angle - angleOffset)*size, Math.sin(angle - angleOffset)*size], - // [x1, y1] - // ] - // } - - return { components: [lineBuilder({ data: data, className: 'connector-arrow' })] }; - }); - - var connectorDot = (function (_ref) { - var line = _ref.line; - - - var dot = arcBuilder({ className: 'connector-dot', data: { radius: 3 } }); - dot.attrs.transform = 'translate(' + line.data[0][0] + ', ' + line.data[0][1] + ')'; - - return { components: [dot] }; - }); - - var subjectCircle = (function (_ref) { - var subjectData = _ref.subjectData, - type = _ref.type; - - if (!subjectData.radius && !subjectData.outerRadius) { - subjectData.radius = 20; + } + + var data = [[x1, y1], [x2, y2]]; + + var diffY = y2 - y1; + var diffX = x2 - x1; + var xe = x2; + var ye = y2; + var opposite = y2 < y1 && x2 > x1 || x2 < x1 && y2 > y1 ? -1 : 1; + + if (Math.abs(diffX) < Math.abs(diffY)) { + xe = x2; + ye = y1 + diffX * opposite; + } else { + ye = y2; + xe = x1 + diffY * opposite; + } + + if (subjectType == "circle" && (subjectData.outerRadius || subjectData.radius)) { + var r = (subjectData.outerRadius || subjectData.radius) + (subjectData.radiusPadding || 0); + var length = r / Math.sqrt(2); + + if (Math.abs(diffX) > length && Math.abs(diffY) > length) { + x1 = length * (x2 < 0 ? -1 : 1); + y1 = length * (y2 < 0 ? -1 : 1); + data = [[x1, y1], [xe, ye], [x2, y2]]; + } else if (Math.abs(diffX) > Math.abs(diffY)) { + var angle = Math.asin(-y2 / r); + x1 = Math.abs(Math.cos(angle) * r) * (x2 < 0 ? -1 : 1); + data = [[x1, y2], [x2, y2]]; + } else { + var _angle = Math.acos(x2 / r); + y1 = Math.abs(Math.sin(_angle) * r) * (y2 < 0 ? -1 : 1); + data = [[x2, y1], [x2, y2]]; } - - var handles = []; - var c = arcBuilder({ data: subjectData, className: "subject" }); - if (type.editMode) { - var h = circleHandles({ - r1: c.data.outerRadius || c.data.radius, - r2: c.data.innerRadius, - padding: subjectData.radiusPadding + } else { + data = [[x1, y1], [xe, ye], [x2, y2]]; + } + + return { components: [lineBuilder({ data: data, className: "connector" })] }; +}); + +var connectorCurve = (function (_ref) { + var type = _ref.type, + connectorData = _ref.connectorData, + subjectType = _ref.subjectType; + + + if (!connectorData) { + connectorData = {}; + } + if (!connectorData.points || typeof connectorData.points === "number") { + connectorData.points = createPoints(type.annotation.offset, connectorData.points); + } + if (!connectorData.curve) { + connectorData.curve = d3Shape.curveCatmullRom; + } + + var handles = []; + + if (type.editMode) { + (function () { + var cHandles = connectorData.points.map(function (c, i) { + return _extends({}, pointHandle({ cx: c[0], cy: c[1] }), { index: i }); }); - var updateRadius = function updateRadius(attr) { - var r = subjectData[attr] + d3Selection.event.dx * Math.sqrt(2); - subjectData[attr] = r; - type.redrawSubject(); + var updatePoint = function updatePoint(index) { + connectorData.points[index][0] += d3Selection.event.dx; + connectorData.points[index][1] += d3Selection.event.dy; type.redrawConnector(); }; - var cHandles = [_extends({}, h.r1, { drag: updateRadius.bind(type, subjectData.outerRadius !== undefined ? 'outerRadius' : 'radius') })]; - - if (subjectData.innerRadius) { - cHandles.push(_extends({}, h.r2, { drag: updateRadius.bind(type, 'innerRadius') })); - } - handles = type.mapHandles(cHandles); - } + handles = type.mapHandles(cHandles.map(function (h) { + return _extends({}, h.move, { drag: updatePoint.bind(type, h.index) }); + })); + })(); + } + + var data = lineSetup({ type: type, subjectType: subjectType }); + data = [data[0]].concat(toConsumableArray(connectorData.points), [data[1]]); + var components = [lineBuilder({ data: data, curve: connectorData.curve, className: "connector" })]; + + return { components: components, handles: handles }; +}); + +var createPoints = function createPoints(offset) { + var anchors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2; + + var diff = { x: offset.x / (anchors + 1), y: offset.y / (anchors + 1) }; + var p = []; + + var i = 1; + for (; i <= anchors; i++) { + p.push([diff.x * i + i % 2 * 20, diff.y * i - i % 2 * 20]); + } + return p; +}; + +var connectorArrow = (function (_ref) { + var annotation = _ref.annotation, + start = _ref.start, + end = _ref.end; + + var offset = annotation.position; + if (!start) { + start = [annotation.dx, annotation.dy]; + } else { + start = [-end[0] + start[0], -end[1] + start[1]]; + } + if (!end) { + end = [annotation.x - offset.x, annotation.y - offset.y]; + } + + var x1 = end[0], + y1 = end[1]; + + var dx = start[0]; + var dy = start[1]; + + var size = 10; + var angleOffset = 16 / 180 * Math.PI; + var angle = Math.atan(dy / dx); + + if (dx < 0) { + angle += Math.PI; + } + + var data = [[x1, y1], [Math.cos(angle + angleOffset) * size + x1, Math.sin(angle + angleOffset) * size + y1], [Math.cos(angle - angleOffset) * size + x1, Math.sin(angle - angleOffset) * size + y1], [x1, y1]]; + + //TODO add in reverse + // if (canvasContext.arrowReverse){ + // data = [[x1, y1], + // [Math.cos(angle + angleOffset)*size, Math.sin(angle + angleOffset)*size], + // [Math.cos(angle - angleOffset)*size, Math.sin(angle - angleOffset)*size], + // [x1, y1] + // ] + // } else { + // data = [[x1, y1], + // [Math.cos(angle + angleOffset)*size, Math.sin(angle + angleOffset)*size], + // [Math.cos(angle - angleOffset)*size, Math.sin(angle - angleOffset)*size], + // [x1, y1] + // ] + // } + + return { components: [lineBuilder({ data: data, className: 'connector-arrow' })] }; +}); + +var connectorDot = (function (_ref) { + var line$$1 = _ref.line; + + + var dot = arcBuilder({ className: 'connector-dot', data: { radius: 3 } }); + dot.attrs.transform = 'translate(' + line$$1.data[0][0] + ', ' + line$$1.data[0][1] + ')'; + + return { components: [dot] }; +}); + +var subjectCircle = (function (_ref) { + var subjectData = _ref.subjectData, + type = _ref.type; + + if (!subjectData.radius && !subjectData.outerRadius) { + subjectData.radius = 20; + } + + var handles = []; + var c = arcBuilder({ data: subjectData, className: "subject" }); + if (type.editMode) { + var h = circleHandles({ + r1: c.data.outerRadius || c.data.radius, + r2: c.data.innerRadius, + padding: subjectData.radiusPadding + }); - return { components: [c], handles: handles }; - }); + var updateRadius = function updateRadius(attr) { + var r = subjectData[attr] + d3Selection.event.dx * Math.sqrt(2); + subjectData[attr] = r; + type.redrawSubject(); + type.redrawConnector(); + }; - var subjectRect = (function (_ref) { - var subjectData = _ref.subjectData, - type = _ref.type; + var cHandles = [_extends({}, h.r1, { drag: updateRadius.bind(type, subjectData.outerRadius !== undefined ? 'outerRadius' : 'radius') })]; - if (!subjectData.width) { - subjectData.width = 100; - } - if (!subjectData.height) { - subjectData.height = 100; + if (subjectData.innerRadius) { + cHandles.push(_extends({}, h.r2, { drag: updateRadius.bind(type, 'innerRadius') })); } + handles = type.mapHandles(cHandles); + } - var handles = []; - var width = subjectData.width, - height = subjectData.height; + return { components: [c], handles: handles }; +}); +var subjectRect = (function (_ref) { + var subjectData = _ref.subjectData, + type = _ref.type; - var data = [[0, 0], [width, 0], [width, height], [0, height], [0, 0]]; - var rect = lineBuilder({ data: data, className: 'subject' }); + if (!subjectData.width) { + subjectData.width = 100; + } + if (!subjectData.height) { + subjectData.height = 100; + } - if (type.editMode) { + var handles = []; + var width = subjectData.width, + height = subjectData.height; - var updateWidth = function updateWidth(attr) { - subjectData.width = d3Selection.event.x; - type.redrawSubject(); - type.redrawConnector(); - }; - var updateHeight = function updateHeight() { - subjectData.height = d3Selection.event.y; - type.redrawSubject(); - type.redrawConnector(); - }; + var data = [[0, 0], [width, 0], [width, height], [0, height], [0, 0]]; + var rect = lineBuilder({ data: data, className: 'subject' }); - var rHandles = [{ x: width, y: height / 2, drag: updateWidth.bind(type) }, { x: width / 2, y: height, drag: updateHeight.bind(type) }]; + if (type.editMode) { - handles = type.mapHandles(rHandles); - } + var updateWidth = function updateWidth(attr) { + subjectData.width = d3Selection.event.x; + type.redrawSubject(); + type.redrawConnector(); + }; - return { components: [rect], handles: handles }; - }); + var updateHeight = function updateHeight() { + subjectData.height = d3Selection.event.y; + type.redrawSubject(); + type.redrawConnector(); + }; - var subjectThreshold = (function (_ref) { - var subjectData = _ref.subjectData, - type = _ref.type; + var rHandles = [{ x: width, y: height / 2, drag: updateWidth.bind(type) }, { x: width / 2, y: height, drag: updateHeight.bind(type) }]; - var offset = type.annotation.position; + handles = type.mapHandles(rHandles); + } - var x1 = (subjectData.x1 !== undefined ? subjectData.x1 : offset.x) - offset.x, - x2 = (subjectData.x2 !== undefined ? subjectData.x2 : offset.x) - offset.x, - y1 = (subjectData.y1 !== undefined ? subjectData.y1 : offset.y) - offset.y, - y2 = (subjectData.y2 !== undefined ? subjectData.y2 : offset.y) - offset.y; + return { components: [rect], handles: handles }; +}); - var data = [[x1, y1], [x2, y2]]; - return { components: [lineBuilder({ data: data, className: 'subject' })] }; - }); +var subjectThreshold = (function (_ref) { + var subjectData = _ref.subjectData, + type = _ref.type; - var subjectBadge = (function (_ref) { - var subjectData = _ref.subjectData, - type = _ref.type; + var offset = type.annotation.position; - if (!subjectData.radius) subjectData.radius = 14; - if (!subjectData.x) subjectData.x = "left"; - if (!subjectData.y) subjectData.y = "top"; + var x1 = (subjectData.x1 !== undefined ? subjectData.x1 : offset.x) - offset.x, + x2 = (subjectData.x2 !== undefined ? subjectData.x2 : offset.x) - offset.x, + y1 = (subjectData.y1 !== undefined ? subjectData.y1 : offset.y) - offset.y, + y2 = (subjectData.y2 !== undefined ? subjectData.y2 : offset.y) - offset.y; - var handles = []; - var radius = subjectData.radius; - var innerRadius = radius * .7; - var x = subjectData.x == "left" ? -radius : radius; - var y = subjectData.y == "top" ? -radius : radius; - var transform = 'translate(' + x + ', ' + y + ')'; - var circlebg = arcBuilder({ className: 'subject', data: { radius: radius } }); - circlebg.attrs.transform = transform; + var data = [[x1, y1], [x2, y2]]; + return { components: [lineBuilder({ data: data, className: 'subject' })] }; +}); - var circle = arcBuilder({ className: 'subject-ring', data: { outerRadius: radius, innerRadius: innerRadius } }); - circle.attrs.transform = transform; +var subjectBadge = (function (_ref) { + var subjectData = _ref.subjectData, + type = _ref.type; - var pointer = lineBuilder({ className: 'subject-pointer', - data: [[0, 0], [x, 0], [0, y], [0, 0]] - }); + if (!subjectData.radius) subjectData.radius = 14; + if (!subjectData.x) subjectData.x = "left"; + if (!subjectData.y) subjectData.y = "top"; - if (type.editMode) { + var handles = []; + var radius = subjectData.radius; + var innerRadius = radius * .7; + var x = subjectData.x == "left" ? -radius : radius; + var y = subjectData.y == "top" ? -radius : radius; + var transform = 'translate(' + x + ', ' + y + ')'; + var circlebg = arcBuilder({ className: 'subject', data: { radius: radius } }); + circlebg.attrs.transform = transform; - var dragBadge = function dragBadge() { - subjectData.x = d3Selection.event.x < 0 ? "left" : "right"; - subjectData.y = d3Selection.event.y < 0 ? "top" : "bottom"; - type.redrawSubject(); - }; + var circle = arcBuilder({ className: 'subject-ring', data: { outerRadius: radius, innerRadius: innerRadius } }); + circle.attrs.transform = transform; - var bHandles = [{ x: x * 2, y: y * 2, drag: dragBadge.bind(type) }]; - handles = type.mapHandles(bHandles); - } - - var text = void 0; - if (subjectData.text) { - text = { - type: "text", - className: "badge-text", - attrs: { - text: subjectData.text, - "text-anchor": "middle", - dy: ".25em", - x: x, - y: y - } - }; - } - return { components: [pointer, circlebg, circle, text], handles: handles }; + var pointer = lineBuilder({ className: 'subject-pointer', + data: [[0, 0], [x, 0], [0, y], [0, 0]] }); - var Type = function () { - function Type(_ref) { - var a = _ref.a, - annotation = _ref.annotation, - editMode = _ref.editMode, - dispatcher = _ref.dispatcher, - notePadding = _ref.notePadding, - accessors = _ref.accessors; - classCallCheck(this, Type); - - this.a = a; - - this.note = annotation.disable.indexOf("note") === -1 && a.select('g.annotation-note'); - this.noteContent = this.note && a.select('g.annotation-note-content'); - this.connector = annotation.disable.indexOf("connector") === -1 && a.select('g.annotation-connector'); - this.subject = annotation.disable.indexOf("subject") === -1 && a.select('g.annotation-subject'); - - if (dispatcher) { - var handler = addHandlers.bind(null, dispatcher, annotation); - handler({ component: this.note, name: 'note' }); - handler({ component: this.connector, name: 'connector' }); - handler({ component: this.subject, name: 'subject' }); - } + if (type.editMode) { - this.annotation = annotation; - this.editMode = annotation.editMode || editMode; - this.notePadding = notePadding || 3; - this.offsetCornerX = 0; - this.offsetCornerY = 0; + var dragBadge = function dragBadge() { + subjectData.x = d3Selection.event.x < 0 ? "left" : "right"; + subjectData.y = d3Selection.event.y < 0 ? "top" : "bottom"; + type.redrawSubject(); + }; - if (accessors && annotation.data) { - this.init(accessors); + var bHandles = [{ x: x * 2, y: y * 2, drag: dragBadge.bind(type) }]; + handles = type.mapHandles(bHandles); + } + + var text = void 0; + if (subjectData.text) { + text = { + type: "text", + className: "badge-text", + attrs: { + text: subjectData.text, + "text-anchor": "middle", + dy: ".25em", + x: x, + y: y } + }; + } + return { components: [pointer, circlebg, circle, text], handles: handles }; +}); + +//Note options +//Connector options +//Subject options +var Type = function () { + function Type(_ref) { + var a = _ref.a, + annotation = _ref.annotation, + editMode = _ref.editMode, + dispatcher = _ref.dispatcher, + notePadding = _ref.notePadding, + accessors = _ref.accessors; + classCallCheck(this, Type); + + this.a = a; + + this.note = annotation.disable.indexOf("note") === -1 && a.select('g.annotation-note'); + this.noteContent = this.note && a.select('g.annotation-note-content'); + this.connector = annotation.disable.indexOf("connector") === -1 && a.select('g.annotation-connector'); + this.subject = annotation.disable.indexOf("subject") === -1 && a.select('g.annotation-subject'); + + if (dispatcher) { + var handler = addHandlers.bind(null, dispatcher, annotation); + handler({ component: this.note, name: 'note' }); + handler({ component: this.connector, name: 'connector' }); + handler({ component: this.subject, name: 'subject' }); } - createClass(Type, [{ - key: 'init', - value: function init(accessors) { - if (!this.annotation.x) { - this.mapX(accessors); - } - if (!this.annotation.y) { - this.mapY(accessors); - } + this.annotation = annotation; + this.editMode = annotation.editMode || editMode; + this.notePadding = notePadding || 3; + this.offsetCornerX = 0; + this.offsetCornerY = 0; + + if (accessors && annotation.data) { + this.init(accessors); + } + } + + createClass(Type, [{ + key: 'init', + value: function init(accessors) { + if (!this.annotation.x) { + this.mapX(accessors); } - }, { - key: 'mapY', - value: function mapY(accessors) { - if (accessors.y) { - this.annotation.y = accessors.y(this.annotation.data); - } + if (!this.annotation.y) { + this.mapY(accessors); } - }, { - key: 'mapX', - value: function mapX(accessors) { - if (accessors.x) { - this.annotation.x = accessors.x(this.annotation.data); - } + } + }, { + key: 'mapY', + value: function mapY(accessors) { + if (accessors.y) { + this.annotation.y = accessors.y(this.annotation.data); } - }, { - key: 'updateEditMode', - value: function updateEditMode() { - this.a.selectAll('circle.handle').remove(); + } + }, { + key: 'mapX', + value: function mapX(accessors) { + if (accessors.x) { + this.annotation.x = accessors.x(this.annotation.data); } - }, { - key: 'drawOnSVG', - value: function drawOnSVG(component, builders) { - var _this = this; - - if (!Array.isArray(builders)) { - builders = [builders]; - } + } + }, { + key: 'updateEditMode', + value: function updateEditMode() { + this.a.selectAll('circle.handle').remove(); + } + }, { + key: 'drawOnSVG', + value: function drawOnSVG(component, builders) { + var _this = this; - builders.filter(function (b) { - return b; - }).forEach(function (_ref2) { - var type = _ref2.type, - className = _ref2.className, - attrs = _ref2.attrs, - handles = _ref2.handles; - - if (type === "handle") { - addHandles({ group: component, r: attrs && attrs.r, handles: handles }); - } else { - (function () { - newWithClass(component, [_this.annotation], type, className); - - var el = component.select(type + '.' + className); - var attrKeys = Object.keys(attrs); - attrKeys.forEach(function (attr) { - if (attr === "text") { - el.text(attrs[attr]); - } else { - el.attr(attr, attrs[attr]); - } - }); - })(); - } - }); + if (!Array.isArray(builders)) { + builders = [builders]; } - //TODO: how to extend this to a drawOnCanvas mode? + builders.filter(function (b) { + return b; + }).forEach(function (_ref2) { + var type = _ref2.type, + className = _ref2.className, + attrs = _ref2.attrs, + handles = _ref2.handles; - }, { - key: 'getNoteBBox', - value: function getNoteBBox() { - return bboxWithoutHandles(this.note, '.annotation-note-content text'); - } - }, { - key: 'getNoteBBoxOffset', - value: function getNoteBBoxOffset() { - var bbox = bboxWithoutHandles(this.note, '.annotation-note-content'); - var transform = this.noteContent.attr('transform').split(/\(|\,|\)/g); - bbox.offsetCornerX = parseFloat(transform[1]) + this.annotation.dx; - bbox.offsetCornerY = parseFloat(transform[2]) + this.annotation.dy; - bbox.offsetX = this.annotation.dx; - bbox.offsetY = this.annotation.dy; - return bbox; - } + if (type === "handle") { + addHandles({ group: component, r: attrs && attrs.r, handles: handles }); + } else { + (function () { + newWithClass(component, [_this.annotation], type, className); + + var el = component.select(type + '.' + className); + var attrKeys = Object.keys(attrs); + attrKeys.forEach(function (attr) { + if (attr === "text") { + el.text(attrs[attr]); + } else { + el.attr(attr, attrs[attr]); + } + }); + })(); + } + }); + } - // getConnectorBBox() { return bboxWithoutHandles(this.connector)} - // getSubjectBBox() { return bboxWithoutHandles(this.subject)} - // getAnnotationBBox() { return bboxWithoutHandles(this.a)} + //TODO: how to extend this to a drawOnCanvas mode? - }, { - key: 'drawSubject', - value: function drawSubject() { - var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + }, { + key: 'getNoteBBox', + value: function getNoteBBox() { + return bboxWithoutHandles(this.note, '.annotation-note-content text'); + } + }, { + key: 'getNoteBBoxOffset', + value: function getNoteBBoxOffset() { + var bbox = bboxWithoutHandles(this.note, '.annotation-note-content'); + var transform = this.noteContent.attr('transform').split(/\(|\,|\)/g); + bbox.offsetCornerX = parseFloat(transform[1]) + this.annotation.dx; + bbox.offsetCornerY = parseFloat(transform[2]) + this.annotation.dy; + bbox.offsetX = this.annotation.dx; + bbox.offsetY = this.annotation.dy; + return bbox; + } - var subjectData = this.annotation.subject; - var type = context.type; - var subjectParams = { type: this, subjectData: subjectData }; + // getConnectorBBox() { return bboxWithoutHandles(this.connector)} + // getSubjectBBox() { return bboxWithoutHandles(this.subject)} + // getAnnotationBBox() { return bboxWithoutHandles(this.a)} - var subject = {}; - if (type === "circle") subject = subjectCircle(subjectParams);else if (type === "rect") subject = subjectRect(subjectParams);else if (type === "threshold") subject = subjectThreshold(subjectParams);else if (type === "badge") subject = subjectBadge(subjectParams); + }, { + key: 'drawSubject', + value: function drawSubject() { + var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var _subject = subject, - _subject$components = _subject.components, - components = _subject$components === undefined ? [] : _subject$components, - _subject$handles = _subject.handles, - handles = _subject$handles === undefined ? [] : _subject$handles; + var subjectData = this.annotation.subject; + var type = context.type; + var subjectParams = { type: this, subjectData: subjectData }; - if (this.editMode) { - handles = handles.concat(this.mapHandles([{ drag: this.dragSubject.bind(this) }])); - components.push({ type: "handle", handles: handles }); - } + var subject = {}; + if (type === "circle") subject = subjectCircle(subjectParams);else if (type === "rect") subject = subjectRect(subjectParams);else if (type === "threshold") subject = subjectThreshold(subjectParams);else if (type === "badge") subject = subjectBadge(subjectParams); - return components; + var _subject = subject, + _subject$components = _subject.components, + components = _subject$components === undefined ? [] : _subject$components, + _subject$handles = _subject.handles, + handles = _subject$handles === undefined ? [] : _subject$handles; + + if (this.editMode) { + handles = handles.concat(this.mapHandles([{ drag: this.dragSubject.bind(this) }])); + components.push({ type: "handle", handles: handles }); } - }, { - key: 'drawConnector', - value: function drawConnector() { - var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - var connectorData = this.annotation.connector; - var type = connectorData.type || context.type; - var connectorParams = { type: this, connectorData: connectorData }; - connectorParams.subjectType = this.typeSettings && this.typeSettings.subject && this.typeSettings.subject.type; - - var connector = {}; - if (type === "curve") connector = connectorCurve(connectorParams);else if (type === "elbow") connector = connectorElbow(connectorParams);else connector = connectorLine(connectorParams); - - var _connector = connector, - _connector$components = _connector.components, - components = _connector$components === undefined ? [] : _connector$components, - _connector$handles = _connector.handles, - handles = _connector$handles === undefined ? [] : _connector$handles; - - var line = components[0]; - var endType = connectorData.end || context.end; - var end = {}; - if (endType === "arrow") { - var s = line.data[1]; - var e = line.data[0]; - var distance = Math.sqrt(Math.pow(s[0] - e[0], 2) + Math.pow(s[1] - e[1], 2)); - if (distance < 5 && line.data[2]) { - s = line.data[2]; - } - end = connectorArrow({ annotation: this.annotation, start: s, end: e }); - } else if (endType === "dot") { - end = connectorDot({ line: line }); + return components; + } + }, { + key: 'drawConnector', + value: function drawConnector() { + var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var connectorData = this.annotation.connector; + var type = connectorData.type || context.type; + var connectorParams = { type: this, connectorData: connectorData }; + connectorParams.subjectType = this.typeSettings && this.typeSettings.subject && this.typeSettings.subject.type; + + var connector = {}; + if (type === "curve") connector = connectorCurve(connectorParams);else if (type === "elbow") connector = connectorElbow(connectorParams);else connector = connectorLine(connectorParams); + + var _connector = connector, + _connector$components = _connector.components, + components = _connector$components === undefined ? [] : _connector$components, + _connector$handles = _connector.handles, + handles = _connector$handles === undefined ? [] : _connector$handles; + + var line$$1 = components[0]; + var endType = connectorData.end || context.end; + var end = {}; + if (endType === "arrow") { + var s = line$$1.data[1]; + var e = line$$1.data[0]; + var distance = Math.sqrt(Math.pow(s[0] - e[0], 2) + Math.pow(s[1] - e[1], 2)); + if (distance < 5 && line$$1.data[2]) { + s = line$$1.data[2]; } - if (end.components) { - components = components.concat(end.components); - } + end = connectorArrow({ annotation: this.annotation, start: s, end: e }); + } else if (endType === "dot") { + end = connectorDot({ line: line$$1 }); + } - if (this.editMode) { - if (handles.length !== 0) components.push({ type: "handle", handles: handles }); - } - return components; + if (end.components) { + components = components.concat(end.components); } - }, { - key: 'drawNote', - value: function drawNote() { - var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - var noteData = this.annotation.note; - var align = noteData.align || context.align || 'dynamic'; - var noteParams = { bbox: context.bbox, align: align, offset: this.annotation.offset }; - var lineType = noteData.lineType || context.lineType; - var note = {}; - if (lineType == "vertical") note = noteVertical(noteParams);else if (lineType == "horizontal") note = noteHorizontal(noteParams); - - var _note = note, - _note$components = _note.components, - components = _note$components === undefined ? [] : _note$components, - _note$handles = _note.handles, - handles = _note$handles === undefined ? [] : _note$handles; - - if (this.editMode) { - handles = this.mapHandles([{ x: 0, y: 0, drag: this.dragNote.bind(this) }]); - components.push({ type: "handle", handles: handles }); - } - return components; + + if (this.editMode) { + if (handles.length !== 0) components.push({ type: "handle", handles: handles }); } - }, { - key: 'drawNoteContent', - value: function drawNoteContent(context) { - var noteData = this.annotation.note; - var padding = noteData.padding || this.notePadding; - var orientation = noteData.orientation || context.orientation || 'topBottom'; - var lineType = noteData.lineType || context.lineType; - var align = noteData.align || context.align || 'dynamic'; - var subjectType = this.typeSettings && this.typeSettings.subject && this.typeSettings.subject.type; + return components; + } + }, { + key: 'drawNote', + value: function drawNote() { + var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var noteData = this.annotation.note; + var align = noteData.align || context.align || 'dynamic'; + var noteParams = { bbox: context.bbox, align: align, offset: this.annotation.offset }; + var lineType = noteData.lineType || context.lineType; + var note = {}; + if (lineType == "vertical") note = noteVertical(noteParams);else if (lineType == "horizontal") note = noteHorizontal(noteParams); + + var _note = note, + _note$components = _note.components, + components = _note$components === undefined ? [] : _note$components, + _note$handles = _note.handles, + handles = _note$handles === undefined ? [] : _note$handles; + + if (this.editMode) { + handles = this.mapHandles([{ x: 0, y: 0, drag: this.dragNote.bind(this) }]); + components.push({ type: "handle", handles: handles }); + } + return components; + } + }, { + key: 'drawNoteContent', + value: function drawNoteContent(context) { + var noteData = this.annotation.note; + var padding = noteData.padding || this.notePadding; + var orientation = noteData.orientation || context.orientation || 'topBottom'; + var lineType = noteData.lineType || context.lineType; + var align = noteData.align || context.align || 'dynamic'; + var subjectType = this.typeSettings && this.typeSettings.subject && this.typeSettings.subject.type; - if (lineType == "vertical") orientation = "leftRight";else if (lineType == "horizontal") orientation = "topBottom"; + if (lineType == "vertical") orientation = "leftRight";else if (lineType == "horizontal") orientation = "topBottom"; - var noteParams = { padding: padding, bbox: context.bbox, offset: this.annotation.offset, orientation: orientation, align: align }; + var noteParams = { padding: padding, bbox: context.bbox, offset: this.annotation.offset, orientation: orientation, align: align }; - var _noteAlignment = noteAlignment(noteParams), - x = _noteAlignment.x, - y = _noteAlignment.y; + var _noteAlignment = noteAlignment(noteParams), + x = _noteAlignment.x, + y = _noteAlignment.y; - this.offsetCornerX = x + this.annotation.dx; - this.offsetCornerY = y + this.annotation.dy; - this.note && this.noteContent.attr('transform', 'translate(' + x + ', ' + y + ')'); + this.offsetCornerX = x + this.annotation.dx; + this.offsetCornerY = y + this.annotation.dy; + this.note && this.noteContent.attr('transform', 'translate(' + x + ', ' + y + ')'); - return []; - } - }, { - key: 'drawOnScreen', - value: function drawOnScreen(component, drawFunction) { - return this.drawOnSVG(component, drawFunction); - } - }, { - key: 'redrawSubject', - value: function redrawSubject() { - this.subject && this.drawOnScreen(this.subject, this.drawSubject()); - } - }, { - key: 'redrawConnector', - value: function redrawConnector() { - var bbox = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getNoteBBox(); + return []; + } + }, { + key: 'drawOnScreen', + value: function drawOnScreen(component, drawFunction) { + return this.drawOnSVG(component, drawFunction); + } + }, { + key: 'redrawSubject', + value: function redrawSubject() { + this.subject && this.drawOnScreen(this.subject, this.drawSubject()); + } + }, { + key: 'redrawConnector', + value: function redrawConnector() { + var bbox = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getNoteBBox(); - this.connector && this.drawOnScreen(this.connector, this.drawConnector()); - } - }, { - key: 'redrawNote', - value: function redrawNote() { - var bbox = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getNoteBBox(); + this.connector && this.drawOnScreen(this.connector, this.drawConnector()); + } + }, { + key: 'redrawNote', + value: function redrawNote() { + var bbox = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getNoteBBox(); - this.noteContent && this.drawOnScreen(this.noteContent, this.drawNoteContent({ bbox: bbox })); - this.note && this.drawOnScreen(this.note, this.drawNote({ bbox: bbox })); - } - }, { - key: 'setPosition', - value: function setPosition() { - var position = this.annotation.position; - this.a.attr('transform', 'translate(' + position.x + ', ' + position.y + ')'); - } - }, { - key: 'setOffset', - value: function setOffset() { - if (this.note) { - var offset = this.annotation.offset; - this.note.attr('transform', 'translate(' + offset.x + ', ' + offset.y + ')'); - } - } - }, { - key: 'setPositionWithAccessors', - value: function setPositionWithAccessors(accessors) { - if (accessors && this.annotation.data) { - this.mapX(accessors); - this.mapY(accessors); - } - this.setPosition(); - } - }, { - key: 'setClassName', - value: function setClassName() { - this.a.attr("class", 'annotation ' + (this.className && this.className()) + ' ' + (this.editMode ? "editable" : "") + ' ' + (this.annotation.className || '')); + this.noteContent && this.drawOnScreen(this.noteContent, this.drawNoteContent({ bbox: bbox })); + this.note && this.drawOnScreen(this.note, this.drawNote({ bbox: bbox })); + } + }, { + key: 'setPosition', + value: function setPosition() { + var position = this.annotation.position; + this.a.attr('transform', 'translate(' + position.x + ', ' + position.y + ')'); + } + }, { + key: 'setOffset', + value: function setOffset() { + if (this.note) { + var offset = this.annotation.offset; + this.note.attr('transform', 'translate(' + offset.x + ', ' + offset.y + ')'); } - }, { - key: 'draw', - value: function draw() { - this.setClassName(); - this.setPosition(); - this.setOffset(); - this.redrawSubject(); - this.redrawConnector(); - this.redrawNote(); + } + }, { + key: 'setPositionWithAccessors', + value: function setPositionWithAccessors(accessors) { + if (accessors && this.annotation.data) { + this.mapX(accessors); + this.mapY(accessors); + } + this.setPosition(); + } + }, { + key: 'setClassName', + value: function setClassName() { + this.a.attr("class", 'annotation ' + (this.className && this.className()) + ' ' + (this.editMode ? "editable" : "") + ' ' + (this.annotation.className || '')); + } + }, { + key: 'draw', + value: function draw() { + this.setClassName(); + this.setPosition(); + this.setOffset(); + this.redrawSubject(); + this.redrawConnector(); + this.redrawNote(); + } + }, { + key: 'dragstarted', + value: function dragstarted() { + d3Selection.event.sourceEvent.stopPropagation(); + this.a.classed("dragging", true); + this.a.selectAll("circle.handle").style("pointer-events", "none"); + } + }, { + key: 'dragended', + value: function dragended() { + this.a.classed("dragging", false); + this.a.selectAll("circle.handle").style("pointer-events", "all"); + } + }, { + key: 'dragSubject', + value: function dragSubject() { + var position = this.annotation.position; + position.x += d3Selection.event.dx; + position.y += d3Selection.event.dy; + this.annotation.position = position; + } + }, { + key: 'dragNote', + value: function dragNote() { + var offset = this.annotation.offset; + offset.x += d3Selection.event.dx; + offset.y += d3Selection.event.dy; + this.annotation.offset = offset; + } + }, { + key: 'mapHandles', + value: function mapHandles(handles) { + var _this2 = this; + + return handles.map(function (h) { + return _extends({}, h, { + start: _this2.dragstarted.bind(_this2), end: _this2.dragended.bind(_this2) }); + }); + } + }]); + return Type; +}(); + +var customType = function customType(initialType, typeSettings, _init) { + return function (_initialType) { + inherits(customType, _initialType); + + function customType(settings) { + classCallCheck(this, customType); + + var _this3 = possibleConstructorReturn(this, (customType.__proto__ || Object.getPrototypeOf(customType)).call(this, settings)); + + _this3.typeSettings = typeSettings; + + if (typeSettings.disable) { + typeSettings.disable.forEach(function (d) { + _this3[d] = undefined; + if (d == "note") { + _this3.noteContent = undefined; + } + }); } - }, { - key: 'dragstarted', - value: function dragstarted() { - d3Selection.event.sourceEvent.stopPropagation(); - this.a.classed("dragging", true); - this.a.selectAll("circle.handle").style("pointer-events", "none"); + return _this3; + } + + createClass(customType, [{ + key: 'className', + value: function className() { + return (typeSettings.className || '') + ' ' + (get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'className', this) && get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'className', this).call(this) || ''); } }, { - key: 'dragended', - value: function dragended() { - this.a.classed("dragging", false); - this.a.selectAll("circle.handle").style("pointer-events", "all"); + key: 'drawSubject', + value: function drawSubject(context) { + this.typeSettings.subject = Object.assign({}, typeSettings.subject, this.typeSettings.subject); + return get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'drawSubject', this).call(this, _extends({}, context, this.typeSettings.subject)); } }, { - key: 'dragSubject', - value: function dragSubject() { - var position = this.annotation.position; - position.x += d3Selection.event.dx; - position.y += d3Selection.event.dy; - this.annotation.position = position; + key: 'drawConnector', + value: function drawConnector(context, subjectContext) { + this.typeSettings.connector = Object.assign({}, typeSettings.connector, this.typeSettings.connector); + return get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'drawConnector', this).call(this, _extends({}, context, typeSettings.connector, this.typeSettings.connector)); } }, { - key: 'dragNote', - value: function dragNote() { - var offset = this.annotation.offset; - offset.x += d3Selection.event.dx; - offset.y += d3Selection.event.dy; - this.annotation.offset = offset; + key: 'drawNote', + value: function drawNote(context) { + this.typeSettings.note = Object.assign({}, typeSettings.note, this.typeSettings.note); + return get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'drawNote', this).call(this, _extends({}, context, typeSettings.note, this.typeSettings.note)); } }, { - key: 'mapHandles', - value: function mapHandles(handles) { - var _this2 = this; - - return handles.map(function (h) { - return _extends({}, h, { - start: _this2.dragstarted.bind(_this2), end: _this2.dragended.bind(_this2) }); - }); + key: 'drawNoteContent', + value: function drawNoteContent(context) { + return get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'drawNoteContent', this).call(this, _extends({}, context, typeSettings.note, this.typeSettings.note)); } - }]); - return Type; - }(); - - var customType = function customType(initialType, typeSettings, _init) { - return function (_initialType) { - inherits(customType, _initialType); - - function customType(settings) { - classCallCheck(this, customType); - - var _this3 = possibleConstructorReturn(this, (customType.__proto__ || Object.getPrototypeOf(customType)).call(this, settings)); - - _this3.typeSettings = typeSettings; - - if (typeSettings.disable) { - typeSettings.disable.forEach(function (d) { - _this3[d] = undefined; - if (d == "note") { - _this3.noteContent = undefined; - } - }); + }], [{ + key: 'init', + value: function init(annotation, accessors) { + get(customType.__proto__ || Object.getPrototypeOf(customType), 'init', this).call(this, annotation, accessors); + if (_init) { + annotation = _init(annotation, accessors); } - return _this3; + return annotation; } + }]); + return customType; + }(initialType); +}; - createClass(customType, [{ - key: 'className', - value: function className() { - return (typeSettings.className || '') + ' ' + (get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'className', this) && get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'className', this).call(this) || ''); - } - }, { - key: 'drawSubject', - value: function drawSubject(context) { - this.typeSettings.subject = Object.assign({}, typeSettings.subject, this.typeSettings.subject); - return get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'drawSubject', this).call(this, _extends({}, context, this.typeSettings.subject)); - } - }, { - key: 'drawConnector', - value: function drawConnector(context, subjectContext) { - this.typeSettings.connector = Object.assign({}, typeSettings.connector, this.typeSettings.connector); - return get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'drawConnector', this).call(this, _extends({}, context, typeSettings.connector, this.typeSettings.connector)); - } - }, { - key: 'drawNote', - value: function drawNote(context) { - this.typeSettings.note = Object.assign({}, typeSettings.note, this.typeSettings.note); - return get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'drawNote', this).call(this, _extends({}, context, typeSettings.note, this.typeSettings.note)); - } - }, { - key: 'drawNoteContent', - value: function drawNoteContent(context) { - return get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'drawNoteContent', this).call(this, _extends({}, context, typeSettings.note, this.typeSettings.note)); - } - }], [{ - key: 'init', - value: function init(annotation, accessors) { - get(customType.__proto__ || Object.getPrototypeOf(customType), 'init', this).call(this, annotation, accessors); - if (_init) { - annotation = _init(annotation, accessors); - } - return annotation; - } - }]); - return customType; - }(initialType); - }; +var d3NoteText = function (_Type) { + inherits(d3NoteText, _Type); - var d3NoteText = function (_Type) { - inherits(d3NoteText, _Type); + function d3NoteText(params) { + classCallCheck(this, d3NoteText); - function d3NoteText(params) { - classCallCheck(this, d3NoteText); + var _this4 = possibleConstructorReturn(this, (d3NoteText.__proto__ || Object.getPrototypeOf(d3NoteText)).call(this, params)); - var _this4 = possibleConstructorReturn(this, (d3NoteText.__proto__ || Object.getPrototypeOf(d3NoteText)).call(this, params)); + _this4.textWrap = params.textWrap || 120; + _this4.drawText(); + return _this4; + } - _this4.textWrap = params.textWrap || 120; - _this4.drawText(); - return _this4; + createClass(d3NoteText, [{ + key: 'updateTextWrap', + value: function updateTextWrap(textWrap) { + this.textWrap = textWrap; + this.drawText(); } - createClass(d3NoteText, [{ - key: 'updateTextWrap', - value: function updateTextWrap(textWrap) { - this.textWrap = textWrap; - this.drawText(); - } + //TODO: add update text functionality - //TODO: add update text functionality + }, { + key: 'drawText', + value: function drawText() { + if (this.note) { - }, { - key: 'drawText', - value: function drawText() { - if (this.note) { - - newWithClass(this.note, [this.annotation], 'g', 'annotation-note-content'); - - var noteContent = this.note.select('g.annotation-note-content'); - newWithClass(noteContent, [this.annotation], 'rect', 'annotation-note-bg'); - newWithClass(noteContent, [this.annotation], 'text', 'annotation-note-label'); - newWithClass(noteContent, [this.annotation], 'text', 'annotation-note-title'); - - var titleBBox = { height: 0 }; - var label = this.a.select('text.annotation-note-label'); - var wrapLength = this.annotation.note && this.annotation.note.wrap || this.typeSettings && this.typeSettings.note && this.typeSettings.note.wrap || this.textWrap; - - if (this.annotation.note.title) { - var title = this.a.select('text.annotation-note-title'); - title.text(this.annotation.note.title).attr('dy', '1.1em'); - title.call(wrap, wrapLength); - titleBBox = title.node().getBBox(); - } + newWithClass(this.note, [this.annotation], 'g', 'annotation-note-content'); - label.text(this.annotation.note.label).attr('dy', '1em'); - label.call(wrap, wrapLength); + var noteContent = this.note.select('g.annotation-note-content'); + newWithClass(noteContent, [this.annotation], 'rect', 'annotation-note-bg'); + newWithClass(noteContent, [this.annotation], 'text', 'annotation-note-label'); + newWithClass(noteContent, [this.annotation], 'text', 'annotation-note-title'); - label.attr('y', titleBBox.height * 1.1 || 0); + var titleBBox = { height: 0 }; + var label = this.a.select('text.annotation-note-label'); + var wrapLength = this.annotation.note && this.annotation.note.wrap || this.typeSettings && this.typeSettings.note && this.typeSettings.note.wrap || this.textWrap; - var bbox = this.getNoteBBox(); - this.a.select('rect.annotation-note-bg').attr('width', bbox.width).attr('height', bbox.height); + if (this.annotation.note.title) { + var title = this.a.select('text.annotation-note-title'); + title.text(this.annotation.note.title).attr('dy', '1.1em'); + title.call(wrap, wrapLength); + titleBBox = title.node().getBBox(); } - } - }]); - return d3NoteText; - }(Type); - - var d3Label = customType(d3NoteText, { - className: "label", - note: { align: "middle" } - }); - - var d3Callout = customType(d3NoteText, { - className: "callout", - note: { lineType: "horizontal" } - }); - - var d3CalloutElbow = customType(d3Callout, { - className: "callout elbow", - connector: { type: "elbow" } - }); - var d3CalloutCurve = customType(d3Callout, { - className: "callout curve", - connector: { type: "curve" } - }); + label.text(this.annotation.note.label).attr('dy', '1em'); + label.call(wrap, wrapLength); - var d3Badge = customType(Type, { - className: "badge", - subject: { type: "badge" }, - disable: ['connector', 'note'] - }); - - var d3CalloutCircle = customType(d3CalloutElbow, { - className: "callout circle", - subject: { type: "circle" } - }); + label.attr('y', titleBBox.height * 1.1 || 0); - var d3CalloutRect = customType(d3CalloutElbow, { - className: "callout rect", - subject: { type: "rect" } - }); - - var ThresholdMap = function (_d3Callout) { - inherits(ThresholdMap, _d3Callout); - - function ThresholdMap() { - classCallCheck(this, ThresholdMap); - return possibleConstructorReturn(this, (ThresholdMap.__proto__ || Object.getPrototypeOf(ThresholdMap)).apply(this, arguments)); + var bbox = this.getNoteBBox(); + this.a.select('rect.annotation-note-bg').attr('width', bbox.width).attr('height', bbox.height); + } } - - createClass(ThresholdMap, [{ - key: 'mapY', - value: function mapY(accessors) { - get(ThresholdMap.prototype.__proto__ || Object.getPrototypeOf(ThresholdMap.prototype), 'mapY', this).call(this, accessors); - var a = this.annotation; - if ((a.subject.x1 || a.subject.x2) && a.data && accessors.y) { - a.y = accessors.y(a.data); - } + }]); + return d3NoteText; +}(Type); + +var d3Label = customType(d3NoteText, { + className: "label", + note: { align: "middle" } +}); + +var d3Callout = customType(d3NoteText, { + className: "callout", + note: { lineType: "horizontal" } +}); + +var d3CalloutElbow = customType(d3Callout, { + className: "callout elbow", + connector: { type: "elbow" } +}); + +var d3CalloutCurve = customType(d3Callout, { + className: "callout curve", + connector: { type: "curve" } +}); + +var d3Badge = customType(Type, { + className: "badge", + subject: { type: "badge" }, + disable: ['connector', 'note'] +}); + +var d3CalloutCircle = customType(d3CalloutElbow, { + className: "callout circle", + subject: { type: "circle" } +}); + +var d3CalloutRect = customType(d3CalloutElbow, { + className: "callout rect", + subject: { type: "rect" } +}); + +var ThresholdMap = function (_d3Callout) { + inherits(ThresholdMap, _d3Callout); + + function ThresholdMap() { + classCallCheck(this, ThresholdMap); + return possibleConstructorReturn(this, (ThresholdMap.__proto__ || Object.getPrototypeOf(ThresholdMap)).apply(this, arguments)); + } + + createClass(ThresholdMap, [{ + key: 'mapY', + value: function mapY(accessors) { + get(ThresholdMap.prototype.__proto__ || Object.getPrototypeOf(ThresholdMap.prototype), 'mapY', this).call(this, accessors); + var a = this.annotation; + if ((a.subject.x1 || a.subject.x2) && a.data && accessors.y) { + a.y = accessors.y(a.data); } - }, { - key: 'mapX', - value: function mapX(accessors) { - get(ThresholdMap.prototype.__proto__ || Object.getPrototypeOf(ThresholdMap.prototype), 'mapX', this).call(this, accessors); - var a = this.annotation; - if ((a.subject.y1 || a.subject.y2) && a.data && accessors.x) { - a.x = accessors.x(a.data); - } + } + }, { + key: 'mapX', + value: function mapX(accessors) { + get(ThresholdMap.prototype.__proto__ || Object.getPrototypeOf(ThresholdMap.prototype), 'mapX', this).call(this, accessors); + var a = this.annotation; + if ((a.subject.y1 || a.subject.y2) && a.data && accessors.x) { + a.x = accessors.x(a.data); } - }]); - return ThresholdMap; - }(d3Callout); - - var d3XYThreshold = customType(ThresholdMap, { - className: "callout xythreshold", - subject: { type: "threshold" } + } + }]); + return ThresholdMap; +}(d3Callout); + +var d3XYThreshold = customType(ThresholdMap, { + className: "callout xythreshold", + subject: { type: "threshold" } +}); + +var newWithClass = function newWithClass(a, d, type, className) { + var group = a.selectAll(type + '.' + className).data(d); + group.enter().append(type).merge(group).attr('class', className); + + group.exit().remove(); + return a; +}; + +var addHandlers = function addHandlers(dispatcher, annotation, _ref3) { + var component = _ref3.component, + name = _ref3.name; + + if (component) { + component.on("mouseover.annotations", function () { + dispatcher.call(name + 'over', component, annotation); + }).on("mouseout.annotations", function () { + return dispatcher.call(name + 'out', component, annotation); + }).on("click.annotations", function () { + return dispatcher.call(name + 'click', component, annotation); + }); + } +}; + +//Text wrapping code adapted from Mike Bostock +var wrap = function wrap(text, width) { + text.each(function () { + var text = d3Selection.select(this), + words = text.text().split(/[ \t\r\n]+/).reverse(), + word, + line$$1 = [], + lineNumber = 0, + lineHeight = .2, + //ems + y = text.attr("y"), + dy = parseFloat(text.attr("dy")) || 0, + tspan = text.text(null).append("tspan").attr("x", 0).attr("dy", dy + "em"); + + while (word = words.pop()) { + line$$1.push(word); + tspan.text(line$$1.join(" ")); + if (tspan.node().getComputedTextLength() > width && line$$1.length > 1) { + line$$1.pop(); + tspan.text(line$$1.join(" ")); + line$$1 = [word]; + tspan = text.append("tspan").attr("x", 0).attr("dy", lineHeight + dy + "em").text(word); + } + } }); +}; - var newWithClass = function newWithClass(a, d, type, className) { - var group = a.selectAll(type + '.' + className).data(d); - group.enter().append(type).merge(group).attr('class', className); +var bboxWithoutHandles = function bboxWithoutHandles(selection) { + var selector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ':not(.handle)'; - group.exit().remove(); - return a; - }; + if (!selection) { + return { x: 0, y: 0, width: 0, height: 0 }; + } - var addHandlers = function addHandlers(dispatcher, annotation, _ref3) { - var component = _ref3.component, - name = _ref3.name; - - if (component) { - component.on("mouseover.annotations", function () { - dispatcher.call(name + 'over', component, annotation); - }).on("mouseout.annotations", function () { - return dispatcher.call(name + 'out', component, annotation); - }).on("click.annotations", function () { - return dispatcher.call(name + 'click', component, annotation); - }); + return selection.selectAll(selector).nodes().reduce(function (p, c) { + var bbox = c.getBBox(); + p.x = Math.min(p.x, bbox.x); + p.y = Math.min(p.y, bbox.y); + p.width = Math.max(p.width, bbox.width); + p.height += bbox.height; + return p; + }, { x: 0, y: 0, width: 0, height: 0 }); +}; + +function annotation() { + var annotations = [], + collection = void 0, + context = void 0, + //TODO: add canvas functionality + disable = [], + accessors = {}, + accessorsInverse = {}, + editMode = false, + ids = void 0, + type = d3Callout, + textWrap = void 0, + notePadding = void 0, + annotationDispatcher = d3Dispatch.dispatch("subjectover", "subjectout", "subjectclick", "connectorover", "connectorout", "connectorclick", "noteover", "noteout", "noteclick"), + sel = void 0; + + var annotation = function annotation(selection) { + sel = selection; + //TODO: check to see if this is still needed + if (!editMode) { + selection.selectAll("circle.handle").remove(); } - }; - //Text wrapping code adapted from Mike Bostock - var wrap = function wrap(text, width) { - text.each(function () { - var text = d3Selection.select(this), - words = text.text().split(/[ \t\r\n]+/).reverse(), - word, - line = [], - lineNumber = 0, - lineHeight = .2, - //ems - y = text.attr("y"), - dy = parseFloat(text.attr("dy")) || 0, - tspan = text.text(null).append("tspan").attr("x", 0).attr("dy", dy + "em"); - - while (word = words.pop()) { - line.push(word); - tspan.text(line.join(" ")); - if (tspan.node().getComputedTextLength() > width && line.length > 1) { - line.pop(); - tspan.text(line.join(" ")); - line = [word]; - tspan = text.append("tspan").attr("x", 0).attr("dy", lineHeight + dy + "em").text(word); - } + var translatedAnnotations = annotations.map(function (a) { + if (!a.type) { + a.type = type; } + if (!a.disable) { + a.disable = disable; + } + return new Annotation(a); }); - }; - var bboxWithoutHandles = function bboxWithoutHandles(selection) { - var selector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ':not(.handle)'; + collection = new AnnotationCollection({ + annotations: translatedAnnotations, + accessors: accessors, + accessorsInverse: accessorsInverse, + ids: ids + }); - if (!selection) { - return { x: 0, y: 0, width: 0, height: 0 }; - } + var annotationG = selection.selectAll('g').data([collection]); + annotationG.enter().append('g').attr('class', 'annotations'); - return selection.selectAll(selector).nodes().reduce(function (p, c) { - var bbox = c.getBBox(); - p.x = Math.min(p.x, bbox.x); - p.y = Math.min(p.y, bbox.y); - p.width = Math.max(p.width, bbox.width); - p.height += bbox.height; - return p; - }, { x: 0, y: 0, width: 0, height: 0 }); - }; + var group = selection.select('g.annotations'); + newWithClass(group, collection.annotations, 'g', 'annotation'); - function annotation() { - var annotations = [], - collection = void 0, - context = void 0, - //TODO: add canvas functionality - disable = [], - accessors = {}, - accessorsInverse = {}, - editMode = false, - ids = void 0, - type = d3Callout, - textWrap = void 0, - notePadding = void 0, - annotationDispatcher = d3Dispatch.dispatch("subjectover", "subjectout", "subjectclick", "connectorover", "connectorout", "connectorclick", "noteover", "noteout", "noteclick"), - sel = void 0; - - var annotation = function annotation(selection) { - sel = selection; - //TODO: check to see if this is still needed - if (!editMode) { - selection.selectAll("circle.handle").remove(); - } + var annotation = group.selectAll('g.annotation'); - var translatedAnnotations = annotations.map(function (a) { - if (!a.type) { - a.type = type; - } - if (!a.disable) { - a.disable = disable; - } - return new Annotation(a); - }); - - collection = new AnnotationCollection({ - annotations: translatedAnnotations, - accessors: accessors, - accessorsInverse: accessorsInverse, - ids: ids - }); + annotation.each(function (d) { + var a = d3Selection.select(this); + var position = d.position; - var annotationG = selection.selectAll('g').data([collection]); - annotationG.enter().append('g').attr('class', 'annotations'); + a.attr('class', 'annotation'); - var group = selection.select('g.annotations'); - newWithClass(group, collection.annotations, 'g', 'annotation'); + newWithClass(a, [d], 'g', 'annotation-connector'); + newWithClass(a, [d], 'g', 'annotation-subject'); + newWithClass(a, [d], 'g', 'annotation-note'); + newWithClass(a.select('g.annotation-note'), [d], 'g', 'annotation-note-content'); - var annotation = group.selectAll('g.annotation'); - - annotation.each(function (d) { - var a = d3Selection.select(this); - var position = d.position; - - a.attr('class', 'annotation'); + d.type = new d.type({ a: a, annotation: d, textWrap: textWrap, notePadding: notePadding, editMode: editMode, + dispatcher: annotationDispatcher, accessors: accessors }); + d.type.draw(); + }); + }; - newWithClass(a, [d], 'g', 'annotation-connector'); - newWithClass(a, [d], 'g', 'annotation-subject'); - newWithClass(a, [d], 'g', 'annotation-note'); - newWithClass(a.select('g.annotation-note'), [d], 'g', 'annotation-note-content'); + annotation.json = function () { + console.log('Annotations JSON was copied to your clipboard. Please note the annotation type is not JSON compatible. It appears in the objects array in the console, but not in the copied JSON.', collection.json); + window.copy(JSON.stringify(collection.json.map(function (a) { + delete a.type;return a; + }))); + return annotation; + }; - d.type = new d.type({ a: a, annotation: d, textWrap: textWrap, notePadding: notePadding, editMode: editMode, - dispatcher: annotationDispatcher, accessors: accessors }); - d.type.draw(); + annotation.update = function () { + if (annotations && collection) { + annotations = collection.annotations.map(function (a, i) { + a.type.draw();return a; }); - }; - - annotation.json = function () { - console.log('Annotations JSON was copied to your clipboard. Please note the annotation type is not JSON compatible. It appears in the objects array in the console, but not in the copied JSON.', collection.json); - window.copy(JSON.stringify(collection.json.map(function (a) { - delete a.type;return a; - }))); - return annotation; - }; + } + return annotation; + }; - annotation.update = function () { - if (annotations && collection) { - annotations = collection.annotations.map(function (a, i) { - a.type.draw();return a; - }); - } - return annotation; - }; + annotation.updatedAccessors = function () { + collection.setPositionWithAccessors(); + annotations = collection.annotations; + return annotation; + }; - annotation.updatedAccessors = function () { - collection.setPositionWithAccessors(); + annotation.disable = function (_) { + if (!arguments.length) return disable; + disable = _; + if (collection) { + collection.updateDisable(disable); annotations = collection.annotations; - return annotation; - }; - - annotation.disable = function (_) { - if (!arguments.length) return disable; - disable = _; - if (collection) { - collection.updateDisable(disable); - annotations = collection.annotations; - } - return annotation; - }; - - annotation.textWrap = function (_) { - if (!arguments.length) return textWrap; - textWrap = _; - if (collection) { - collection.updateTextWrap(textWrap); - annotations = collection.annotations; - } - return annotation; - }; - - annotation.notePadding = function (_) { - if (!arguments.length) return notePadding; - notePadding = _; - if (collection) { - collection.updateNotePadding(notePadding); - annotations = collection.annotations; - } - return annotation; - }; + } + return annotation; + }; - annotation.type = function (_, settings) { - if (!arguments.length) return type; - type = _; - if (collection) { - collection.annotations.map(function (a) { - - a.type.note && a.type.note.selectAll("*:not(.annotation-note-content)").remove(); - a.type.noteContent && a.type.noteContent.selectAll("*").remove(); - a.type.subject && a.type.subject.selectAll("*").remove(); - a.type.connector && a.type.connector.selectAll("*").remove(); - a.type.typeSettings = {}; - a.type = type; - - a.subject = settings && settings.subject || a.subject; - a.connector = settings && settings.connector || a.connector; - a.note = settings && settings.note || a.note; - }); + annotation.textWrap = function (_) { + if (!arguments.length) return textWrap; + textWrap = _; + if (collection) { + collection.updateTextWrap(textWrap); + annotations = collection.annotations; + } + return annotation; + }; - annotations = collection.annotations; - } - return annotation; - }; + annotation.notePadding = function (_) { + if (!arguments.length) return notePadding; + notePadding = _; + if (collection) { + collection.updateNotePadding(notePadding); + annotations = collection.annotations; + } + return annotation; + }; - annotation.annotations = function (_) { - if (!arguments.length) return collection && collection.annotations || annotations; - annotations = _; - return annotation; - }; + annotation.type = function (_, settings) { + if (!arguments.length) return type; + type = _; + if (collection) { + collection.annotations.map(function (a) { + + a.type.note && a.type.note.selectAll("*:not(.annotation-note-content)").remove(); + a.type.noteContent && a.type.noteContent.selectAll("*").remove(); + a.type.subject && a.type.subject.selectAll("*").remove(); + a.type.connector && a.type.connector.selectAll("*").remove(); + a.type.typeSettings = {}; + a.type = type; + + a.subject = settings && settings.subject || a.subject; + a.connector = settings && settings.connector || a.connector; + a.note = settings && settings.note || a.note; + }); - annotation.context = function (_) { - if (!arguments.length) return context; - context = _; - return annotation; - }; + annotations = collection.annotations; + } + return annotation; + }; - annotation.accessors = function (_) { - if (!arguments.length) return accessors; - accessors = _; - return annotation; - }; + annotation.annotations = function (_) { + if (!arguments.length) return collection && collection.annotations || annotations; + annotations = _; + return annotation; + }; - annotation.accessorsInverse = function (_) { - if (!arguments.length) return accessorsInverse; - accessorsInverse = _; - return annotation; - }; + annotation.context = function (_) { + if (!arguments.length) return context; + context = _; + return annotation; + }; - annotation.ids = function (_) { - if (!arguments.length) return ids; - ids = _; - return annotation; - }; + annotation.accessors = function (_) { + if (!arguments.length) return accessors; + accessors = _; + return annotation; + }; - annotation.editMode = function (_) { - if (!arguments.length) return editMode; - editMode = _; + annotation.accessorsInverse = function (_) { + if (!arguments.length) return accessorsInverse; + accessorsInverse = _; + return annotation; + }; - if (sel) { - sel.selectAll('g.annotation').classed('editable', editMode); - } + annotation.ids = function (_) { + if (!arguments.length) return ids; + ids = _; + return annotation; + }; - if (collection) { - collection.editMode(editMode); - annotations = collection.annotations; - } - return annotation; - }; + annotation.editMode = function (_) { + if (!arguments.length) return editMode; + editMode = _; - annotation.collection = function (_) { - if (!arguments.length) return collection; - collection = _; - return annotation; - }; + if (sel) { + sel.selectAll('g.annotation').classed('editable', editMode); + } - annotation.on = function () { - var value = annotationDispatcher.on.apply(annotationDispatcher, arguments); - return value === annotationDispatcher ? annotation : value; - }; + if (collection) { + collection.editMode(editMode); + annotations = collection.annotations; + } + return annotation; + }; + annotation.collection = function (_) { + if (!arguments.length) return collection; + collection = _; return annotation; }; - var index = { - annotation: annotation, - annotationTypeBase: Type, - annotationLabel: d3Label, - annotationCallout: d3Callout, - annotationCalloutCurve: d3CalloutCurve, - annotationCalloutElbow: d3CalloutElbow, - annotationCalloutCircle: d3CalloutCircle, - annotationCalloutRect: d3CalloutRect, - annotationXYThreshold: d3XYThreshold, - annotationBadge: d3Badge, - annotationCustomType: customType + annotation.on = function () { + var value = annotationDispatcher.on.apply(annotationDispatcher, arguments); + return value === annotationDispatcher ? annotation : value; }; - exports.annotation = annotation; - exports.annotationTypeBase = Type; - exports.annotationLabel = d3Label; - exports.annotationCallout = d3Callout; - exports.annotationCalloutCurve = d3CalloutCurve; - exports.annotationCalloutElbow = d3CalloutElbow; - exports.annotationCalloutCircle = d3CalloutCircle; - exports.annotationCalloutRect = d3CalloutRect; - exports.annotationXYThreshold = d3XYThreshold; - exports.annotationBadge = d3Badge; - exports.annotationCustomType = customType; - exports['default'] = index; - - Object.defineProperty(exports, '__esModule', { value: true }); - -})); + return annotation; +} + +var index = { + annotation: annotation, + annotationTypeBase: Type, + annotationLabel: d3Label, + annotationCallout: d3Callout, + annotationCalloutCurve: d3CalloutCurve, + annotationCalloutElbow: d3CalloutElbow, + annotationCalloutCircle: d3CalloutCircle, + annotationCalloutRect: d3CalloutRect, + annotationXYThreshold: d3XYThreshold, + annotationBadge: d3Badge, + annotationCustomType: customType +}; + +exports.annotation = annotation; +exports.annotationTypeBase = Type; +exports.annotationLabel = d3Label; +exports.annotationCallout = d3Callout; +exports.annotationCalloutCurve = d3CalloutCurve; +exports.annotationCalloutElbow = d3CalloutElbow; +exports.annotationCalloutCircle = d3CalloutCircle; +exports.annotationCalloutRect = d3CalloutRect; +exports.annotationXYThreshold = d3XYThreshold; +exports.annotationBadge = d3Badge; +exports.annotationCustomType = customType; +exports['default'] = index; + +Object.defineProperty(exports, '__esModule', { value: true }); + +}))); //# sourceMappingURL=indexRollup.js.map diff --git a/indexRollup.js.map b/indexRollup.js.map index f3c7997..2b0ac5e 100644 --- a/indexRollup.js.map +++ b/indexRollup.js.map @@ -1 +1 @@ -{"version":3,"file":null,"sources":["src/Annotation.js","src/AnnotationCollection.js","src/Handles.js","src/Note/alignment.js","src/Builder.js","src/Note/lineType-vertical.js","src/Note/lineType-horizontal.js","src/Connector/type-line.js","src/Connector/type-elbow.js","src/Connector/type-curve.js","src/Connector/end-arrow.js","src/Connector/end-dot.js","src/Subject/circle.js","src/Subject/rect.js","src/Subject/threshold.js","src/Subject/badge.js","src/Types-d3.js","src/Adapter-d3.js","index.js"],"sourcesContent":["\nexport default class Annotation {\n constructor({ x=0, y=0, dy=0, dx=0, data, type, subject, connector, note, \n disable, id, className }) {\n\n this._dx = dx\n this._dy = dy \n this._x = x \n this._y = y\n this.id = id\n this._className = className || ''\n\n this.type = type || ''\n this.data = data\n\n this.note = note || {}\n this.connector = connector || {}\n this.subject = subject || {}\n\n this.disable = disable || []\n }\n\n updatePosition(){\n if (this.type.setPosition) { \n this.type.setPosition() \n if (this.type.subject.selectAll(':not(.handle)').nodes().length !== 0) {\n this.type.redrawSubject()\n }\n }\n }\n\n get className() { return this._className }\n\n set className(className){\n this._className = className\n if (this.type.setClassName) this.type.setClassName()\n }\n\n updateOffset(){\n if (this.type.setOffset) {\n this.type.setOffset() \n \n if (this.type.connector.selectAll(':not(.handle)').nodes().length !== 0) {\n this.type.redrawConnector()\n }\n\n this.type.redrawNote()\n }\n }\n\n get x() { return this._x }\n set x(x) { \n this._x = x; \n this.updatePosition()\n }\n\n get y() { return this._y }\n set y(y) { \n this._y = y; \n this.updatePosition()\n }\n\n get dx() { return this._dx }\n set dx(dx) { \n this._dx = dx; \n this.updateOffset()\n }\n\n get dy() { return this._dy }\n set dy(dy) { \n this._dy = dy; \n this.updateOffset()\n }\n\n get offset() { return { x: this._dx, y: this._dy }}\n\n set offset({ x, y }) {\n this._dx = x\n this._dy = y\n this.updateOffset()\n }\n\n get position() { return { x: this._x, y: this._y }}\n\n set position({ x, y }) {\n this._x = x\n this._y = y\n this.updatePosition()\n }\n\n get translation() {\n return {\n x: this._x + this._dx,\n y: this._y + this._dy\n }}\n\n get json() { \n const json = {\n x: this._x,\n y: this._y,\n dx: this._dx,\n dy: this._dy\n }\n\n if (this.data && Object.keys(this.data).length > 0) json.data = this.data\n if (this.type) json.type = this.type\n if (this._className) json.className = this._className\n\n if (Object.keys(this.connector).length > 0) json.connector = this.connector\n if (Object.keys(this.subject).length > 0) json.subject = this.subject\n if (Object.keys(this.note).length > 0) json.note = this.note\n \n return json\n }\n}","export default class AnnotationCollection {\n\n constructor({ annotations, accessors, accessorsInverse }) {\n this.accessors = accessors\n this.accessorsInverse = accessorsInverse\n this.annotations = annotations\n }\n\n clearTypes(newSettings) {\n this.annotations.forEach(d => {\n d.type = undefined\n d.subject = newSettings && newSettings.subject || d.subject\n d.connector = newSettings && newSettings.connector || d.connector\n d.note = newSettings && newSettings.note || d.note\n })\n }\n\n setPositionWithAccessors() {\n this.annotations.forEach(d => {\n d.type.setPositionWithAccessors(this.accessors)\n })\n }\n\n editMode(editMode) { this.annotations.forEach(a => {\n if (a.type) {\n a.type.editMode = editMode\n a.type.updateEditMode()\n }\n })\n }\n\n updateDisable(disable) {\n this.annotations.forEach(a => {\n a.disable = disable\n if (a.type){\n disable.forEach(d => {\n if (a.type[d]){\n a.type[d].remove && a.type[d].remove()\n a.type[d] = undefined\n }\n })\n }\n })\n }\n\n updateTextWrap(textWrap) {\n this.annotations.forEach(a => {\n if (a.type && a.type.updateTextWrap){\n a.type.updateTextWrap(textWrap)\n }\n })\n }\n\n updateNotePadding(notePadding) {\n this.annotations.forEach(a => {\n if (a.type){\n a.type.notePadding = notePadding\n }\n })\n }\n\n get json() { \n return this.annotations.map(a => { \n const json = a.json\n if (this.accessorsInverse && a.data){\n json.data = {}\n Object.keys(this.accessorsInverse).forEach(k => {\n json.data[k] = this.accessorsInverse[k]({ x: a.x, y: a.y})\n\n //TODO make this feasible to map back to data for other types of subjects\n })\n }\n return json\n })\n }\n\n get noteNodes(){\n return this.annotations.map(a => ({ ...a.type.getNoteBBoxOffset(), positionX: a.x, positionY: a.y }))\n }\n\n //TODO: come back and rethink if a.x and a.y are applicable in all situations\n // get connectorNodes() {\n // return this.annotations.map(a => ({ ...a.type.getConnectorBBox(), startX: a.x, startY: a.y}))\n // }\n\n // get subjectNodes() {\n // return this.annotations.map(a => ({ ...a.type.getSubjectBBox(), startX: a.x, startY: a.y}))\n // }\n\n // get annotationNodes() {\n // return this.annotations.map(a => ({ ...a.type.getAnnotationBBox(), startX: a.x, startY: a.y}))\n // }\n}\n","import { select } from 'd3-selection'\nimport { drag } from 'd3-drag'\n\n\nexport const pointHandle = ({ cx=0, cy=0 }) => {\n return { move: { x: cx, y: cy} }\n}\n\nexport const circleHandles = ({ cx=0, cy =0, r1, r2, padding }) => {\n const h = { move: { x: cx, y: cy}}\n \n if (r1 !== undefined) {\n h.r1 = { x: cx + r1/Math.sqrt(2), y: cy + r1/Math.sqrt(2) }\n }\n \n if (r2 !== undefined) {\n h.r2 = { x: cx + r2/Math.sqrt(2), y: cy + r2/Math.sqrt(2) }\n }\n\n if (padding !== undefined) {\n h.padding = { x: cx + r1 + padding, y: cy}\n }\n\n return h\n}\n\nexport const rectHandles = ({ x1=0, y1=0, x2=x1, y2=y1, width, height }) => {\n \n const w = width || Math.abs(x2 - x1)\n const h = height || Math.abs(y2 - y1)\n\n return {\n move: {\n x: Math.min(x1, x2) + w/2,\n y: Math.min(y1, y2) - 10\n },\n width: {\n x: Math.max(x1, x2),\n y: Math.min(y1, y2) + h/2\n },\n height: {\n x: Math.min(x1, x2) + w/2,\n y: Math.max(y1, y2)\n }\n }\n}\n\nexport const lineHandles = ({ x1, y1, x2, y2, x, y}) => {\n\n const minY = Math.min(y1, y2)\n const minX = Math.min(x1, x2)\n\n const height = Math.abs(y2 - y1)\n const width = Math.abs(x2 - x1)\n \n return {\n move: {\n x: x || minX + width/2,\n y: y || minY + height/2\n }\n }\n}\n\n//arc handles\nexport const addHandles = ({ group, handles, r=10}) => { \n //give it a group and x,y to draw handles\n //then give it instructions on what the handles change \n const h = group.selectAll('circle.handle')\n .data(handles)\n\n h.enter()\n .append('circle')\n .attr('class', 'handle')\n .call(drag()\n .container(select('g.annotations').node())\n .on('start', d => d.start && d.start(d))\n .on('drag', d => d.drag && d.drag(d))\n .on('end', d => d.end && d.end(d))\n )\n\n group.selectAll('circle.handle')\n .attr('cx', d => d.x)\n .attr('cy', d => d.y)\n .attr('r', d => d.r || r)\n .attr('class', d => `handle ${d.className || ''}`)\n\n h.exit()\n .remove()\n \n}\n\n","\nexport const leftRightDynamic = (align, y) => {\n if (align == \"dynamic\" || align == \"left\" || align == \"right\"){\n if (y < 0){ align = \"top\" }\n else { align = \"bottom\" } \n }\n return align\n}\n\nexport const topBottomDynamic = (align, x) => {\n if (align == \"dynamic\" || align == \"top\" || align == \"bottom\"){\n if (x < 0){ align = \"right\" }\n else { align = \"left\" } \n }\n return align\n}\n\n\nexport default ({ padding, bbox, align, orientation, offset }) => {\n let x = -bbox.x \n let y = -bbox.y\n\n if ( orientation === \"topBottom\" ){\n align = topBottomDynamic(align, offset.x)\n if (offset.y < 0){ \n y -= (bbox.height + padding)\n } else {\n y += padding\n }\n\n if ( align === \"middle\" ) {\n x -= bbox.width/2\n } else if (align === \"right\" ) {\n x -= (bbox.width)\n } \n\n } else if ( orientation === \"leftRight\" ){\n align = leftRightDynamic(align, offset.y)\n if (offset.x < 0){ \n x -= (bbox.width + padding) \n } else {\n x += padding\n }\n\n if ( align === \"middle\" ) {\n y -= bbox.height/2\n } else if (align === \"top\" ){\n y -= (bbox.height )\n }\n } \n\n return { x, y }\n}","import { line, arc, curveLinear, symbol, symbolTriangle } from \"d3-shape\"\n\nexport const lineBuilder = ({ data, curve=curveLinear, canvasContext, className }) => { \n const lineGen = line()\n .curve(curve)\n\n const builder = {\n type: 'path',\n className,\n data\n }\n\n if (canvasContext) {\n lineGen.context(canvasContext)\n builder.pathMethods = lineGen\n\n } else {\n builder.attrs = {\n d: lineGen(data)\n }\n }\n\n return builder\n}\n\nexport const arcBuilder = ({ data, canvasContext, className }) => {\n\n const builder = {\n type: 'path',\n className,\n data\n }\n\n const arcShape = arc()\n .innerRadius(data.innerRadius || 0)\n .outerRadius(data.outerRadius || data.radius || 2)\n .startAngle(data.startAngle || 0)\n .endAngle(data.endAngle || 2*Math.PI)\n\n if (canvasContext) {\n arcShape.context(canvasContext)\n builder.pathMethods = lineGen\n\n } else {\n \n builder.attrs = {\n d: arcShape()\n }\n }\n\n return builder\n}","import { lineBuilder } from '../Builder'\nimport { leftRightDynamic } from './alignment'\n\nexport default ({ align, x=0, y=0, bbox, offset, padding }) => {\n align = leftRightDynamic(align, offset.y)\n\n if (align == \"top\") { y -= bbox.height } \n else if (align == \"middle\"){ y -= bbox.height/2 }\n\n const data = [[x, y], [x, y + bbox.height]]\n return { components: [lineBuilder({ data, className : \"note-line\" })] }\n}","import { lineBuilder } from '../Builder'\nimport { topBottomDynamic } from './alignment'\n\nexport default ({ align, x=0, y=0, offset, bbox, padding }) => {\n align = topBottomDynamic(align, offset.x)\n\n if (align == \"right\") { x -= bbox.width }\n else if (align == \"middle\"){ x -= bbox.width/2 }\n\n const data = [[x, y], [x + bbox.width, y]]\n return { components: [lineBuilder({ data, className : \"note-line\" })] }\n}","import { lineBuilder } from '../Builder'\n\nexport const lineSetup = ({ type, subjectType }) => {\n let annotation = type.annotation\n let offset = annotation.position\n \n let x1 = annotation.x - offset.x,\n x2 = x1 + annotation.dx,\n y1 = annotation.y - offset.y,\n y2 = y1 + annotation.dy\n\n\n const subjectData = annotation.subject\n\n if (subjectType == \"circle\" && (subjectData.outerRadius || subjectData.radius)){\n const h = Math.sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2))\n const angle = Math.asin(-y2/h)\n const r = subjectData.outerRadius || subjectData.radius + (subjectData.radiusPadding || 0)\n\n x1 = Math.abs(Math.cos(angle)*r)*(x2 < 0 ? -1 : 1)\n y1 = Math.abs(Math.sin(angle)*r)*(y2 < 0 ? -1 : 1)\n\n }\n\n if (subjectType == \"rect\"){\n const { width, height } = subjectData\n \n if ((width > 0 && annotation.dx > 0) || (width < 0 && annotation.dx < 0)) {\n if (Math.abs(width) > Math.abs(annotation.dx)) x1 = width/2\n else x1 = width\n } \n if ((height > 0 && annotation.dy > 0) || (height < 0 && annotation.dy < 0)) {\n if (Math.abs(height) > Math.abs(annotation.dy)) y1 = height/2\n else y1 = height\n }\n if (x1 == width/2 && y1 == height/2){ x1 = x2; y1 = y2;}\n }\n\n\n return [[x1, y1], [x2, y2]]\n}\n\nexport default (connectorData) => {\n const data = lineSetup(connectorData)\n return { components: [lineBuilder({ data, className : \"connector\" })]} \n}","import { lineBuilder } from '../Builder'\n\nexport default ({ type, subjectType }) => {\n\n const annotation = type.annotation\n const offset = annotation.position\n\n let x1 = annotation.x - offset.x,\n x2 = x1 + annotation.dx,\n y1 = annotation.y - offset.y,\n y2 = y1 + annotation.dy\n\n const subjectData = annotation.subject\n\n if (subjectType == \"rect\"){\n const { width, height } = subjectData\n \n if ((width > 0 && annotation.dx > 0) || (width < 0 && annotation.dx < 0)) {\n if (Math.abs(width) > Math.abs(annotation.dx)) x1 = width/2\n else x1 = width\n } \n if ((height > 0 && annotation.dy > 0) || (height < 0 && annotation.dy < 0)) {\n if (Math.abs(height) > Math.abs(annotation.dy)) y1 = height/2\n else y1 = height\n }\n if (x1 == width/2 && y1 == height/2){ x1 = x2; y1 = y2;}\n }\n\n let data = [[x1, y1], [x2, y2]]\n\n let diffY = (y2 - y1)\n let diffX = (x2 - x1)\n let xe = x2 \n let ye = y2\n let opposite = (y2 < y1 && x2 > x1 || x2 < x1 && y2 > y1)? -1 : 1\n\n if (Math.abs(diffX) < Math.abs(diffY)){\n xe = x2\n ye = y1 + diffX*opposite\n } else {\n ye = y2\n xe = x1 + diffY*opposite\n }\n \n if (subjectType == \"circle\" && (subjectData.outerRadius || subjectData.radius)){\n const r = (subjectData.outerRadius || subjectData.radius) + (subjectData.radiusPadding || 0)\n const length = r/Math.sqrt(2)\n\n if (Math.abs(diffX) > length && Math.abs(diffY) > length){\n x1 = length*(x2 < 0 ? -1 : 1)\n y1 = length*(y2 < 0 ? -1 : 1)\n data = [[x1, y1], [xe , ye ], [x2, y2]]\n\n } else if (Math.abs(diffX) > Math.abs(diffY)){\n const angle = Math.asin(-y2/r)\n x1 = Math.abs(Math.cos(angle)*r)*(x2 < 0 ? -1 : 1)\n data = [[ x1, y2], [x2, y2]]\n } else {\n const angle = Math.acos(x2/r)\n y1 = Math.abs(Math.sin(angle)*r)*(y2 < 0 ? -1 : 1)\n data = [[ x2, y1], [x2, y2]]\n }\n } else {\n data = [[x1, y1], [xe , ye], [x2, y2]]\n }\n\n return { components: [lineBuilder({ data, className: \"connector\"})]}\n}\n","import { lineBuilder } from '../Builder'\nimport { event } from 'd3-selection'\nimport { lineSetup } from './type-line'\nimport { curveCatmullRom } from 'd3-shape'\nimport { pointHandle } from '../Handles'\n\nexport default ({ type, connectorData, subjectType }) => {\n\n if (!connectorData){ connectorData = {} }\n if (!connectorData.points || typeof connectorData.points === \"number\"){ \n connectorData.points = createPoints(type.annotation.offset, connectorData.points) \n }\n if (!connectorData.curve){ connectorData.curve = curveCatmullRom }\n\n let handles = []\n\n if (type.editMode) {\n const cHandles = connectorData.points\n .map((c,i) => ({...pointHandle({cx: c[0], cy: c[1]}), index: i}))\n\n const updatePoint = (index) => { \n connectorData.points[index][0] += event.dx\n connectorData.points[index][1] += event.dy\n type.redrawConnector()\n }\n \n handles = type.mapHandles(cHandles\n .map(h => ({ ...h.move, drag: updatePoint.bind(type, h.index)})))\n\n }\n\n let data = lineSetup({ type, subjectType })\n data = [data[0], ...connectorData.points, data[1]]\n const components = [lineBuilder({ data, curve: connectorData.curve, className: \"connector\" })]\n\n return { components , handles }\n}\n\nconst createPoints = function( offset, anchors=2){\n const diff = { x: offset.x/(anchors + 1), y: offset.y/(anchors + 1) }\n const p = []\n\n let i = 1 \n for (; i <= anchors; i++){\n p.push([diff.x*i + i%2*20, diff.y*i - i%2*20])\n }\n return p\n}","import { lineBuilder } from '../Builder'\n\nexport default ({ annotation, start, end }) => {\n const offset = annotation.position\n if (!start) { start = [annotation.dx, annotation.dy]} \n else { start = [-end[0] + start[0], - end[1] + start[1]]}\n if (!end) { end = [annotation.x - offset.x, annotation.y - offset.y]}\n\n let x1 = end[0],\n y1 = end[1];\n\n let dx = start[0] \n let dy = start[1] \n\n let size = 10;\n let angleOffset = 16/180*Math.PI\n let angle = Math.atan(dy/dx) \n\n if (dx < 0 ) {\n angle += Math.PI\n }\n\n const data = [[x1, y1], \n [Math.cos(angle + angleOffset)*size + x1, Math.sin(angle + angleOffset)*size + y1],\n [Math.cos(angle - angleOffset)*size + x1, Math.sin(angle - angleOffset)*size + y1],\n [x1, y1]]\n\n //TODO add in reverse\n // if (canvasContext.arrowReverse){\n // data = [[x1, y1], \n // [Math.cos(angle + angleOffset)*size, Math.sin(angle + angleOffset)*size],\n // [Math.cos(angle - angleOffset)*size, Math.sin(angle - angleOffset)*size],\n // [x1, y1]\n // ]\n // } else {\n // data = [[x1, y1], \n // [Math.cos(angle + angleOffset)*size, Math.sin(angle + angleOffset)*size],\n // [Math.cos(angle - angleOffset)*size, Math.sin(angle - angleOffset)*size],\n // [x1, y1]\n // ]\n // }\n\n return { components: [lineBuilder({ data, className : 'connector-arrow' })] }\n}\n","import { arcBuilder } from '../Builder'\n\nexport default ({ line }) => {\n \n let dot = arcBuilder({ className: 'connector-dot', data: { radius: 3} })\n dot.attrs.transform = `translate(${line.data[0][0]}, ${line.data[0][1]})`\n \n return { components: [dot] }\n}\n","import { circleHandles } from '../Handles'\nimport { arcBuilder } from '../Builder'\nimport { event } from 'd3-selection'\n\nexport default ({ subjectData, type}) => {\n if (!subjectData.radius && !subjectData.outerRadius ){ subjectData.radius = 20 }\n\n let handles = []\n const c = arcBuilder({ data: subjectData, className: \"subject\" })\n if (type.editMode){\n const h = circleHandles({\n r1: c.data.outerRadius || c.data.radius,\n r2: c.data.innerRadius,\n padding: subjectData.radiusPadding\n })\n\n const updateRadius = (attr) => { \n const r = subjectData[attr] + event.dx*Math.sqrt(2)\n subjectData[attr] = r\n type.redrawSubject()\n type.redrawConnector()\n }\n\n const cHandles = [\n { ...h.r1, drag: updateRadius.bind(type, subjectData.outerRadius !== undefined ? 'outerRadius': 'radius')}\n ]\n\n if (subjectData.innerRadius){\n cHandles.push({ ...h.r2, drag: updateRadius.bind(type, 'innerRadius')})\n }\n handles = type.mapHandles(cHandles)\n }\n\n return { components: [c], handles }\n}","import { circleHandles } from '../Handles'\nimport { lineBuilder } from '../Builder'\nimport { event } from 'd3-selection'\n\nexport default ({ subjectData, type}) => {\n if (!subjectData.width){ subjectData.width = 100 }\n if (!subjectData.height){ subjectData.height = 100 }\n\n let handles = []\n let { width, height } = subjectData\n\n const data = [[0, 0], \n [ width, 0], \n [ width, height], \n [0, height],\n [0, 0]]\n let rect = lineBuilder({ data, className : 'subject'})\n\n if (type.editMode){\n\n const updateWidth = (attr) => { \n subjectData.width = event.x\n type.redrawSubject()\n type.redrawConnector()\n }\n\n const updateHeight = () => {\n subjectData.height = event.y\n type.redrawSubject()\n type.redrawConnector()\n }\n\n const rHandles = [{ x: width, y: height/2, drag: updateWidth.bind(type) },\n { x: width/2, y: height, drag: updateHeight.bind(type) }\n ]\n\n handles = type.mapHandles(rHandles)\n\n }\n\n return { components: [rect], handles }\n}","import { circleHandles } from '../Handles'\nimport { lineBuilder } from '../Builder'\n\n\nexport default ({ subjectData, type }) => {\n const offset = type.annotation.position\n\n let x1 = (subjectData.x1 !== undefined ? subjectData.x1 : offset.x) - offset.x,\n x2 = (subjectData.x2 !== undefined ? subjectData.x2 : offset.x) - offset.x,\n y1 = (subjectData.y1 !== undefined ? subjectData.y1 : offset.y) - offset.y,\n y2 = (subjectData.y2 !== undefined ? subjectData.y2 : offset.y) - offset.y\n\n const data = [[x1, y1], [x2, y2]]\n return { components: [lineBuilder({ data, className : 'subject'})]}\n}","import { circleHandles } from '../Handles'\nimport { lineBuilder, arcBuilder } from '../Builder'\nimport { event } from 'd3-selection'\n\nexport default ({ subjectData, type }) => {\n if (!subjectData.radius ) subjectData.radius = 14\n if (!subjectData.x) subjectData.x =\"left\"\n if (!subjectData.y) subjectData.y = \"top\"\n\n let handles = []\n const radius = subjectData.radius\n const innerRadius = radius*.7\n const x = subjectData.x == \"left\" ? -radius : radius\n const y = subjectData.y == \"top\" ? -radius : radius\n const transform = `translate(${x}, ${y})`\n const circlebg = arcBuilder({ className: 'subject', data: { radius} }) \n circlebg.attrs.transform = transform\n\n const circle = arcBuilder({ className: 'subject-ring', data: { outerRadius: radius, innerRadius} })\n circle.attrs.transform = transform\n\n const pointer = lineBuilder({ className: 'subject-pointer',\n data: [[0, 0], [x, 0], [0, y], [0, 0]]\n })\n\n if (type.editMode){\n\n const dragBadge = () => {\n subjectData.x = event.x < 0 ? \"left\" : \"right\"\n subjectData.y = event.y < 0 ? \"top\" : \"bottom\"\n type.redrawSubject()\n }\n\n const bHandles = [{ x: x*2, y: y*2, drag: dragBadge.bind(type)}]\n handles = type.mapHandles(bHandles)\n\n }\n\n let text\n if (subjectData.text){\n text = {\n type: \"text\",\n className: \"badge-text\",\n attrs: {\n text: subjectData.text,\n \"text-anchor\": \"middle\",\n dy: \".25em\",\n x,\n y\n }\n }\n }\n return { components: [pointer, circlebg, circle, text], handles }\n}","import { select, event } from 'd3-selection'\nimport { drag } from 'd3-drag'\nimport { Annotation } from './Annotation'\nimport { addHandles } from './Handles'\n\n//Note options\nimport noteAlignment from './Note/alignment'\nimport noteVertical from './Note/lineType-vertical'\nimport noteHorizontal from './Note/lineType-horizontal'\n\n//Connector options\nimport connectorLine from './Connector/type-line'\nimport connectorElbow from './Connector/type-elbow'\nimport connectorCurve from './Connector/type-curve'\nimport connectorArrow from './Connector/end-arrow'\nimport connectorDot from './Connector/end-dot'\n\n//Subject options\nimport subjectCircle from './Subject/circle'\nimport subjectRect from './Subject/rect'\nimport subjectThreshold from './Subject/threshold'\nimport subjectBadge from './Subject/badge'\n\nexport class Type {\n constructor({ a, annotation, editMode, dispatcher, notePadding, accessors }) {\n this.a = a\n\n this.note = annotation.disable.indexOf(\"note\") === -1 && a.select('g.annotation-note')\n this.noteContent = this.note && a.select('g.annotation-note-content')\n this.connector = annotation.disable.indexOf(\"connector\") === -1 && a.select('g.annotation-connector')\n this.subject = annotation.disable.indexOf(\"subject\") === -1 && a.select('g.annotation-subject')\n\n if (dispatcher){\n const handler = addHandlers.bind(null, dispatcher, annotation)\n handler({ component: this.note, name: 'note' })\n handler({ component: this.connector, name: 'connector' })\n handler({ component: this.subject, name: 'subject' })\n }\n \n this.annotation = annotation\n this.editMode = annotation.editMode || editMode\n this.notePadding = notePadding || 3\n this.offsetCornerX = 0\n this.offsetCornerY = 0\n\n if (accessors && annotation.data){\n this.init(accessors)\n }\n }\n\n init(accessors) {\n if (!this.annotation.x){\n this.mapX(accessors)\n }\n if (!this.annotation.y){\n this.mapY(accessors)\n }\n }\n\n mapY(accessors){\n if (accessors.y){\n this.annotation.y = accessors.y(this.annotation.data)\n }\n }\n\n mapX(accessors) {\n if (accessors.x){\n this.annotation.x = accessors.x(this.annotation.data)\n }\n }\n\n\n updateEditMode () {\n this.a.selectAll('circle.handle')\n .remove()\n }\n\n drawOnSVG (component, builders) {\n if (!Array.isArray(builders)){\n builders = [ builders ]\n }\n\n builders\n .filter(b => b)\n .forEach(({ type, className, attrs, handles}) => {\n if (type === \"handle\"){\n addHandles({ group: component, r: attrs && attrs.r, handles })\n } else {\n newWithClass(component, [this.annotation], type, className)\n \n const el = component.select(`${type}.${className}`) \n const attrKeys = Object.keys(attrs)\n attrKeys.forEach(attr => {\n if (attr === \"text\"){\n el.text(attrs[attr])\n } else {\n el.attr(attr, attrs[attr])\n }\n })\n }\n })\n }\n\n //TODO: how to extend this to a drawOnCanvas mode? \n\n getNoteBBox() { return bboxWithoutHandles(this.note, '.annotation-note-content text')}\n getNoteBBoxOffset() { \n const bbox = bboxWithoutHandles(this.note, '.annotation-note-content')\n const transform = this.noteContent.attr('transform').split(/\\(|\\,|\\)/g)\n bbox.offsetCornerX = parseFloat(transform[1]) + this.annotation.dx\n bbox.offsetCornerY = parseFloat(transform[2]) + this.annotation.dy\n bbox.offsetX = this.annotation.dx\n bbox.offsetY = this.annotation.dy\n return bbox \n }\n\n // getConnectorBBox() { return bboxWithoutHandles(this.connector)}\n // getSubjectBBox() { return bboxWithoutHandles(this.subject)}\n // getAnnotationBBox() { return bboxWithoutHandles(this.a)}\n\n drawSubject (context={}) {\n const subjectData = this.annotation.subject\n const type = context.type\n const subjectParams = { type: this, subjectData}\n\n let subject = {}\n if (type === \"circle\") subject = subjectCircle(subjectParams)\n else if (type === \"rect\") subject = subjectRect(subjectParams)\n else if (type === \"threshold\") subject = subjectThreshold(subjectParams)\n else if (type === \"badge\") subject = subjectBadge(subjectParams)\n\n let { components=[], handles=[] } = subject\n if (this.editMode){\n handles = handles.concat(this.mapHandles([{ drag: this.dragSubject.bind(this)}]))\n components.push({ type: \"handle\", handles })\n }\n\n return components\n }\n\n drawConnector (context={}) {\n const connectorData = this.annotation.connector\n const type = connectorData.type || context.type\n const connectorParams = { type: this, connectorData}\n connectorParams.subjectType = this.typeSettings && this.typeSettings.subject && this.typeSettings.subject.type \n\n let connector = {}\n if (type === \"curve\") connector = connectorCurve(connectorParams)\n else if (type === \"elbow\") connector = connectorElbow(connectorParams)\n else connector = connectorLine(connectorParams)\n\n let { components=[], handles=[] } = connector\n const line = components[0]\n const endType = connectorData.end || context.end\n let end = {}\n if (endType === \"arrow\") {\n let s = line.data[1]\n const e = line.data[0]\n const distance = Math.sqrt(Math.pow((s[0] - e[0]),2) + Math.pow((s[1] - e[1]),2))\n if (distance < 5 && line.data[2]) {\n s = line.data[2]\n }\n\n end = connectorArrow({ annotation: this.annotation, start: s, end: e })\n } else if (endType === \"dot\") {\n end = connectorDot({ line })\n }\n\n if (end.components){ components = components.concat(end.components)}\n\n if (this.editMode){\n if (handles.length !== 0) components.push({ type: \"handle\", handles })\n }\n return components;\n }\n\n drawNote (context={}) {\n const noteData = this.annotation.note\n const align = noteData.align || context.align || 'dynamic'\n const noteParams = { bbox: context.bbox, align, offset: this.annotation.offset }\n const lineType = noteData.lineType || context.lineType\n let note={}\n if (lineType == \"vertical\") note = noteVertical(noteParams)\n else if (lineType == \"horizontal\") note = noteHorizontal(noteParams)\n\n let { components=[], handles=[] } = note\n if (this.editMode) {\n handles = this.mapHandles([{ x: 0, y: 0, drag: this.dragNote.bind(this)}])\n components.push({ type: \"handle\", handles })\n }\n return components\n }\n\n drawNoteContent (context) {\n const noteData = this.annotation.note\n const padding = noteData.padding || this.notePadding\n let orientation = noteData.orientation || context.orientation || 'topBottom'\n const lineType = noteData.lineType || context.lineType\n const align = noteData.align || context.align || 'dynamic'\n const subjectType = this.typeSettings && this.typeSettings.subject && this.typeSettings.subject.type \n \n if (lineType == \"vertical\") orientation = \"leftRight\"\n else if (lineType == \"horizontal\") orientation = \"topBottom\"\n\n const noteParams = { padding, bbox: context.bbox, offset: \n this.annotation.offset, orientation, align }\n\n const { x, y } = noteAlignment(noteParams)\n this.offsetCornerX = x + this.annotation.dx\n this.offsetCornerY = y + this.annotation.dy\n this.note && this.noteContent.attr('transform', `translate(${x}, ${y})`)\n \n return []\n } \n\n drawOnScreen(component, drawFunction) { return this.drawOnSVG( component, drawFunction) }\n\n redrawSubject(){\n this.subject && this.drawOnScreen( this.subject, this.drawSubject())\n }\n\n redrawConnector(bbox=this.getNoteBBox()){\n this.connector && this.drawOnScreen( this.connector, this.drawConnector())\n }\n\n redrawNote(bbox=this.getNoteBBox()){\n this.noteContent && this.drawOnScreen( this.noteContent, this.drawNoteContent({ bbox }))\n this.note && this.drawOnScreen( this.note, this.drawNote({ bbox })) \n }\n\n setPosition(){\n const position = this.annotation.position \n this.a.attr('transform', `translate(${position.x}, ${position.y})`)\n }\n\n setOffset(){\n if (this.note){\n const offset = this.annotation.offset\n this.note.attr('transform', `translate(${offset.x}, ${offset.y})`)\n }\n }\n\n setPositionWithAccessors(accessors){\n if (accessors && this.annotation.data){\n this.mapX(accessors)\n this.mapY(accessors)\n }\n this.setPosition()\n }\n\n\n setClassName(){\n this.a.attr(\"class\", `annotation ${this.className && this.className()} ${this.editMode ? \"editable\" : \"\"} ${this.annotation.className || ''}`)\n }\n\n draw() {\n this.setClassName()\n this.setPosition()\n this.setOffset()\n this.redrawSubject()\n this.redrawConnector()\n this.redrawNote()\n }\n\n dragstarted() { event.sourceEvent.stopPropagation(); \n this.a.classed(\"dragging\", true) \n this.a.selectAll(\"circle.handle\").style(\"pointer-events\", \"none\")\n }\n dragended() { \n this.a.classed(\"dragging\", false)\n this.a.selectAll(\"circle.handle\").style(\"pointer-events\", \"all\")\n }\n\n dragSubject() {\n const position = this.annotation.position\n position.x += event.dx\n position.y += event.dy\n this.annotation.position = position\n }\n\n dragNote() {\n const offset = this.annotation.offset\n offset.x += event.dx\n offset.y += event.dy\n this.annotation.offset = offset\n }\n\n mapHandles(handles) {\n return handles\n .map(h => ({ ...h, \n start: this.dragstarted.bind(this), end: this.dragended.bind(this) }))\n }\n}\n\nexport const customType = (initialType, typeSettings, init) => {\n return class customType extends initialType {\n constructor (settings) {\n super(settings)\n this.typeSettings = typeSettings\n\n if (typeSettings.disable){\n typeSettings.disable.forEach(d => {\n this[d] = undefined\n if (d == \"note\"){\n this.noteContent = undefined\n }\n })\n }\n }\n\n static init(annotation, accessors){ \n super.init(annotation, accessors); \n if (init) {\n annotation = init(annotation, accessors) \n }\n return annotation\n }\n\n className(){ return `${typeSettings.className || ''} ${super.className && super.className() || ''}`}\n\n drawSubject(context){\n this.typeSettings.subject = Object.assign({}, typeSettings.subject, this.typeSettings.subject)\n return super.drawSubject({ ...context, ...this.typeSettings.subject })\n }\n\n drawConnector(context, subjectContext){\n this.typeSettings.connector = Object.assign({}, typeSettings.connector, this.typeSettings.connector)\n return super.drawConnector({ ...context, ...typeSettings.connector, ...this.typeSettings.connector })\n }\n\n drawNote(context){\n this.typeSettings.note = Object.assign({}, typeSettings.note, this.typeSettings.note)\n return super.drawNote({ ...context, ...typeSettings.note, ...this.typeSettings.note })\n }\n\n drawNoteContent(context){\n return super.drawNoteContent({ ...context, ...typeSettings.note, ...this.typeSettings.note })\n }\n }\n}\n\nexport class d3NoteText extends Type {\n\n constructor(params){\n super(params)\n this.textWrap = params.textWrap || 120\n this.drawText()\n }\n\n updateTextWrap (textWrap) {\n this.textWrap = textWrap\n this.drawText()\n }\n\n //TODO: add update text functionality\n\n drawText () {\n if (this.note){\n \n newWithClass(this.note, [this.annotation], 'g', 'annotation-note-content')\n\n const noteContent = this.note.select('g.annotation-note-content')\n newWithClass(noteContent, [this.annotation], 'rect', 'annotation-note-bg')\n newWithClass(noteContent, [this.annotation], 'text', 'annotation-note-label')\n newWithClass(noteContent, [this.annotation], 'text', 'annotation-note-title')\n\n let titleBBox = { height: 0 }\n const label = this.a.select('text.annotation-note-label')\n const wrapLength = this.annotation.note && this.annotation.note.wrap || \n this.typeSettings && this.typeSettings.note && this.typeSettings.note.wrap ||\n this.textWrap \n\n if (this.annotation.note.title){\n const title = this.a.select('text.annotation-note-title')\n title.text(this.annotation.note.title)\n .attr('dy', '1.1em')\n title.call(wrap, wrapLength)\n titleBBox = title.node().getBBox()\n }\n\n label.text(this.annotation.note.label)\n .attr('dy', '1em')\n label.call(wrap, wrapLength)\n\n label.attr('y', titleBBox.height * 1.1 || 0)\n\n const bbox = this.getNoteBBox()\n this.a.select('rect.annotation-note-bg')\n .attr('width', bbox.width)\n .attr('height', bbox.height)\n }\n }\n}\n\nexport const d3Label = customType(d3NoteText, {\n className: \"label\", \n note: { align: \"middle\"}\n})\n\nexport const d3Callout = customType(d3NoteText, {\n className: \"callout\",\n note: { lineType: \"horizontal\" }\n})\n\nexport const d3CalloutElbow = customType(d3Callout, {\n className: \"callout elbow\",\n connector: { type: \"elbow\" }\n})\n\nexport const d3CalloutCurve = customType(d3Callout, {\n className: \"callout curve\",\n connector: { type: \"curve\" }\n})\n\nexport const d3Badge = customType(Type, {\n className: \"badge\",\n subject: { type: \"badge\"},\n disable: ['connector', 'note']\n})\n\n\nexport const d3CalloutCircle = customType(d3CalloutElbow, {\n className: \"callout circle\",\n subject: { type: \"circle\"}\n})\n\nexport const d3CalloutRect = customType(d3CalloutElbow, {\n className: \"callout rect\",\n subject: { type: \"rect\"}\n})\n\n\nclass ThresholdMap extends d3Callout {\n\n mapY(accessors){\n super.mapY(accessors)\n const a = this.annotation\n if ((a.subject.x1 || a.subject.x2) && a.data && accessors.y){\n a.y = accessors.y(a.data)\n }\n }\n\n mapX(accessors) {\n super.mapX(accessors)\n const a = this.annotation\n if ((a.subject.y1 || a.subject.y2) && a.data && accessors.x){\n a.x = accessors.x(a.data)\n }\n }\n}\n\nexport const d3XYThreshold = customType(ThresholdMap, {\n className: \"callout xythreshold\",\n subject: { type: \"threshold\"}\n})\n\n\n\nexport const newWithClass = (a, d, type, className) => {\n const group = a.selectAll(`${type}.${className}`).data(d)\n group.enter()\n .append(type)\n .merge(group)\n .attr('class', className)\n\n group.exit().remove()\n return a\n}\n\n\nconst addHandlers = ( dispatcher, annotation, { component, name }) => {\n if (component){\n component\n .on(\"mouseover.annotations\", () => {\n dispatcher.call(`${name}over`, component, annotation)})\n .on(\"mouseout.annotations\", () => dispatcher.call(`${name}out`, component, annotation))\n .on(\"click.annotations\", () => dispatcher.call(`${name}click`, component, annotation))\n }\n}\n\n//Text wrapping code adapted from Mike Bostock\nconst wrap = (text, width) => {\n text.each(function() {\n var text = select(this),\n words = text.text().split(/[ \\t\\r\\n]+/).reverse(),\n word,\n line = [],\n lineNumber = 0,\n lineHeight = .2, //ems\n y = text.attr(\"y\"),\n dy = parseFloat(text.attr(\"dy\")) || 0,\n tspan = text.text(null)\n .append(\"tspan\")\n .attr(\"x\", 0)\n .attr(\"dy\", dy + \"em\");\n\n while (word = words.pop()) {\n line.push(word);\n tspan.text(line.join(\" \"));\n if (tspan.node().getComputedTextLength() > width && line.length > 1) {\n line.pop();\n tspan.text(line.join(\" \"));\n line = [word];\n tspan = text.append(\"tspan\")\n .attr(\"x\", 0)\n .attr(\"dy\", lineHeight + dy + \"em\").text(word);\n }\n }\n });\n}\n\nconst bboxWithoutHandles = (selection, selector=':not(.handle)') => {\n if (!selection){\n return { x: 0, y: 0, width: 0, height: 0}\n }\n\n return selection.selectAll(selector).nodes().reduce((p, c) => {\n const bbox = c.getBBox()\n p.x = Math.min(p.x, bbox.x)\n p.y = Math.min(p.y, bbox.y)\n p.width = Math.max(p.width, bbox.width)\n p.height += bbox.height\n return p\n }, { x: 0, y: 0, width: 0, height: 0});\n}\n\nexport default {\n Type,\n d3Label,\n d3Callout,\n d3CalloutElbow,\n d3CalloutCurve,\n d3CalloutCircle,\n d3CalloutRect,\n d3XYThreshold,\n d3Badge,\n customType\n}\n","import Annotation from './Annotation'\nimport AnnotationCollection from './AnnotationCollection'\nimport { newWithClass, d3Callout } from './Types-d3'\nimport { select } from 'd3-selection'\nimport { dispatch } from 'd3-dispatch';\n\n\nexport default function annotation(){\n let annotations = [],\n collection,\n context, //TODO: add canvas functionality\n disable = [],\n accessors = {},\n accessorsInverse = {},\n editMode = false,\n ids,\n type = d3Callout,\n textWrap,\n notePadding,\n annotationDispatcher = dispatch(\n \"subjectover\", \"subjectout\", \"subjectclick\", \n \"connectorover\", \"connectorout\", \"connectorclick\", \n \"noteover\", \"noteout\", \"noteclick\"),\n sel;\n\n const annotation = function(selection){\n sel = selection\n //TODO: check to see if this is still needed \n if (!editMode){\n selection.selectAll(\"circle.handle\")\n .remove()\n }\n\n const translatedAnnotations = annotations\n .map(a => {\n if (!a.type) { a.type = type }\n if (!a.disable) {a.disable = disable}\n return new Annotation(a)\n });\n\n collection = new AnnotationCollection ({\n annotations: translatedAnnotations,\n accessors,\n accessorsInverse,\n ids\n })\n \n\n const annotationG = selection.selectAll('g').data([collection])\n annotationG.enter().append('g').attr('class', `annotations`)\n \n const group = selection.select('g.annotations')\n newWithClass(group, collection.annotations, 'g', 'annotation')\n\n const annotation = group.selectAll('g.annotation')\n \n annotation \n .each(function(d) {\n const a = select(this)\n const position = d.position\n\n a.attr('class', 'annotation')\n\n newWithClass(a, [d], 'g', 'annotation-connector')\n newWithClass(a, [d], 'g', 'annotation-subject')\n newWithClass(a, [d], 'g', 'annotation-note')\n newWithClass(a.select('g.annotation-note'), [d], 'g', 'annotation-note-content')\n\n d.type = new d.type({ a, annotation: d, textWrap, notePadding, editMode, \n dispatcher: annotationDispatcher, accessors })\n d.type.draw()\n })\n }\n\n annotation.json = function() {\n console.log('Annotations JSON was copied to your clipboard. Please note the annotation type is not JSON compatible. It appears in the objects array in the console, but not in the copied JSON.', collection.json)\n window.copy(JSON.stringify(collection.json.map(a => { delete a.type; return a })))\n return annotation\n }\n\n annotation.update = function(){\n if (annotations && collection){\n annotations = collection.annotations.map((a, i) => { a.type.draw(); return a }) \n }\n return annotation\n }\n\n annotation.updatedAccessors = function(){\n collection.setPositionWithAccessors()\n annotations = collection.annotations\n return annotation\n }\n\n annotation.disable = function(_){\n if (!arguments.length) return disable;\n disable = _\n if (collection) { \n collection.updateDisable(disable)\n annotations = collection.annotations\n }\n return annotation;\n }\n\n annotation.textWrap = function(_){\n if (!arguments.length) return textWrap;\n textWrap = _\n if (collection) { \n collection.updateTextWrap(textWrap)\n annotations = collection.annotations\n }\n return annotation;\n }\n\n annotation.notePadding = function(_){\n if (!arguments.length) return notePadding;\n notePadding = _\n if (collection) { \n collection.updateNotePadding(notePadding)\n annotations = collection.annotations\n }\n return annotation;\n }\n\n annotation.type = function(_, settings) {\n if (!arguments.length) return type;\n type = _;\n if (collection) { \n collection.annotations.map(a => {\n \n a.type.note && a.type.note.selectAll(\"*:not(.annotation-note-content)\").remove()\n a.type.noteContent && a.type.noteContent.selectAll(\"*\").remove()\n a.type.subject && a.type.subject.selectAll(\"*\").remove()\n a.type.connector && a.type.connector.selectAll(\"*\").remove()\n a.type.typeSettings = {}\n a.type = type\n\n a.subject = settings && settings.subject || a.subject\n a.connector = settings && settings.connector || a.connector\n a.note = settings && settings.note || a.note\n })\n\n annotations = collection.annotations\n }\n return annotation;\n }\n\n annotation.annotations = function(_) {\n if (!arguments.length) return collection && collection.annotations || annotations;\n annotations = _\n return annotation;\n };\n\n annotation.context = function(_) {\n if (!arguments.length) return context;\n context = _\n return annotation;\n }; \n\n annotation.accessors = function(_) {\n if (!arguments.length) return accessors;\n accessors = _;\n return annotation\n }\n\n annotation.accessorsInverse = function(_) {\n if (!arguments.length) return accessorsInverse;\n accessorsInverse = _;\n return annotation\n }\n\n annotation.ids = function(_) {\n if (!arguments.length) return ids;\n ids = _;\n return annotation\n }\n\n annotation.editMode = function(_) {\n if (!arguments.length) return editMode;\n editMode = _\n\n if (sel){\n sel.selectAll('g.annotation')\n .classed('editable', editMode)\n }\n\n if (collection) { \n collection.editMode(editMode)\n annotations = collection.annotations\n }\n return annotation\n }\n\n annotation.collection = function(_) {\n if (!arguments.length) return collection;\n collection = _\n return annotation\n }\n\n annotation.on = function(){\n const value = annotationDispatcher.on.apply(annotationDispatcher, arguments)\n return value === annotationDispatcher ? annotation : value;\n }\n\n return annotation;\n\n};","import annotation from './src/Adapter-d3'\nimport { Type, d3Label, d3Callout, d3CalloutCurve, d3CalloutElbow, d3CalloutCircle, \n d3CalloutRect, d3XYThreshold, d3Badge, customType } from './src/Types-d3'\n\nexport {\n annotation,\n Type as annotationTypeBase ,\n d3Label as annotationLabel ,\n d3Callout as annotationCallout ,\n d3CalloutCurve as annotationCalloutCurve ,\n d3CalloutElbow as annotationCalloutElbow ,\n d3CalloutCircle as annotationCalloutCircle ,\n d3CalloutRect as annotationCalloutRect ,\n d3XYThreshold as annotationXYThreshold ,\n d3Badge as annotationBadge ,\n customType as annotationCustomType \n}\n\nexport default {\n annotation,\n annotationTypeBase : Type,\n annotationLabel : d3Label,\n annotationCallout : d3Callout,\n annotationCalloutCurve : d3CalloutCurve,\n annotationCalloutElbow : d3CalloutElbow,\n annotationCalloutCircle : d3CalloutCircle,\n annotationCalloutRect : d3CalloutRect,\n annotationXYThreshold : d3XYThreshold,\n annotationBadge : d3Badge,\n annotationCustomType : customType\n}"],"names":["Annotation","x","y","dy","dx","data","type","subject","connector","note","disable","id","className","_dx","_dy","_x","_y","_className","setPosition","selectAll","nodes","length","redrawSubject","setOffset","redrawConnector","redrawNote","setClassName","updatePosition","updateOffset","json","Object","keys","AnnotationCollection","annotations","accessors","accessorsInverse","newSettings","forEach","d","undefined","setPositionWithAccessors","editMode","a","updateEditMode","remove","textWrap","updateTextWrap","notePadding","map","k","getNoteBBoxOffset","positionX","positionY","pointHandle","cx","cy","move","circleHandles","r1","r2","padding","h","Math","sqrt","addHandles","group","handles","r","enter","append","attr","call","drag","container","select","node","on","start","end","exit","leftRightDynamic","align","topBottomDynamic","bbox","orientation","offset","height","width","lineBuilder","curve","curveLinear","canvasContext","lineGen","line","builder","context","pathMethods","attrs","arcBuilder","arcShape","arc","innerRadius","outerRadius","radius","startAngle","endAngle","PI","components","lineSetup","subjectType","annotation","position","x1","x2","y1","y2","subjectData","angle","asin","radiusPadding","abs","cos","sin","connectorData","diffY","diffX","xe","ye","opposite","acos","points","createPoints","curveCatmullRom","cHandles","c","i","index","updatePoint","event","mapHandles","bind","anchors","diff","p","push","size","angleOffset","atan","dot","transform","updateRadius","rect","updateWidth","updateHeight","rHandles","circlebg","circle","pointer","dragBadge","bHandles","text","Type","dispatcher","indexOf","noteContent","handler","addHandlers","component","name","offsetCornerX","offsetCornerY","init","mapX","mapY","builders","Array","isArray","filter","b","newWithClass","el","attrKeys","bboxWithoutHandles","split","parseFloat","offsetX","offsetY","subjectParams","subjectCircle","subjectRect","subjectThreshold","subjectBadge","concat","dragSubject","connectorParams","typeSettings","connectorCurve","connectorElbow","connectorLine","endType","s","e","distance","pow","connectorArrow","connectorDot","noteData","noteParams","lineType","noteVertical","noteHorizontal","dragNote","noteAlignment","drawFunction","drawOnSVG","drawOnScreen","drawSubject","getNoteBBox","drawConnector","drawNoteContent","drawNote","sourceEvent","stopPropagation","classed","style","dragstarted","dragended","customType","initialType","settings","babelHelpers.get","assign","subjectContext","d3NoteText","params","drawText","titleBBox","label","wrapLength","wrap","title","getBBox","d3Label","d3Callout","d3CalloutElbow","d3CalloutCurve","d3Badge","d3CalloutCircle","d3CalloutRect","ThresholdMap","d3XYThreshold","merge","each","words","reverse","word","lineNumber","lineHeight","tspan","pop","join","getComputedTextLength","selection","selector","reduce","min","max","collection","ids","annotationDispatcher","dispatch","sel","translatedAnnotations","annotationG","draw","console","log","window","copy","JSON","stringify","update","updatedAccessors","_","arguments","updateDisable","updateNotePadding","value","apply","annotationTypeBase","annotationLabel","annotationCallout","annotationCalloutCurve","annotationCalloutElbow","annotationCalloutCircle","annotationCalloutRect","annotationXYThreshold","annotationBadge","annot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WlO,QAAX,CAAoBA,QAApB;AACAR,EAAAA,oBAAc0O,WAAW1O,WAAzB;AACD,EAAA;AACD,EAAA,WAAO6E,UAAP;AACD,EAAA,GAdD;;AAgBAA,EAAAA,aAAW6J,UAAX,GAAwB,UAASgB,CAAT,EAAY;AAClC,EAAA,QAAI,CAACC,UAAUvQ,MAAf,EAAuB,OAAOsP,UAAP;AACvBA,EAAAA,iBAAagB,CAAb;AACA,EAAA,WAAO7K,UAAP;AACD,EAAA,GAJD;;AAMAA,EAAAA,aAAWlC,EAAX,GAAgB,YAAU;AACxB,EAAA,QAAMmN,QAAQlB,qBAAqBjM,EAArB,CAAwBoN,KAAxB,CAA8BnB,oBAA9B,EAAoDe,SAApD,CAAd;AACA,EAAA,WAAOG,UAAUlB,oBAAV,GAAiC/J,UAAjC,GAA8CiL,KAArD;AACD,EAAA,GAHD;;AAKA,EAAA,SAAOjL,UAAP;AAED,EAAA;;AC3LD,cAAe;AACbA,EAAAA,wBADa;AAEbmL,EAAAA,sBAAqBhI,IAFR;AAGbiI,EAAAA,mBAAkBhD,OAHL;AAIbiD,EAAAA,qBAAoBhD,SAJP;AAKbiD,EAAAA,0BAAyB/C,cALZ;AAMbgD,EAAAA,0BAAyBjD,cANZ;AAObkD,EAAAA,2BAA0B/C,eAPb;AAQbgD,EAAAA,yBAAwB/C,aARX;AASbgD,EAAAA,yBAAwB9C,aATX;AAUb+C,EAAAA,mBAAkBnD,OAVL;AAWboD,EAAAA,wBAAuBvE;AAXV,EAAA,CAAf;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"indexRollup.js","sources":["src/Annotation.js","src/AnnotationCollection.js","src/Handles.js","src/Note/alignment.js","src/Builder.js","src/Note/lineType-vertical.js","src/Note/lineType-horizontal.js","src/Connector/type-line.js","src/Connector/type-elbow.js","src/Connector/type-curve.js","src/Connector/end-arrow.js","src/Connector/end-dot.js","src/Subject/circle.js","src/Subject/rect.js","src/Subject/threshold.js","src/Subject/badge.js","src/Types-d3.js","src/Adapter-d3.js","index.js"],"sourcesContent":["\nexport default class Annotation {\n constructor({ x=0, y=0, dy=0, dx=0, data, type, subject, connector, note, \n disable, id, className }) {\n\n this._dx = dx\n this._dy = dy \n this._x = x \n this._y = y\n this.id = id\n this._className = className || ''\n\n this.type = type || ''\n this.data = data\n\n this.note = note || {}\n this.connector = connector || {}\n this.subject = subject || {}\n\n this.disable = disable || []\n }\n\n updatePosition(){\n if (this.type.setPosition) { \n this.type.setPosition() \n if (this.type.subject.selectAll(':not(.handle)').nodes().length !== 0) {\n this.type.redrawSubject()\n }\n }\n }\n\n get className() { return this._className }\n\n set className(className){\n this._className = className\n if (this.type.setClassName) this.type.setClassName()\n }\n\n updateOffset(){\n if (this.type.setOffset) {\n this.type.setOffset() \n \n if (this.type.connector.selectAll(':not(.handle)').nodes().length !== 0) {\n this.type.redrawConnector()\n }\n\n this.type.redrawNote()\n }\n }\n\n get x() { return this._x }\n set x(x) { \n this._x = x; \n this.updatePosition()\n }\n\n get y() { return this._y }\n set y(y) { \n this._y = y; \n this.updatePosition()\n }\n\n get dx() { return this._dx }\n set dx(dx) { \n this._dx = dx; \n this.updateOffset()\n }\n\n get dy() { return this._dy }\n set dy(dy) { \n this._dy = dy; \n this.updateOffset()\n }\n\n get offset() { return { x: this._dx, y: this._dy }}\n\n set offset({ x, y }) {\n this._dx = x\n this._dy = y\n this.updateOffset()\n }\n\n get position() { return { x: this._x, y: this._y }}\n\n set position({ x, y }) {\n this._x = x\n this._y = y\n this.updatePosition()\n }\n\n get translation() {\n return {\n x: this._x + this._dx,\n y: this._y + this._dy\n }}\n\n get json() { \n const json = {\n x: this._x,\n y: this._y,\n dx: this._dx,\n dy: this._dy\n }\n\n if (this.data && Object.keys(this.data).length > 0) json.data = this.data\n if (this.type) json.type = this.type\n if (this._className) json.className = this._className\n\n if (Object.keys(this.connector).length > 0) json.connector = this.connector\n if (Object.keys(this.subject).length > 0) json.subject = this.subject\n if (Object.keys(this.note).length > 0) json.note = this.note\n \n return json\n }\n}","export default class AnnotationCollection {\n\n constructor({ annotations, accessors, accessorsInverse }) {\n this.accessors = accessors\n this.accessorsInverse = accessorsInverse\n this.annotations = annotations\n }\n\n clearTypes(newSettings) {\n this.annotations.forEach(d => {\n d.type = undefined\n d.subject = newSettings && newSettings.subject || d.subject\n d.connector = newSettings && newSettings.connector || d.connector\n d.note = newSettings && newSettings.note || d.note\n })\n }\n\n setPositionWithAccessors() {\n this.annotations.forEach(d => {\n d.type.setPositionWithAccessors(this.accessors)\n })\n }\n\n editMode(editMode) { this.annotations.forEach(a => {\n if (a.type) {\n a.type.editMode = editMode\n a.type.updateEditMode()\n }\n })\n }\n\n updateDisable(disable) {\n this.annotations.forEach(a => {\n a.disable = disable\n if (a.type){\n disable.forEach(d => {\n if (a.type[d]){\n a.type[d].remove && a.type[d].remove()\n a.type[d] = undefined\n }\n })\n }\n })\n }\n\n updateTextWrap(textWrap) {\n this.annotations.forEach(a => {\n if (a.type && a.type.updateTextWrap){\n a.type.updateTextWrap(textWrap)\n }\n })\n }\n\n updateNotePadding(notePadding) {\n this.annotations.forEach(a => {\n if (a.type){\n a.type.notePadding = notePadding\n }\n })\n }\n\n get json() { \n return this.annotations.map(a => { \n const json = a.json\n if (this.accessorsInverse && a.data){\n json.data = {}\n Object.keys(this.accessorsInverse).forEach(k => {\n json.data[k] = this.accessorsInverse[k]({ x: a.x, y: a.y})\n\n //TODO make this feasible to map back to data for other types of subjects\n })\n }\n return json\n })\n }\n\n get noteNodes(){\n return this.annotations.map(a => ({ ...a.type.getNoteBBoxOffset(), positionX: a.x, positionY: a.y }))\n }\n\n //TODO: come back and rethink if a.x and a.y are applicable in all situations\n // get connectorNodes() {\n // return this.annotations.map(a => ({ ...a.type.getConnectorBBox(), startX: a.x, startY: a.y}))\n // }\n\n // get subjectNodes() {\n // return this.annotations.map(a => ({ ...a.type.getSubjectBBox(), startX: a.x, startY: a.y}))\n // }\n\n // get annotationNodes() {\n // return this.annotations.map(a => ({ ...a.type.getAnnotationBBox(), startX: a.x, startY: a.y}))\n // }\n}\n","import { select } from 'd3-selection'\nimport { drag } from 'd3-drag'\n\n\nexport const pointHandle = ({ cx=0, cy=0 }) => {\n return { move: { x: cx, y: cy} }\n}\n\nexport const circleHandles = ({ cx=0, cy =0, r1, r2, padding }) => {\n const h = { move: { x: cx, y: cy}}\n \n if (r1 !== undefined) {\n h.r1 = { x: cx + r1/Math.sqrt(2), y: cy + r1/Math.sqrt(2) }\n }\n \n if (r2 !== undefined) {\n h.r2 = { x: cx + r2/Math.sqrt(2), y: cy + r2/Math.sqrt(2) }\n }\n\n if (padding !== undefined) {\n h.padding = { x: cx + r1 + padding, y: cy}\n }\n\n return h\n}\n\nexport const rectHandles = ({ x1=0, y1=0, x2=x1, y2=y1, width, height }) => {\n \n const w = width || Math.abs(x2 - x1)\n const h = height || Math.abs(y2 - y1)\n\n return {\n move: {\n x: Math.min(x1, x2) + w/2,\n y: Math.min(y1, y2) - 10\n },\n width: {\n x: Math.max(x1, x2),\n y: Math.min(y1, y2) + h/2\n },\n height: {\n x: Math.min(x1, x2) + w/2,\n y: Math.max(y1, y2)\n }\n }\n}\n\nexport const lineHandles = ({ x1, y1, x2, y2, x, y}) => {\n\n const minY = Math.min(y1, y2)\n const minX = Math.min(x1, x2)\n\n const height = Math.abs(y2 - y1)\n const width = Math.abs(x2 - x1)\n \n return {\n move: {\n x: x || minX + width/2,\n y: y || minY + height/2\n }\n }\n}\n\n//arc handles\nexport const addHandles = ({ group, handles, r=10}) => { \n //give it a group and x,y to draw handles\n //then give it instructions on what the handles change \n const h = group.selectAll('circle.handle')\n .data(handles)\n\n h.enter()\n .append('circle')\n .attr('class', 'handle')\n .call(drag()\n .container(select('g.annotations').node())\n .on('start', d => d.start && d.start(d))\n .on('drag', d => d.drag && d.drag(d))\n .on('end', d => d.end && d.end(d))\n )\n\n group.selectAll('circle.handle')\n .attr('cx', d => d.x)\n .attr('cy', d => d.y)\n .attr('r', d => d.r || r)\n .attr('class', d => `handle ${d.className || ''}`)\n\n h.exit()\n .remove()\n \n}\n\n","\nexport const leftRightDynamic = (align, y) => {\n if (align == \"dynamic\" || align == \"left\" || align == \"right\"){\n if (y < 0){ align = \"top\" }\n else { align = \"bottom\" } \n }\n return align\n}\n\nexport const topBottomDynamic = (align, x) => {\n if (align == \"dynamic\" || align == \"top\" || align == \"bottom\"){\n if (x < 0){ align = \"right\" }\n else { align = \"left\" } \n }\n return align\n}\n\n\nexport default ({ padding, bbox, align, orientation, offset }) => {\n let x = -bbox.x \n let y = -bbox.y\n\n if ( orientation === \"topBottom\" ){\n align = topBottomDynamic(align, offset.x)\n if (offset.y < 0){ \n y -= (bbox.height + padding)\n } else {\n y += padding\n }\n\n if ( align === \"middle\" ) {\n x -= bbox.width/2\n } else if (align === \"right\" ) {\n x -= (bbox.width)\n } \n\n } else if ( orientation === \"leftRight\" ){\n align = leftRightDynamic(align, offset.y)\n if (offset.x < 0){ \n x -= (bbox.width + padding) \n } else {\n x += padding\n }\n\n if ( align === \"middle\" ) {\n y -= bbox.height/2\n } else if (align === \"top\" ){\n y -= (bbox.height )\n }\n } \n\n return { x, y }\n}","import { line, arc, curveLinear, symbol, symbolTriangle } from \"d3-shape\"\n\nexport const lineBuilder = ({ data, curve=curveLinear, canvasContext, className }) => { \n const lineGen = line()\n .curve(curve)\n\n const builder = {\n type: 'path',\n className,\n data\n }\n\n if (canvasContext) {\n lineGen.context(canvasContext)\n builder.pathMethods = lineGen\n\n } else {\n builder.attrs = {\n d: lineGen(data)\n }\n }\n\n return builder\n}\n\nexport const arcBuilder = ({ data, canvasContext, className }) => {\n\n const builder = {\n type: 'path',\n className,\n data\n }\n\n const arcShape = arc()\n .innerRadius(data.innerRadius || 0)\n .outerRadius(data.outerRadius || data.radius || 2)\n .startAngle(data.startAngle || 0)\n .endAngle(data.endAngle || 2*Math.PI)\n\n if (canvasContext) {\n arcShape.context(canvasContext)\n builder.pathMethods = lineGen\n\n } else {\n \n builder.attrs = {\n d: arcShape()\n }\n }\n\n return builder\n}","import { lineBuilder } from '../Builder'\nimport { leftRightDynamic } from './alignment'\n\nexport default ({ align, x=0, y=0, bbox, offset, padding }) => {\n align = leftRightDynamic(align, offset.y)\n\n if (align == \"top\") { y -= bbox.height } \n else if (align == \"middle\"){ y -= bbox.height/2 }\n\n const data = [[x, y], [x, y + bbox.height]]\n return { components: [lineBuilder({ data, className : \"note-line\" })] }\n}","import { lineBuilder } from '../Builder'\nimport { topBottomDynamic } from './alignment'\n\nexport default ({ align, x=0, y=0, offset, bbox, padding }) => {\n align = topBottomDynamic(align, offset.x)\n\n if (align == \"right\") { x -= bbox.width }\n else if (align == \"middle\"){ x -= bbox.width/2 }\n\n const data = [[x, y], [x + bbox.width, y]]\n return { components: [lineBuilder({ data, className : \"note-line\" })] }\n}","import { lineBuilder } from '../Builder'\n\nexport const lineSetup = ({ type, subjectType }) => {\n let annotation = type.annotation\n let offset = annotation.position\n \n let x1 = annotation.x - offset.x,\n x2 = x1 + annotation.dx,\n y1 = annotation.y - offset.y,\n y2 = y1 + annotation.dy\n\n\n const subjectData = annotation.subject\n\n if (subjectType == \"circle\" && (subjectData.outerRadius || subjectData.radius)){\n const h = Math.sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2))\n const angle = Math.asin(-y2/h)\n const r = subjectData.outerRadius || subjectData.radius + (subjectData.radiusPadding || 0)\n\n x1 = Math.abs(Math.cos(angle)*r)*(x2 < 0 ? -1 : 1)\n y1 = Math.abs(Math.sin(angle)*r)*(y2 < 0 ? -1 : 1)\n\n }\n\n if (subjectType == \"rect\"){\n const { width, height } = subjectData\n \n if ((width > 0 && annotation.dx > 0) || (width < 0 && annotation.dx < 0)) {\n if (Math.abs(width) > Math.abs(annotation.dx)) x1 = width/2\n else x1 = width\n } \n if ((height > 0 && annotation.dy > 0) || (height < 0 && annotation.dy < 0)) {\n if (Math.abs(height) > Math.abs(annotation.dy)) y1 = height/2\n else y1 = height\n }\n if (x1 == width/2 && y1 == height/2){ x1 = x2; y1 = y2;}\n }\n\n\n return [[x1, y1], [x2, y2]]\n}\n\nexport default (connectorData) => {\n const data = lineSetup(connectorData)\n return { components: [lineBuilder({ data, className : \"connector\" })]} \n}","import { lineBuilder } from '../Builder'\n\nexport default ({ type, subjectType }) => {\n\n const annotation = type.annotation\n const offset = annotation.position\n\n let x1 = annotation.x - offset.x,\n x2 = x1 + annotation.dx,\n y1 = annotation.y - offset.y,\n y2 = y1 + annotation.dy\n\n const subjectData = annotation.subject\n\n if (subjectType == \"rect\"){\n const { width, height } = subjectData\n \n if ((width > 0 && annotation.dx > 0) || (width < 0 && annotation.dx < 0)) {\n if (Math.abs(width) > Math.abs(annotation.dx)) x1 = width/2\n else x1 = width\n } \n if ((height > 0 && annotation.dy > 0) || (height < 0 && annotation.dy < 0)) {\n if (Math.abs(height) > Math.abs(annotation.dy)) y1 = height/2\n else y1 = height\n }\n if (x1 == width/2 && y1 == height/2){ x1 = x2; y1 = y2;}\n }\n\n let data = [[x1, y1], [x2, y2]]\n\n let diffY = (y2 - y1)\n let diffX = (x2 - x1)\n let xe = x2 \n let ye = y2\n let opposite = (y2 < y1 && x2 > x1 || x2 < x1 && y2 > y1)? -1 : 1\n\n if (Math.abs(diffX) < Math.abs(diffY)){\n xe = x2\n ye = y1 + diffX*opposite\n } else {\n ye = y2\n xe = x1 + diffY*opposite\n }\n \n if (subjectType == \"circle\" && (subjectData.outerRadius || subjectData.radius)){\n const r = (subjectData.outerRadius || subjectData.radius) + (subjectData.radiusPadding || 0)\n const length = r/Math.sqrt(2)\n\n if (Math.abs(diffX) > length && Math.abs(diffY) > length){\n x1 = length*(x2 < 0 ? -1 : 1)\n y1 = length*(y2 < 0 ? -1 : 1)\n data = [[x1, y1], [xe , ye ], [x2, y2]]\n\n } else if (Math.abs(diffX) > Math.abs(diffY)){\n const angle = Math.asin(-y2/r)\n x1 = Math.abs(Math.cos(angle)*r)*(x2 < 0 ? -1 : 1)\n data = [[ x1, y2], [x2, y2]]\n } else {\n const angle = Math.acos(x2/r)\n y1 = Math.abs(Math.sin(angle)*r)*(y2 < 0 ? -1 : 1)\n data = [[ x2, y1], [x2, y2]]\n }\n } else {\n data = [[x1, y1], [xe , ye], [x2, y2]]\n }\n\n return { components: [lineBuilder({ data, className: \"connector\"})]}\n}\n","import { lineBuilder } from '../Builder'\nimport { event } from 'd3-selection'\nimport { lineSetup } from './type-line'\nimport { curveCatmullRom } from 'd3-shape'\nimport { pointHandle } from '../Handles'\n\nexport default ({ type, connectorData, subjectType }) => {\n\n if (!connectorData){ connectorData = {} }\n if (!connectorData.points || typeof connectorData.points === \"number\"){ \n connectorData.points = createPoints(type.annotation.offset, connectorData.points) \n }\n if (!connectorData.curve){ connectorData.curve = curveCatmullRom }\n\n let handles = []\n\n if (type.editMode) {\n const cHandles = connectorData.points\n .map((c,i) => ({...pointHandle({cx: c[0], cy: c[1]}), index: i}))\n\n const updatePoint = (index) => { \n connectorData.points[index][0] += event.dx\n connectorData.points[index][1] += event.dy\n type.redrawConnector()\n }\n \n handles = type.mapHandles(cHandles\n .map(h => ({ ...h.move, drag: updatePoint.bind(type, h.index)})))\n\n }\n\n let data = lineSetup({ type, subjectType })\n data = [data[0], ...connectorData.points, data[1]]\n const components = [lineBuilder({ data, curve: connectorData.curve, className: \"connector\" })]\n\n return { components , handles }\n}\n\nconst createPoints = function( offset, anchors=2){\n const diff = { x: offset.x/(anchors + 1), y: offset.y/(anchors + 1) }\n const p = []\n\n let i = 1 \n for (; i <= anchors; i++){\n p.push([diff.x*i + i%2*20, diff.y*i - i%2*20])\n }\n return p\n}","import { lineBuilder } from '../Builder'\n\nexport default ({ annotation, start, end }) => {\n const offset = annotation.position\n if (!start) { start = [annotation.dx, annotation.dy]} \n else { start = [-end[0] + start[0], - end[1] + start[1]]}\n if (!end) { end = [annotation.x - offset.x, annotation.y - offset.y]}\n\n let x1 = end[0],\n y1 = end[1];\n\n let dx = start[0] \n let dy = start[1] \n\n let size = 10;\n let angleOffset = 16/180*Math.PI\n let angle = Math.atan(dy/dx) \n\n if (dx < 0 ) {\n angle += Math.PI\n }\n\n const data = [[x1, y1], \n [Math.cos(angle + angleOffset)*size + x1, Math.sin(angle + angleOffset)*size + y1],\n [Math.cos(angle - angleOffset)*size + x1, Math.sin(angle - angleOffset)*size + y1],\n [x1, y1]]\n\n //TODO add in reverse\n // if (canvasContext.arrowReverse){\n // data = [[x1, y1], \n // [Math.cos(angle + angleOffset)*size, Math.sin(angle + angleOffset)*size],\n // [Math.cos(angle - angleOffset)*size, Math.sin(angle - angleOffset)*size],\n // [x1, y1]\n // ]\n // } else {\n // data = [[x1, y1], \n // [Math.cos(angle + angleOffset)*size, Math.sin(angle + angleOffset)*size],\n // [Math.cos(angle - angleOffset)*size, Math.sin(angle - angleOffset)*size],\n // [x1, y1]\n // ]\n // }\n\n return { components: [lineBuilder({ data, className : 'connector-arrow' })] }\n}\n","import { arcBuilder } from '../Builder'\n\nexport default ({ line }) => {\n \n let dot = arcBuilder({ className: 'connector-dot', data: { radius: 3} })\n dot.attrs.transform = `translate(${line.data[0][0]}, ${line.data[0][1]})`\n \n return { components: [dot] }\n}\n","import { circleHandles } from '../Handles'\nimport { arcBuilder } from '../Builder'\nimport { event } from 'd3-selection'\n\nexport default ({ subjectData, type}) => {\n if (!subjectData.radius && !subjectData.outerRadius ){ subjectData.radius = 20 }\n\n let handles = []\n const c = arcBuilder({ data: subjectData, className: \"subject\" })\n if (type.editMode){\n const h = circleHandles({\n r1: c.data.outerRadius || c.data.radius,\n r2: c.data.innerRadius,\n padding: subjectData.radiusPadding\n })\n\n const updateRadius = (attr) => { \n const r = subjectData[attr] + event.dx*Math.sqrt(2)\n subjectData[attr] = r\n type.redrawSubject()\n type.redrawConnector()\n }\n\n const cHandles = [\n { ...h.r1, drag: updateRadius.bind(type, subjectData.outerRadius !== undefined ? 'outerRadius': 'radius')}\n ]\n\n if (subjectData.innerRadius){\n cHandles.push({ ...h.r2, drag: updateRadius.bind(type, 'innerRadius')})\n }\n handles = type.mapHandles(cHandles)\n }\n\n return { components: [c], handles }\n}","import { circleHandles } from '../Handles'\nimport { lineBuilder } from '../Builder'\nimport { event } from 'd3-selection'\n\nexport default ({ subjectData, type}) => {\n if (!subjectData.width){ subjectData.width = 100 }\n if (!subjectData.height){ subjectData.height = 100 }\n\n let handles = []\n let { width, height } = subjectData\n\n const data = [[0, 0], \n [ width, 0], \n [ width, height], \n [0, height],\n [0, 0]]\n let rect = lineBuilder({ data, className : 'subject'})\n\n if (type.editMode){\n\n const updateWidth = (attr) => { \n subjectData.width = event.x\n type.redrawSubject()\n type.redrawConnector()\n }\n\n const updateHeight = () => {\n subjectData.height = event.y\n type.redrawSubject()\n type.redrawConnector()\n }\n\n const rHandles = [{ x: width, y: height/2, drag: updateWidth.bind(type) },\n { x: width/2, y: height, drag: updateHeight.bind(type) }\n ]\n\n handles = type.mapHandles(rHandles)\n\n }\n\n return { components: [rect], handles }\n}","import { circleHandles } from '../Handles'\nimport { lineBuilder } from '../Builder'\n\n\nexport default ({ subjectData, type }) => {\n const offset = type.annotation.position\n\n let x1 = (subjectData.x1 !== undefined ? subjectData.x1 : offset.x) - offset.x,\n x2 = (subjectData.x2 !== undefined ? subjectData.x2 : offset.x) - offset.x,\n y1 = (subjectData.y1 !== undefined ? subjectData.y1 : offset.y) - offset.y,\n y2 = (subjectData.y2 !== undefined ? subjectData.y2 : offset.y) - offset.y\n\n const data = [[x1, y1], [x2, y2]]\n return { components: [lineBuilder({ data, className : 'subject'})]}\n}","import { circleHandles } from '../Handles'\nimport { lineBuilder, arcBuilder } from '../Builder'\nimport { event } from 'd3-selection'\n\nexport default ({ subjectData, type }) => {\n if (!subjectData.radius ) subjectData.radius = 14\n if (!subjectData.x) subjectData.x =\"left\"\n if (!subjectData.y) subjectData.y = \"top\"\n\n let handles = []\n const radius = subjectData.radius\n const innerRadius = radius*.7\n const x = subjectData.x == \"left\" ? -radius : radius\n const y = subjectData.y == \"top\" ? -radius : radius\n const transform = `translate(${x}, ${y})`\n const circlebg = arcBuilder({ className: 'subject', data: { radius} }) \n circlebg.attrs.transform = transform\n\n const circle = arcBuilder({ className: 'subject-ring', data: { outerRadius: radius, innerRadius} })\n circle.attrs.transform = transform\n\n const pointer = lineBuilder({ className: 'subject-pointer',\n data: [[0, 0], [x, 0], [0, y], [0, 0]]\n })\n\n if (type.editMode){\n\n const dragBadge = () => {\n subjectData.x = event.x < 0 ? \"left\" : \"right\"\n subjectData.y = event.y < 0 ? \"top\" : \"bottom\"\n type.redrawSubject()\n }\n\n const bHandles = [{ x: x*2, y: y*2, drag: dragBadge.bind(type)}]\n handles = type.mapHandles(bHandles)\n\n }\n\n let text\n if (subjectData.text){\n text = {\n type: \"text\",\n className: \"badge-text\",\n attrs: {\n text: subjectData.text,\n \"text-anchor\": \"middle\",\n dy: \".25em\",\n x,\n y\n }\n }\n }\n return { components: [pointer, circlebg, circle, text], handles }\n}","import { select, event } from 'd3-selection'\nimport { drag } from 'd3-drag'\nimport { addHandles } from './Handles'\n\n//Note options\nimport noteAlignment from './Note/alignment'\nimport noteVertical from './Note/lineType-vertical'\nimport noteHorizontal from './Note/lineType-horizontal'\n\n//Connector options\nimport connectorLine from './Connector/type-line'\nimport connectorElbow from './Connector/type-elbow'\nimport connectorCurve from './Connector/type-curve'\nimport connectorArrow from './Connector/end-arrow'\nimport connectorDot from './Connector/end-dot'\n\n//Subject options\nimport subjectCircle from './Subject/circle'\nimport subjectRect from './Subject/rect'\nimport subjectThreshold from './Subject/threshold'\nimport subjectBadge from './Subject/badge'\n\nexport class Type {\n constructor({ a, annotation, editMode, dispatcher, notePadding, accessors }) {\n this.a = a\n\n this.note = annotation.disable.indexOf(\"note\") === -1 && a.select('g.annotation-note')\n this.noteContent = this.note && a.select('g.annotation-note-content')\n this.connector = annotation.disable.indexOf(\"connector\") === -1 && a.select('g.annotation-connector')\n this.subject = annotation.disable.indexOf(\"subject\") === -1 && a.select('g.annotation-subject')\n\n if (dispatcher){\n const handler = addHandlers.bind(null, dispatcher, annotation)\n handler({ component: this.note, name: 'note' })\n handler({ component: this.connector, name: 'connector' })\n handler({ component: this.subject, name: 'subject' })\n }\n \n this.annotation = annotation\n this.editMode = annotation.editMode || editMode\n this.notePadding = notePadding || 3\n this.offsetCornerX = 0\n this.offsetCornerY = 0\n\n if (accessors && annotation.data){\n this.init(accessors)\n }\n }\n\n init(accessors) {\n if (!this.annotation.x){\n this.mapX(accessors)\n }\n if (!this.annotation.y){\n this.mapY(accessors)\n }\n }\n\n mapY(accessors){\n if (accessors.y){\n this.annotation.y = accessors.y(this.annotation.data)\n }\n }\n\n mapX(accessors) {\n if (accessors.x){\n this.annotation.x = accessors.x(this.annotation.data)\n }\n }\n\n\n updateEditMode () {\n this.a.selectAll('circle.handle')\n .remove()\n }\n\n drawOnSVG (component, builders) {\n if (!Array.isArray(builders)){\n builders = [ builders ]\n }\n\n builders\n .filter(b => b)\n .forEach(({ type, className, attrs, handles}) => {\n if (type === \"handle\"){\n addHandles({ group: component, r: attrs && attrs.r, handles })\n } else {\n newWithClass(component, [this.annotation], type, className)\n \n const el = component.select(`${type}.${className}`) \n const attrKeys = Object.keys(attrs)\n attrKeys.forEach(attr => {\n if (attr === \"text\"){\n el.text(attrs[attr])\n } else {\n el.attr(attr, attrs[attr])\n }\n })\n }\n })\n }\n\n //TODO: how to extend this to a drawOnCanvas mode? \n\n getNoteBBox() { return bboxWithoutHandles(this.note, '.annotation-note-content text')}\n getNoteBBoxOffset() { \n const bbox = bboxWithoutHandles(this.note, '.annotation-note-content')\n const transform = this.noteContent.attr('transform').split(/\\(|\\,|\\)/g)\n bbox.offsetCornerX = parseFloat(transform[1]) + this.annotation.dx\n bbox.offsetCornerY = parseFloat(transform[2]) + this.annotation.dy\n bbox.offsetX = this.annotation.dx\n bbox.offsetY = this.annotation.dy\n return bbox \n }\n\n // getConnectorBBox() { return bboxWithoutHandles(this.connector)}\n // getSubjectBBox() { return bboxWithoutHandles(this.subject)}\n // getAnnotationBBox() { return bboxWithoutHandles(this.a)}\n\n drawSubject (context={}) {\n const subjectData = this.annotation.subject\n const type = context.type\n const subjectParams = { type: this, subjectData}\n\n let subject = {}\n if (type === \"circle\") subject = subjectCircle(subjectParams)\n else if (type === \"rect\") subject = subjectRect(subjectParams)\n else if (type === \"threshold\") subject = subjectThreshold(subjectParams)\n else if (type === \"badge\") subject = subjectBadge(subjectParams)\n\n let { components=[], handles=[] } = subject\n if (this.editMode){\n handles = handles.concat(this.mapHandles([{ drag: this.dragSubject.bind(this)}]))\n components.push({ type: \"handle\", handles })\n }\n\n return components\n }\n\n drawConnector (context={}) {\n const connectorData = this.annotation.connector\n const type = connectorData.type || context.type\n const connectorParams = { type: this, connectorData}\n connectorParams.subjectType = this.typeSettings && this.typeSettings.subject && this.typeSettings.subject.type \n\n let connector = {}\n if (type === \"curve\") connector = connectorCurve(connectorParams)\n else if (type === \"elbow\") connector = connectorElbow(connectorParams)\n else connector = connectorLine(connectorParams)\n\n let { components=[], handles=[] } = connector\n const line = components[0]\n const endType = connectorData.end || context.end\n let end = {}\n if (endType === \"arrow\") {\n let s = line.data[1]\n const e = line.data[0]\n const distance = Math.sqrt(Math.pow((s[0] - e[0]),2) + Math.pow((s[1] - e[1]),2))\n if (distance < 5 && line.data[2]) {\n s = line.data[2]\n }\n\n end = connectorArrow({ annotation: this.annotation, start: s, end: e })\n } else if (endType === \"dot\") {\n end = connectorDot({ line })\n }\n\n if (end.components){ components = components.concat(end.components)}\n\n if (this.editMode){\n if (handles.length !== 0) components.push({ type: \"handle\", handles })\n }\n return components;\n }\n\n drawNote (context={}) {\n const noteData = this.annotation.note\n const align = noteData.align || context.align || 'dynamic'\n const noteParams = { bbox: context.bbox, align, offset: this.annotation.offset }\n const lineType = noteData.lineType || context.lineType\n let note={}\n if (lineType == \"vertical\") note = noteVertical(noteParams)\n else if (lineType == \"horizontal\") note = noteHorizontal(noteParams)\n\n let { components=[], handles=[] } = note\n if (this.editMode) {\n handles = this.mapHandles([{ x: 0, y: 0, drag: this.dragNote.bind(this)}])\n components.push({ type: \"handle\", handles })\n }\n return components\n }\n\n drawNoteContent (context) {\n const noteData = this.annotation.note\n const padding = noteData.padding || this.notePadding\n let orientation = noteData.orientation || context.orientation || 'topBottom'\n const lineType = noteData.lineType || context.lineType\n const align = noteData.align || context.align || 'dynamic'\n const subjectType = this.typeSettings && this.typeSettings.subject && this.typeSettings.subject.type \n \n if (lineType == \"vertical\") orientation = \"leftRight\"\n else if (lineType == \"horizontal\") orientation = \"topBottom\"\n\n const noteParams = { padding, bbox: context.bbox, offset: \n this.annotation.offset, orientation, align }\n\n const { x, y } = noteAlignment(noteParams)\n this.offsetCornerX = x + this.annotation.dx\n this.offsetCornerY = y + this.annotation.dy\n this.note && this.noteContent.attr('transform', `translate(${x}, ${y})`)\n \n return []\n } \n\n drawOnScreen(component, drawFunction) { return this.drawOnSVG( component, drawFunction) }\n\n redrawSubject(){\n this.subject && this.drawOnScreen( this.subject, this.drawSubject())\n }\n\n redrawConnector(bbox=this.getNoteBBox()){\n this.connector && this.drawOnScreen( this.connector, this.drawConnector())\n }\n\n redrawNote(bbox=this.getNoteBBox()){\n this.noteContent && this.drawOnScreen( this.noteContent, this.drawNoteContent({ bbox }))\n this.note && this.drawOnScreen( this.note, this.drawNote({ bbox })) \n }\n\n setPosition(){\n const position = this.annotation.position \n this.a.attr('transform', `translate(${position.x}, ${position.y})`)\n }\n\n setOffset(){\n if (this.note){\n const offset = this.annotation.offset\n this.note.attr('transform', `translate(${offset.x}, ${offset.y})`)\n }\n }\n\n setPositionWithAccessors(accessors){\n if (accessors && this.annotation.data){\n this.mapX(accessors)\n this.mapY(accessors)\n }\n this.setPosition()\n }\n\n\n setClassName(){\n this.a.attr(\"class\", `annotation ${this.className && this.className()} ${this.editMode ? \"editable\" : \"\"} ${this.annotation.className || ''}`)\n }\n\n draw() {\n this.setClassName()\n this.setPosition()\n this.setOffset()\n this.redrawSubject()\n this.redrawConnector()\n this.redrawNote()\n }\n\n dragstarted() { event.sourceEvent.stopPropagation(); \n this.a.classed(\"dragging\", true) \n this.a.selectAll(\"circle.handle\").style(\"pointer-events\", \"none\")\n }\n dragended() { \n this.a.classed(\"dragging\", false)\n this.a.selectAll(\"circle.handle\").style(\"pointer-events\", \"all\")\n }\n\n dragSubject() {\n const position = this.annotation.position\n position.x += event.dx\n position.y += event.dy\n this.annotation.position = position\n }\n\n dragNote() {\n const offset = this.annotation.offset\n offset.x += event.dx\n offset.y += event.dy\n this.annotation.offset = offset\n }\n\n mapHandles(handles) {\n return handles\n .map(h => ({ ...h, \n start: this.dragstarted.bind(this), end: this.dragended.bind(this) }))\n }\n}\n\nexport const customType = (initialType, typeSettings, init) => {\n return class customType extends initialType {\n constructor (settings) {\n super(settings)\n this.typeSettings = typeSettings\n\n if (typeSettings.disable){\n typeSettings.disable.forEach(d => {\n this[d] = undefined\n if (d == \"note\"){\n this.noteContent = undefined\n }\n })\n }\n }\n\n static init(annotation, accessors){ \n super.init(annotation, accessors); \n if (init) {\n annotation = init(annotation, accessors) \n }\n return annotation\n }\n\n className(){ return `${typeSettings.className || ''} ${super.className && super.className() || ''}`}\n\n drawSubject(context){\n this.typeSettings.subject = Object.assign({}, typeSettings.subject, this.typeSettings.subject)\n return super.drawSubject({ ...context, ...this.typeSettings.subject })\n }\n\n drawConnector(context, subjectContext){\n this.typeSettings.connector = Object.assign({}, typeSettings.connector, this.typeSettings.connector)\n return super.drawConnector({ ...context, ...typeSettings.connector, ...this.typeSettings.connector })\n }\n\n drawNote(context){\n this.typeSettings.note = Object.assign({}, typeSettings.note, this.typeSettings.note)\n return super.drawNote({ ...context, ...typeSettings.note, ...this.typeSettings.note })\n }\n\n drawNoteContent(context){\n return super.drawNoteContent({ ...context, ...typeSettings.note, ...this.typeSettings.note })\n }\n }\n}\n\nexport class d3NoteText extends Type {\n\n constructor(params){\n super(params)\n this.textWrap = params.textWrap || 120\n this.drawText()\n }\n\n updateTextWrap (textWrap) {\n this.textWrap = textWrap\n this.drawText()\n }\n\n //TODO: add update text functionality\n\n drawText () {\n if (this.note){\n \n newWithClass(this.note, [this.annotation], 'g', 'annotation-note-content')\n\n const noteContent = this.note.select('g.annotation-note-content')\n newWithClass(noteContent, [this.annotation], 'rect', 'annotation-note-bg')\n newWithClass(noteContent, [this.annotation], 'text', 'annotation-note-label')\n newWithClass(noteContent, [this.annotation], 'text', 'annotation-note-title')\n\n let titleBBox = { height: 0 }\n const label = this.a.select('text.annotation-note-label')\n const wrapLength = this.annotation.note && this.annotation.note.wrap || \n this.typeSettings && this.typeSettings.note && this.typeSettings.note.wrap ||\n this.textWrap \n\n if (this.annotation.note.title){\n const title = this.a.select('text.annotation-note-title')\n title.text(this.annotation.note.title)\n .attr('dy', '1.1em')\n title.call(wrap, wrapLength)\n titleBBox = title.node().getBBox()\n }\n\n label.text(this.annotation.note.label)\n .attr('dy', '1em')\n label.call(wrap, wrapLength)\n\n label.attr('y', titleBBox.height * 1.1 || 0)\n\n const bbox = this.getNoteBBox()\n this.a.select('rect.annotation-note-bg')\n .attr('width', bbox.width)\n .attr('height', bbox.height)\n }\n }\n}\n\nexport const d3Label = customType(d3NoteText, {\n className: \"label\", \n note: { align: \"middle\"}\n})\n\nexport const d3Callout = customType(d3NoteText, {\n className: \"callout\",\n note: { lineType: \"horizontal\" }\n})\n\nexport const d3CalloutElbow = customType(d3Callout, {\n className: \"callout elbow\",\n connector: { type: \"elbow\" }\n})\n\nexport const d3CalloutCurve = customType(d3Callout, {\n className: \"callout curve\",\n connector: { type: \"curve\" }\n})\n\nexport const d3Badge = customType(Type, {\n className: \"badge\",\n subject: { type: \"badge\"},\n disable: ['connector', 'note']\n})\n\n\nexport const d3CalloutCircle = customType(d3CalloutElbow, {\n className: \"callout circle\",\n subject: { type: \"circle\"}\n})\n\nexport const d3CalloutRect = customType(d3CalloutElbow, {\n className: \"callout rect\",\n subject: { type: \"rect\"}\n})\n\n\nclass ThresholdMap extends d3Callout {\n\n mapY(accessors){\n super.mapY(accessors)\n const a = this.annotation\n if ((a.subject.x1 || a.subject.x2) && a.data && accessors.y){\n a.y = accessors.y(a.data)\n }\n }\n\n mapX(accessors) {\n super.mapX(accessors)\n const a = this.annotation\n if ((a.subject.y1 || a.subject.y2) && a.data && accessors.x){\n a.x = accessors.x(a.data)\n }\n }\n}\n\nexport const d3XYThreshold = customType(ThresholdMap, {\n className: \"callout xythreshold\",\n subject: { type: \"threshold\"}\n})\n\n\n\nexport const newWithClass = (a, d, type, className) => {\n const group = a.selectAll(`${type}.${className}`).data(d)\n group.enter()\n .append(type)\n .merge(group)\n .attr('class', className)\n\n group.exit().remove()\n return a\n}\n\n\nconst addHandlers = ( dispatcher, annotation, { component, name }) => {\n if (component){\n component\n .on(\"mouseover.annotations\", () => {\n dispatcher.call(`${name}over`, component, annotation)})\n .on(\"mouseout.annotations\", () => dispatcher.call(`${name}out`, component, annotation))\n .on(\"click.annotations\", () => dispatcher.call(`${name}click`, component, annotation))\n }\n}\n\n//Text wrapping code adapted from Mike Bostock\nconst wrap = (text, width) => {\n text.each(function() {\n var text = select(this),\n words = text.text().split(/[ \\t\\r\\n]+/).reverse(),\n word,\n line = [],\n lineNumber = 0,\n lineHeight = .2, //ems\n y = text.attr(\"y\"),\n dy = parseFloat(text.attr(\"dy\")) || 0,\n tspan = text.text(null)\n .append(\"tspan\")\n .attr(\"x\", 0)\n .attr(\"dy\", dy + \"em\");\n\n while (word = words.pop()) {\n line.push(word);\n tspan.text(line.join(\" \"));\n if (tspan.node().getComputedTextLength() > width && line.length > 1) {\n line.pop();\n tspan.text(line.join(\" \"));\n line = [word];\n tspan = text.append(\"tspan\")\n .attr(\"x\", 0)\n .attr(\"dy\", lineHeight + dy + \"em\").text(word);\n }\n }\n });\n}\n\nconst bboxWithoutHandles = (selection, selector=':not(.handle)') => {\n if (!selection){\n return { x: 0, y: 0, width: 0, height: 0}\n }\n\n return selection.selectAll(selector).nodes().reduce((p, c) => {\n const bbox = c.getBBox()\n p.x = Math.min(p.x, bbox.x)\n p.y = Math.min(p.y, bbox.y)\n p.width = Math.max(p.width, bbox.width)\n p.height += bbox.height\n return p\n }, { x: 0, y: 0, width: 0, height: 0});\n}\n\nexport default {\n Type,\n d3Label,\n d3Callout,\n d3CalloutElbow,\n d3CalloutCurve,\n d3CalloutCircle,\n d3CalloutRect,\n d3XYThreshold,\n d3Badge,\n customType\n}\n","import Annotation from './Annotation'\nimport AnnotationCollection from './AnnotationCollection'\nimport { newWithClass, d3Callout } from './Types-d3'\nimport { select } from 'd3-selection'\nimport { dispatch } from 'd3-dispatch';\n\n\nexport default function annotation(){\n let annotations = [],\n collection,\n context, //TODO: add canvas functionality\n disable = [],\n accessors = {},\n accessorsInverse = {},\n editMode = false,\n ids,\n type = d3Callout,\n textWrap,\n notePadding,\n annotationDispatcher = dispatch(\n \"subjectover\", \"subjectout\", \"subjectclick\", \n \"connectorover\", \"connectorout\", \"connectorclick\", \n \"noteover\", \"noteout\", \"noteclick\"),\n sel;\n\n const annotation = function(selection){\n sel = selection\n //TODO: check to see if this is still needed \n if (!editMode){\n selection.selectAll(\"circle.handle\")\n .remove()\n }\n\n const translatedAnnotations = annotations\n .map(a => {\n if (!a.type) { a.type = type }\n if (!a.disable) {a.disable = disable}\n return new Annotation(a)\n });\n\n collection = new AnnotationCollection ({\n annotations: translatedAnnotations,\n accessors,\n accessorsInverse,\n ids\n })\n \n\n const annotationG = selection.selectAll('g').data([collection])\n annotationG.enter().append('g').attr('class', `annotations`)\n \n const group = selection.select('g.annotations')\n newWithClass(group, collection.annotations, 'g', 'annotation')\n\n const annotation = group.selectAll('g.annotation')\n \n annotation \n .each(function(d) {\n const a = select(this)\n const position = d.position\n\n a.attr('class', 'annotation')\n\n newWithClass(a, [d], 'g', 'annotation-connector')\n newWithClass(a, [d], 'g', 'annotation-subject')\n newWithClass(a, [d], 'g', 'annotation-note')\n newWithClass(a.select('g.annotation-note'), [d], 'g', 'annotation-note-content')\n\n d.type = new d.type({ a, annotation: d, textWrap, notePadding, editMode, \n dispatcher: annotationDispatcher, accessors })\n d.type.draw()\n })\n }\n\n annotation.json = function() {\n console.log('Annotations JSON was copied to your clipboard. Please note the annotation type is not JSON compatible. It appears in the objects array in the console, but not in the copied JSON.', collection.json)\n window.copy(JSON.stringify(collection.json.map(a => { delete a.type; return a })))\n return annotation\n }\n\n annotation.update = function(){\n if (annotations && collection){\n annotations = collection.annotations.map((a, i) => { a.type.draw(); return a }) \n }\n return annotation\n }\n\n annotation.updatedAccessors = function(){\n collection.setPositionWithAccessors()\n annotations = collection.annotations\n return annotation\n }\n\n annotation.disable = function(_){\n if (!arguments.length) return disable;\n disable = _\n if (collection) { \n collection.updateDisable(disable)\n annotations = collection.annotations\n }\n return annotation;\n }\n\n annotation.textWrap = function(_){\n if (!arguments.length) return textWrap;\n textWrap = _\n if (collection) { \n collection.updateTextWrap(textWrap)\n annotations = collection.annotations\n }\n return annotation;\n }\n\n annotation.notePadding = function(_){\n if (!arguments.length) return notePadding;\n notePadding = _\n if (collection) { \n collection.updateNotePadding(notePadding)\n annotations = collection.annotations\n }\n return annotation;\n }\n\n annotation.type = function(_, settings) {\n if (!arguments.length) return type;\n type = _;\n if (collection) { \n collection.annotations.map(a => {\n \n a.type.note && a.type.note.selectAll(\"*:not(.annotation-note-content)\").remove()\n a.type.noteContent && a.type.noteContent.selectAll(\"*\").remove()\n a.type.subject && a.type.subject.selectAll(\"*\").remove()\n a.type.connector && a.type.connector.selectAll(\"*\").remove()\n a.type.typeSettings = {}\n a.type = type\n\n a.subject = settings && settings.subject || a.subject\n a.connector = settings && settings.connector || a.connector\n a.note = settings && settings.note || a.note\n })\n\n annotations = collection.annotations\n }\n return annotation;\n }\n\n annotation.annotations = function(_) {\n if (!arguments.length) return collection && collection.annotations || annotations;\n annotations = _\n return annotation;\n };\n\n annotation.context = function(_) {\n if (!arguments.length) return context;\n context = _\n return annotation;\n }; \n\n annotation.accessors = function(_) {\n if (!arguments.length) return accessors;\n accessors = _;\n return annotation\n }\n\n annotation.accessorsInverse = function(_) {\n if (!arguments.length) return accessorsInverse;\n accessorsInverse = _;\n return annotation\n }\n\n annotation.ids = function(_) {\n if (!arguments.length) return ids;\n ids = _;\n return annotation\n }\n\n annotation.editMode = function(_) {\n if (!arguments.length) return editMode;\n editMode = _\n\n if (sel){\n sel.selectAll('g.annotation')\n .classed('editable', editMode)\n }\n\n if (collection) { \n collection.editMode(editMode)\n annotations = collection.annotations\n }\n return annotation\n }\n\n annotation.collection = function(_) {\n if (!arguments.length) return collection;\n collection = _\n return annotation\n }\n\n annotation.on = function(){\n const value = annotationDispatcher.on.apply(annotationDispatcher, arguments)\n return value === annotationDispatcher ? annotation : value;\n }\n\n return annotation;\n\n};","import annotation from './src/Adapter-d3'\nimport { Type, d3Label, d3Callout, d3CalloutCurve, d3CalloutElbow, d3CalloutCircle, \n d3CalloutRect, d3XYThreshold, d3Badge, customType } from './src/Types-d3'\n\n\nexport {\n annotation,\n Type as annotationTypeBase ,\n d3Label as annotationLabel ,\n d3Callout as annotationCallout ,\n d3CalloutCurve as annotationCalloutCurve ,\n d3CalloutElbow as annotationCalloutElbow ,\n d3CalloutCircle as annotationCalloutCircle ,\n d3CalloutRect as annotationCalloutRect ,\n d3XYThreshold as annotationXYThreshold ,\n d3Badge as annotationBadge ,\n customType as annotationCustomType \n}\n\nexport default {\n annotation,\n annotationTypeBase : Type,\n annotationLabel : d3Label,\n annotationCallout : d3Callout,\n annotationCalloutCurve : d3CalloutCurve,\n annotationCalloutElbow : d3CalloutElbow,\n annotationCalloutCircle : d3CalloutCircle,\n annotationCalloutRect : d3CalloutRect,\n annotationXYThreshold : d3XYThreshold,\n annotationBadge : d3Badge,\n annotationCustomType : customType\n}"],"names":["Annotation","x","y","dy","dx","data","type","subject","connector","note","disable","id","className","_dx","_dy","_x","_y","_className","setPosition","selectAll","nodes","length","redrawSubject","setOffset","redrawConnector","redrawNote","setClassName","updatePosition","updateOffset","json","Object","keys","AnnotationCollection","annotations","accessors","accessorsInverse","newSettings","forEach","undefined","d","setPositionWithAccessors","editMode","a","updateEditMode","remove","textWrap","updateTextWrap","notePadding","map","k","getNoteBBoxOffset","positionX","positionY","pointHandle","cx","cy","move","circleHandles","r1","r2","padding","h","Math","sqrt","addHandles","group","handles","r","enter","append","attr","call","drag","container","select","node","on","start","end","exit","leftRightDynamic","align","topBottomDynamic","bbox","orientation","offset","height","width","lineBuilder","curve","curveLinear","canvasContext","lineGen","line","builder","context","pathMethods","attrs","arcBuilder","arcShape","arc","innerRadius","outerRadius","radius","startAngle","endAngle","PI","components","lineSetup","subjectType","annotation","position","x1","x2","y1","y2","subjectData","angle","asin","radiusPadding","abs","cos","sin","connectorData","diffY","diffX","xe","ye","opposite","acos","points","createPoints","curveCatmullRom","cHandles","c","i","index","updatePoint","event","mapHandles","bind","anchors","diff","p","push","size","angleOffset","atan","dot","transform","updateRadius","rect","updateWidth","updateHeight","rHandles","circlebg","circle","pointer","dragBadge","bHandles","text","Type","dispatcher","indexOf","noteContent","handler","addHandlers","component","name","offsetCornerX","offsetCornerY","init","mapX","mapY","builders","Array","isArray","filter","b","el","attrKeys","bboxWithoutHandles","split","parseFloat","offsetX","offsetY","subjectParams","subjectCircle","subjectRect","subjectThreshold","subjectBadge","concat","dragSubject","connectorParams","typeSettings","connectorCurve","connectorElbow","connectorLine","endType","s","e","distance","pow","connectorArrow","connectorDot","noteData","noteParams","lineType","noteVertical","noteHorizontal","dragNote","noteAlignment","drawFunction","drawOnSVG","drawOnScreen","drawSubject","getNoteBBox","drawConnector","drawNoteContent","drawNote","sourceEvent","stopPropagation","classed","style","dragstarted","dragended","customType","initialType","settings","babelHelpers.get","assign","subjectContext","d3NoteText","params","drawText","titleBBox","label","wrapLength","wrap","title","getBBox","d3Label","d3Callout","d3CalloutElbow","d3CalloutCurve","d3Badge","d3CalloutCircle","d3CalloutRect","ThresholdMap","d3XYThreshold","newWithClass","merge","each","words","reverse","word","lineNumber","lineHeight","tspan","pop","join","getComputedTextLength","selection","selector","reduce","min","max","collection","ids","annotationDispatcher","dispatch","sel","translatedAnnotations","annotationG","draw","log","copy","JSON","stringify","update","updatedAccessors","_","arguments","updateDisable","updateNotePadding","value","apply"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACqBA;4BAES;sBADdC,CACc;QADdA,CACc,0BADZ,CACY;sBADTC,CACS;QADTA,CACS,0BADP,CACO;uBADJC,EACI;QADJA,EACI,2BADD,CACC;uBADEC,EACF;QADEA,EACF,2BADK,CACL;QADQC,IACR,QADQA,IACR;QADcC,IACd,QADcA,IACd;QADoBC,OACpB,QADoBA,OACpB;QAD6BC,SAC7B,QAD6BA,SAC7B;QADwCC,IACxC,QADwCA,IACxC;QAA1BC,OAA0B,QAA1BA,OAA0B;QAAjBC,EAAiB,QAAjBA,EAAiB;QAAbC,SAAa,QAAbA,SAAa;;;;SAErBC,GAAL,GAAWT,EAAX;SACKU,GAAL,GAAWX,EAAX;SACKY,EAAL,GAAUd,CAAV;SACKe,EAAL,GAAUd,CAAV;SACKS,EAAL,GAAUA,EAAV;SACKM,UAAL,GAAkBL,aAAa,EAA/B;;SAEKN,IAAL,GAAYA,QAAQ,EAApB;SACKD,IAAL,GAAYA,IAAZ;;SAEKI,IAAL,GAAYA,QAAQ,EAApB;SACKD,SAAL,GAAiBA,aAAa,EAA9B;SACKD,OAAL,GAAeA,WAAW,EAA1B;;SAEKG,OAAL,GAAeA,WAAW,EAA1B;;;;;qCAGc;UACV,KAAKJ,IAAL,CAAUY,WAAd,EAA2B;aACpBZ,IAAL,CAAUY,WAAV;YACI,KAAKZ,IAAL,CAAUC,OAAV,CAAkBY,SAAlB,CAA4B,eAA5B,EAA6CC,KAA7C,GAAqDC,MAArD,KAAgE,CAApE,EAAuE;eAChEf,IAAL,CAAUgB,aAAV;;;;;;mCAYQ;UACR,KAAKhB,IAAL,CAAUiB,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UAASc,CAAT,EAAY;QAC9B,CAACC,UAAUrQ,MAAf,EAAuB,OAAOsP,UAAP;iBACVc,CAAb;WACO3K,UAAP;GAHF;;aAMWlC,EAAX,GAAgB,YAAU;QAClBiN,QAAQhB,qBAAqBjM,EAArB,CAAwBkN,KAAxB,CAA8BjB,oBAA9B,EAAoDa,SAApD,CAAd;WACOG,UAAUhB,oBAAV,GAAiC/J,UAAjC,GAA8C+K,KAArD;GAFF;;SAKO/K,UAAP;;;ACxLF,YAAe;wBAAA;sBAEQmD,IAFR;mBAGKgF,OAHL;qBAIOC,SAJP;0BAKYE,cALZ;0BAMYD,cANZ;2BAOaG,eAPb;yBAQWC,aARX;yBASWE,aATX;mBAUKJ,OAVL;wBAWUnB;CAXzB;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/indexRollup.mjs b/indexRollup.mjs deleted file mode 100644 index ded73f3..0000000 --- a/indexRollup.mjs +++ /dev/null @@ -1,1909 +0,0 @@ -import { select, event } from 'd3-selection'; -import { drag } from 'd3-drag'; -import { line, curveLinear, arc, curveCatmullRom } from 'd3-shape'; -import { dispatch } from 'd3-dispatch'; - -var asyncGenerator = function () { - function AwaitValue(value) { - this.value = value; - } - - function AsyncGenerator(gen) { - var front, back; - - function send(key, arg) { - return new Promise(function (resolve, reject) { - var request = { - key: key, - arg: arg, - resolve: resolve, - reject: reject, - next: null - }; - - if (back) { - back = back.next = request; - } else { - front = back = request; - resume(key, arg); - } - }); - } - - function resume(key, arg) { - try { - var result = gen[key](arg); - var value = result.value; - - if (value instanceof AwaitValue) { - Promise.resolve(value.value).then(function (arg) { - resume("next", arg); - }, function (arg) { - resume("throw", arg); - }); - } else { - settle(result.done ? "return" : "normal", result.value); - } - } catch (err) { - settle("throw", err); - } - } - - function settle(type, value) { - switch (type) { - case "return": - front.resolve({ - value: value, - done: true - }); - break; - - case "throw": - front.reject(value); - break; - - default: - front.resolve({ - value: value, - done: false - }); - break; - } - - front = front.next; - - if (front) { - resume(front.key, front.arg); - } else { - back = null; - } - } - - this._invoke = send; - - if (typeof gen.return !== "function") { - this.return = undefined; - } - } - - if (typeof Symbol === "function" && Symbol.asyncIterator) { - AsyncGenerator.prototype[Symbol.asyncIterator] = function () { - return this; - }; - } - - AsyncGenerator.prototype.next = function (arg) { - return this._invoke("next", arg); - }; - - AsyncGenerator.prototype.throw = function (arg) { - return this._invoke("throw", arg); - }; - - AsyncGenerator.prototype.return = function (arg) { - return this._invoke("return", arg); - }; - - return { - wrap: function (fn) { - return function () { - return new AsyncGenerator(fn.apply(this, arguments)); - }; - }, - await: function (value) { - return new AwaitValue(value); - } - }; - }(); - - var classCallCheck = function (instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } - }; - - 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 _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 get = function get(object, property, receiver) { - if (object === null) object = Function.prototype; - var desc = Object.getOwnPropertyDescriptor(object, property); - - if (desc === undefined) { - var parent = Object.getPrototypeOf(object); - - if (parent === null) { - return undefined; - } else { - return get(parent, property, receiver); - } - } else if ("value" in desc) { - return desc.value; - } else { - var getter = desc.get; - - if (getter === undefined) { - return undefined; - } - - return getter.call(receiver); - } - }; - - var inherits = function (subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function, not " + 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 possibleConstructorReturn = function (self, call) { - if (!self) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return call && (typeof call === "object" || typeof call === "function") ? call : self; - }; - - var toConsumableArray = function (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); - } - }; - -var Annotation = function () { - function Annotation(_ref) { - var _ref$x = _ref.x, - x = _ref$x === undefined ? 0 : _ref$x, - _ref$y = _ref.y, - y = _ref$y === undefined ? 0 : _ref$y, - _ref$dy = _ref.dy, - dy = _ref$dy === undefined ? 0 : _ref$dy, - _ref$dx = _ref.dx, - dx = _ref$dx === undefined ? 0 : _ref$dx, - data = _ref.data, - type = _ref.type, - subject = _ref.subject, - connector = _ref.connector, - note = _ref.note, - disable = _ref.disable, - id = _ref.id, - className = _ref.className; - classCallCheck(this, Annotation); - - - this._dx = dx; - this._dy = dy; - this._x = x; - this._y = y; - this.id = id; - this._className = className || ''; - - this.type = type || ''; - this.data = data; - - this.note = note || {}; - this.connector = connector || {}; - this.subject = subject || {}; - - this.disable = disable || []; - } - - createClass(Annotation, [{ - key: 'updatePosition', - value: function updatePosition() { - if (this.type.setPosition) { - this.type.setPosition(); - if (this.type.subject.selectAll(':not(.handle)').nodes().length !== 0) { - this.type.redrawSubject(); - } - } - } - }, { - key: 'updateOffset', - value: function updateOffset() { - if (this.type.setOffset) { - this.type.setOffset(); - - if (this.type.connector.selectAll(':not(.handle)').nodes().length !== 0) { - this.type.redrawConnector(); - } - - this.type.redrawNote(); - } - } - }, { - key: 'className', - get: function get() { - return this._className; - }, - set: function set(className) { - this._className = className; - if (this.type.setClassName) this.type.setClassName(); - } - }, { - key: 'x', - get: function get() { - return this._x; - }, - set: function set(x) { - this._x = x; - this.updatePosition(); - } - }, { - key: 'y', - get: function get() { - return this._y; - }, - set: function set(y) { - this._y = y; - this.updatePosition(); - } - }, { - key: 'dx', - get: function get() { - return this._dx; - }, - set: function set(dx) { - this._dx = dx; - this.updateOffset(); - } - }, { - key: 'dy', - get: function get() { - return this._dy; - }, - set: function set(dy) { - this._dy = dy; - this.updateOffset(); - } - }, { - key: 'offset', - get: function get() { - return { x: this._dx, y: this._dy }; - }, - set: function set(_ref2) { - var x = _ref2.x, - y = _ref2.y; - - this._dx = x; - this._dy = y; - this.updateOffset(); - } - }, { - key: 'position', - get: function get() { - return { x: this._x, y: this._y }; - }, - set: function set(_ref3) { - var x = _ref3.x, - y = _ref3.y; - - this._x = x; - this._y = y; - this.updatePosition(); - } - }, { - key: 'translation', - get: function get() { - return { - x: this._x + this._dx, - y: this._y + this._dy - }; - } - }, { - key: 'json', - get: function get() { - var json = { - x: this._x, - y: this._y, - dx: this._dx, - dy: this._dy - }; - - if (this.data && Object.keys(this.data).length > 0) json.data = this.data; - if (this.type) json.type = this.type; - if (this._className) json.className = this._className; - - if (Object.keys(this.connector).length > 0) json.connector = this.connector; - if (Object.keys(this.subject).length > 0) json.subject = this.subject; - if (Object.keys(this.note).length > 0) json.note = this.note; - - return json; - } - }]); - return Annotation; - }(); - -var AnnotationCollection = function () { - function AnnotationCollection(_ref) { - var annotations = _ref.annotations, - accessors = _ref.accessors, - accessorsInverse = _ref.accessorsInverse; - classCallCheck(this, AnnotationCollection); - - this.accessors = accessors; - this.accessorsInverse = accessorsInverse; - this.annotations = annotations; - } - - createClass(AnnotationCollection, [{ - key: "clearTypes", - value: function clearTypes(newSettings) { - this.annotations.forEach(function (d) { - d.type = undefined; - d.subject = newSettings && newSettings.subject || d.subject; - d.connector = newSettings && newSettings.connector || d.connector; - d.note = newSettings && newSettings.note || d.note; - }); - } - }, { - key: "setPositionWithAccessors", - value: function setPositionWithAccessors() { - var _this = this; - - this.annotations.forEach(function (d) { - d.type.setPositionWithAccessors(_this.accessors); - }); - } - }, { - key: "editMode", - value: function editMode(_editMode) { - this.annotations.forEach(function (a) { - if (a.type) { - a.type.editMode = _editMode; - a.type.updateEditMode(); - } - }); - } - }, { - key: "updateDisable", - value: function updateDisable(disable) { - this.annotations.forEach(function (a) { - a.disable = disable; - if (a.type) { - disable.forEach(function (d) { - if (a.type[d]) { - a.type[d].remove && a.type[d].remove(); - a.type[d] = undefined; - } - }); - } - }); - } - }, { - key: "updateTextWrap", - value: function updateTextWrap(textWrap) { - this.annotations.forEach(function (a) { - if (a.type && a.type.updateTextWrap) { - a.type.updateTextWrap(textWrap); - } - }); - } - }, { - key: "updateNotePadding", - value: function updateNotePadding(notePadding) { - this.annotations.forEach(function (a) { - if (a.type) { - a.type.notePadding = notePadding; - } - }); - } - }, { - key: "json", - get: function get() { - var _this2 = this; - - return this.annotations.map(function (a) { - var json = a.json; - if (_this2.accessorsInverse && a.data) { - json.data = {}; - Object.keys(_this2.accessorsInverse).forEach(function (k) { - json.data[k] = _this2.accessorsInverse[k]({ x: a.x, y: a.y }); - - //TODO make this feasible to map back to data for other types of subjects - }); - } - return json; - }); - } - }, { - key: "noteNodes", - get: function get() { - return this.annotations.map(function (a) { - return _extends({}, a.type.getNoteBBoxOffset(), { positionX: a.x, positionY: a.y }); - }); - } - - //TODO: come back and rethink if a.x and a.y are applicable in all situations - // get connectorNodes() { - // return this.annotations.map(a => ({ ...a.type.getConnectorBBox(), startX: a.x, startY: a.y})) - // } - - // get subjectNodes() { - // return this.annotations.map(a => ({ ...a.type.getSubjectBBox(), startX: a.x, startY: a.y})) - // } - - // get annotationNodes() { - // return this.annotations.map(a => ({ ...a.type.getAnnotationBBox(), startX: a.x, startY: a.y})) - // } - - }]); - return AnnotationCollection; - }(); - -var pointHandle = function pointHandle(_ref) { - var _ref$cx = _ref.cx, - cx = _ref$cx === undefined ? 0 : _ref$cx, - _ref$cy = _ref.cy, - cy = _ref$cy === undefined ? 0 : _ref$cy; - - return { move: { x: cx, y: cy } }; - }; - - var circleHandles = function circleHandles(_ref2) { - var _ref2$cx = _ref2.cx, - cx = _ref2$cx === undefined ? 0 : _ref2$cx, - _ref2$cy = _ref2.cy, - cy = _ref2$cy === undefined ? 0 : _ref2$cy, - r1 = _ref2.r1, - r2 = _ref2.r2, - padding = _ref2.padding; - - var h = { move: { x: cx, y: cy } }; - - if (r1 !== undefined) { - h.r1 = { x: cx + r1 / Math.sqrt(2), y: cy + r1 / Math.sqrt(2) }; - } - - if (r2 !== undefined) { - h.r2 = { x: cx + r2 / Math.sqrt(2), y: cy + r2 / Math.sqrt(2) }; - } - - if (padding !== undefined) { - h.padding = { x: cx + r1 + padding, y: cy }; - } - - return h; - }; - - //arc handles - var addHandles = function addHandles(_ref5) { - var group = _ref5.group, - handles = _ref5.handles, - _ref5$r = _ref5.r, - r = _ref5$r === undefined ? 10 : _ref5$r; - - //give it a group and x,y to draw handles - //then give it instructions on what the handles change - var h = group.selectAll('circle.handle').data(handles); - - h.enter().append('circle').attr('class', 'handle').call(d3Drag.drag().container(d3Selection.select('g.annotations').node()).on('start', function (d) { return d.start && d.start(d); - }).on('drag', function (d) { - return d.drag && d.drag(d); - }).on('end', function (d) { - return d.end && d.end(d); - })); - - group.selectAll('circle.handle').attr('cx', function (d) { - return d.x; - }).attr('cy', function (d) { - return d.y; - }).attr('r', function (d) { - return d.r || r; - }).attr('class', function (d) { - return 'handle ' + (d.className || ''); - }); - - h.exit().remove(); - }; - -var leftRightDynamic = function leftRightDynamic(align, y) { - if (align == "dynamic" || align == "left" || align == "right") { - if (y < 0) { - align = "top"; - } else { - align = "bottom"; - } - } - return align; - }; - - var topBottomDynamic = function topBottomDynamic(align, x) { - if (align == "dynamic" || align == "top" || align == "bottom") { - if (x < 0) { - align = "right"; - } else { - align = "left"; - } - } - return align; - }; - -var noteAlignment = (function (_ref) { var padding = _ref.padding, - bbox = _ref.bbox, - align = _ref.align, - orientation = _ref.orientation, - offset = _ref.offset; - - var x = -bbox.x; - var y = -bbox.y; - - if (orientation === "topBottom") { - align = topBottomDynamic(align, offset.x); - if (offset.y < 0) { - y -= bbox.height + padding; - } else { - y += padding; - } - - if (align === "middle") { - x -= bbox.width / 2; - } else if (align === "right") { - x -= bbox.width; - } - } else if (orientation === "leftRight") { - align = leftRightDynamic(align, offset.y); - if (offset.x < 0) { - x -= bbox.width + padding; - } else { - x += padding; - } - - if (align === "middle") { - y -= bbox.height / 2; - } else if (align === "top") { - y -= bbox.height; - } - } - - return { x: x, y: y }; - }); - -var lineBuilder = function lineBuilder(_ref) { - var data = _ref.data, - _ref$curve = _ref.curve, - curve = _ref$curve === undefined ? d3Shape.curveLinear : _ref$curve, - canvasContext = _ref.canvasContext, - className = _ref.className; - - var lineGen = d3Shape.line().curve(curve); - - var builder = { - type: 'path', - className: className, - data: data - }; - - if (canvasContext) { - lineGen.context(canvasContext); - builder.pathMethods = lineGen; - } else { - builder.attrs = { - d: lineGen(data) - }; - } - - return builder; - }; - - var arcBuilder = function arcBuilder(_ref2) { - var data = _ref2.data, - canvasContext = _ref2.canvasContext, - className = _ref2.className; - - - var builder = { - type: 'path', - className: className, - data: data - }; - - var arcShape = d3Shape.arc().innerRadius(data.innerRadius || 0).outerRadius(data.outerRadius || data.radius || 2).startAngle(data.startAngle || 0).endAngle(data.endAngle || 2 * Math.PI); if (canvasContext) { - arcShape.context(canvasContext); - builder.pathMethods = lineGen; - } else { - - builder.attrs = { - d: arcShape() - }; - } - - return builder; - }; - -var noteVertical = (function (_ref) { var align = _ref.align, - _ref$x = _ref.x, - x = _ref$x === undefined ? 0 : _ref$x, - _ref$y = _ref.y, - y = _ref$y === undefined ? 0 : _ref$y, - bbox = _ref.bbox, - offset = _ref.offset, - padding = _ref.padding; - - align = leftRightDynamic(align, offset.y); - - if (align == "top") { - y -= bbox.height; - } else if (align == "middle") { - y -= bbox.height / 2; - } - - var data = [[x, y], [x, y + bbox.height]]; - return { components: [lineBuilder({ data: data, className: "note-line" })] }; - }); - -var noteHorizontal = (function (_ref) { var align = _ref.align, - _ref$x = _ref.x, - x = _ref$x === undefined ? 0 : _ref$x, - _ref$y = _ref.y, - y = _ref$y === undefined ? 0 : _ref$y, - offset = _ref.offset, - bbox = _ref.bbox, - padding = _ref.padding; - - align = topBottomDynamic(align, offset.x); - - if (align == "right") { - x -= bbox.width; - } else if (align == "middle") { - x -= bbox.width / 2; - } - - var data = [[x, y], [x + bbox.width, y]]; - return { components: [lineBuilder({ data: data, className: "note-line" })] }; - }); - -var lineSetup = function lineSetup(_ref) { - var type = _ref.type, - subjectType = _ref.subjectType; - - var annotation = type.annotation; - var offset = annotation.position; - - var x1 = annotation.x - offset.x, - x2 = x1 + annotation.dx, - y1 = annotation.y - offset.y, - y2 = y1 + annotation.dy; - - var subjectData = annotation.subject; - - if (subjectType == "circle" && (subjectData.outerRadius || subjectData.radius)) { - var h = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); - var angle = Math.asin(-y2 / h); - var r = subjectData.outerRadius || subjectData.radius + (subjectData.radiusPadding || 0); - - x1 = Math.abs(Math.cos(angle) * r) * (x2 < 0 ? -1 : 1); - y1 = Math.abs(Math.sin(angle) * r) * (y2 < 0 ? -1 : 1); - } - - if (subjectType == "rect") { - var width = subjectData.width, - height = subjectData.height; - - - if (width > 0 && annotation.dx > 0 || width < 0 && annotation.dx < 0) { - if (Math.abs(width) > Math.abs(annotation.dx)) x1 = width / 2;else x1 = width; - } - if (height > 0 && annotation.dy > 0 || height < 0 && annotation.dy < 0) { - if (Math.abs(height) > Math.abs(annotation.dy)) y1 = height / 2;else y1 = height; - } - if (x1 == width / 2 && y1 == height / 2) { - x1 = x2;y1 = y2; - } - } - - return [[x1, y1], [x2, y2]]; - }; - -var connectorLine = (function (connectorData) { var data = lineSetup(connectorData); - return { components: [lineBuilder({ data: data, className: "connector" })] }; - }); - -var connectorElbow = (function (_ref) { var type = _ref.type, - subjectType = _ref.subjectType; - - - var annotation = type.annotation; - var offset = annotation.position; - - var x1 = annotation.x - offset.x, - x2 = x1 + annotation.dx, - y1 = annotation.y - offset.y, - y2 = y1 + annotation.dy; - - var subjectData = annotation.subject; - - if (subjectType == "rect") { - var width = subjectData.width, - height = subjectData.height; - - - if (width > 0 && annotation.dx > 0 || width < 0 && annotation.dx < 0) { - if (Math.abs(width) > Math.abs(annotation.dx)) x1 = width / 2;else x1 = width; - } - if (height > 0 && annotation.dy > 0 || height < 0 && annotation.dy < 0) { - if (Math.abs(height) > Math.abs(annotation.dy)) y1 = height / 2;else y1 = height; - } - if (x1 == width / 2 && y1 == height / 2) { - x1 = x2;y1 = y2; - } - } - - var data = [[x1, y1], [x2, y2]]; - - var diffY = y2 - y1; - var diffX = x2 - x1; - var xe = x2; - var ye = y2; - var opposite = y2 < y1 && x2 > x1 || x2 < x1 && y2 > y1 ? -1 : 1; - - if (Math.abs(diffX) < Math.abs(diffY)) { - xe = x2; - ye = y1 + diffX * opposite; - } else { - ye = y2; - xe = x1 + diffY * opposite; - } - - if (subjectType == "circle" && (subjectData.outerRadius || subjectData.radius)) { - var r = (subjectData.outerRadius || subjectData.radius) + (subjectData.radiusPadding || 0); - var length = r / Math.sqrt(2); - - if (Math.abs(diffX) > length && Math.abs(diffY) > length) { - x1 = length * (x2 < 0 ? -1 : 1); - y1 = length * (y2 < 0 ? -1 : 1); - data = [[x1, y1], [xe, ye], [x2, y2]]; - } else if (Math.abs(diffX) > Math.abs(diffY)) { - var angle = Math.asin(-y2 / r); - x1 = Math.abs(Math.cos(angle) * r) * (x2 < 0 ? -1 : 1); - data = [[x1, y2], [x2, y2]]; - } else { - var _angle = Math.acos(x2 / r); - y1 = Math.abs(Math.sin(_angle) * r) * (y2 < 0 ? -1 : 1); - data = [[x2, y1], [x2, y2]]; - } - } else { - data = [[x1, y1], [xe, ye], [x2, y2]]; - } - - return { components: [lineBuilder({ data: data, className: "connector" })] }; - }); - -var connectorCurve = (function (_ref) { - var type = _ref.type, - connectorData = _ref.connectorData, - subjectType = _ref.subjectType; - - - if (!connectorData) { - connectorData = {}; - } - if (!connectorData.points || typeof connectorData.points === "number") { - connectorData.points = createPoints(type.annotation.offset, connectorData.points); - } - if (!connectorData.curve) { - connectorData.curve = d3Shape.curveCatmullRom; - } - - var handles = []; - - if (type.editMode) { - (function () { - var cHandles = connectorData.points.map(function (c, i) { - return _extends({}, pointHandle({ cx: c[0], cy: c[1] }), { index: i }); - }); - - var updatePoint = function updatePoint(index) { - connectorData.points[index][0] += d3Selection.event.dx; - connectorData.points[index][1] += d3Selection.event.dy; - type.redrawConnector(); - }; - - handles = type.mapHandles(cHandles.map(function (h) { - return _extends({}, h.move, { drag: updatePoint.bind(type, h.index) }); - })); - })(); - } - - var data = lineSetup({ type: type, subjectType: subjectType }); - data = [data[0]].concat(toConsumableArray(connectorData.points), [data[1]]); - var components = [lineBuilder({ data: data, curve: connectorData.curve, className: "connector" })]; - - return { components: components, handles: handles }; - }); - - var createPoints = function createPoints(offset) { - var anchors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2; - - var diff = { x: offset.x / (anchors + 1), y: offset.y / (anchors + 1) }; - var p = []; - - var i = 1; - for (; i <= anchors; i++) { - p.push([diff.x * i + i % 2 * 20, diff.y * i - i % 2 * 20]); - } - return p; - }; - -var connectorArrow = (function (_ref) { var annotation = _ref.annotation, - start = _ref.start, - end = _ref.end; - - var offset = annotation.position; - if (!start) { - start = [annotation.dx, annotation.dy]; - } else { - start = [-end[0] + start[0], -end[1] + start[1]]; - } - if (!end) { - end = [annotation.x - offset.x, annotation.y - offset.y]; - } - - var x1 = end[0], - y1 = end[1]; - - var dx = start[0]; - var dy = start[1]; - - var size = 10; - var angleOffset = 16 / 180 * Math.PI; - var angle = Math.atan(dy / dx); - - if (dx < 0) { - angle += Math.PI; - } - - var data = [[x1, y1], [Math.cos(angle + angleOffset) * size + x1, Math.sin(angle + angleOffset) * size + y1], [Math.cos(angle - angleOffset) * size + x1, Math.sin(angle - angleOffset) * size + y1], [x1, y1]]; - - //TODO add in reverse - // if (canvasContext.arrowReverse){ - // data = [[x1, y1], - // [Math.cos(angle + angleOffset)*size, Math.sin(angle + angleOffset)*size], - // [Math.cos(angle - angleOffset)*size, Math.sin(angle - angleOffset)*size], - // [x1, y1] - // ] - // } else { - // data = [[x1, y1], - // [Math.cos(angle + angleOffset)*size, Math.sin(angle + angleOffset)*size], - // [Math.cos(angle - angleOffset)*size, Math.sin(angle - angleOffset)*size], - // [x1, y1] - // ] - // } - - return { components: [lineBuilder({ data: data, className: 'connector-arrow' })] }; - }); - -var connectorDot = (function (_ref) { var line = _ref.line; - - - var dot = arcBuilder({ className: 'connector-dot', data: { radius: 3 } }); - dot.attrs.transform = 'translate(' + line.data[0][0] + ', ' + line.data[0][1] + ')'; - - return { components: [dot] }; - }); - -var subjectCircle = (function (_ref) { - var subjectData = _ref.subjectData, - type = _ref.type; - - if (!subjectData.radius && !subjectData.outerRadius) { - subjectData.radius = 20; - } - - var handles = []; - var c = arcBuilder({ data: subjectData, className: "subject" }); - if (type.editMode) { - var h = circleHandles({ - r1: c.data.outerRadius || c.data.radius, - r2: c.data.innerRadius, - padding: subjectData.radiusPadding - }); - - var updateRadius = function updateRadius(attr) { - var r = subjectData[attr] + d3Selection.event.dx * Math.sqrt(2); - subjectData[attr] = r; - type.redrawSubject(); - type.redrawConnector(); - }; - - var cHandles = [_extends({}, h.r1, { drag: updateRadius.bind(type, subjectData.outerRadius !== undefined ? 'outerRadius' : 'radius') })]; - - if (subjectData.innerRadius) { - cHandles.push(_extends({}, h.r2, { drag: updateRadius.bind(type, 'innerRadius') })); - } - handles = type.mapHandles(cHandles); - } - - return { components: [c], handles: handles }; - }); - -var subjectRect = (function (_ref) { - var subjectData = _ref.subjectData, - type = _ref.type; - - if (!subjectData.width) { - subjectData.width = 100; - } - if (!subjectData.height) { - subjectData.height = 100; - } - - var handles = []; - var width = subjectData.width, - height = subjectData.height; - - - var data = [[0, 0], [width, 0], [width, height], [0, height], [0, 0]]; - var rect = lineBuilder({ data: data, className: 'subject' }); - - if (type.editMode) { - - var updateWidth = function updateWidth(attr) { - subjectData.width = d3Selection.event.x; - type.redrawSubject(); - type.redrawConnector(); - }; - - var updateHeight = function updateHeight() { - subjectData.height = d3Selection.event.y; type.redrawSubject(); - type.redrawConnector(); - }; - - var rHandles = [{ x: width, y: height / 2, drag: updateWidth.bind(type) }, { x: width / 2, y: height, drag: updateHeight.bind(type) }]; - - handles = type.mapHandles(rHandles); - } - - return { components: [rect], handles: handles }; - }); - -var subjectThreshold = (function (_ref) { var subjectData = _ref.subjectData, - type = _ref.type; - - var offset = type.annotation.position; - - var x1 = (subjectData.x1 !== undefined ? subjectData.x1 : offset.x) - offset.x, - x2 = (subjectData.x2 !== undefined ? subjectData.x2 : offset.x) - offset.x, - y1 = (subjectData.y1 !== undefined ? subjectData.y1 : offset.y) - offset.y, - y2 = (subjectData.y2 !== undefined ? subjectData.y2 : offset.y) - offset.y; - - var data = [[x1, y1], [x2, y2]]; - return { components: [lineBuilder({ data: data, className: 'subject' })] }; - }); - -var subjectBadge = (function (_ref) { - var subjectData = _ref.subjectData, - type = _ref.type; - - if (!subjectData.radius) subjectData.radius = 14; - if (!subjectData.x) subjectData.x = "left"; - if (!subjectData.y) subjectData.y = "top"; - - var handles = []; - var radius = subjectData.radius; - var innerRadius = radius * .7; - var x = subjectData.x == "left" ? -radius : radius; - var y = subjectData.y == "top" ? -radius : radius; - var transform = 'translate(' + x + ', ' + y + ')'; - var circlebg = arcBuilder({ className: 'subject', data: { radius: radius } }); - circlebg.attrs.transform = transform; - - var circle = arcBuilder({ className: 'subject-ring', data: { outerRadius: radius, innerRadius: innerRadius } }); - circle.attrs.transform = transform; - - var pointer = lineBuilder({ className: 'subject-pointer', - data: [[0, 0], [x, 0], [0, y], [0, 0]] - }); - - if (type.editMode) { - - var dragBadge = function dragBadge() { - subjectData.x = d3Selection.event.x < 0 ? "left" : "right"; - subjectData.y = d3Selection.event.y < 0 ? "top" : "bottom"; type.redrawSubject(); - }; - - var bHandles = [{ x: x * 2, y: y * 2, drag: dragBadge.bind(type) }]; - handles = type.mapHandles(bHandles); - } - - var text = void 0; - if (subjectData.text) { - text = { - type: "text", - className: "badge-text", - attrs: { - text: subjectData.text, - "text-anchor": "middle", - dy: ".25em", - x: x, - y: y - } - }; - } - return { components: [pointer, circlebg, circle, text], handles: handles }; - }); - -var Type = function () { - function Type(_ref) { - var a = _ref.a, - annotation = _ref.annotation, - editMode = _ref.editMode, - dispatcher = _ref.dispatcher, - notePadding = _ref.notePadding, - accessors = _ref.accessors; - classCallCheck(this, Type); - - this.a = a; - - this.note = annotation.disable.indexOf("note") === -1 && a.select('g.annotation-note'); - this.noteContent = this.note && a.select('g.annotation-note-content'); - this.connector = annotation.disable.indexOf("connector") === -1 && a.select('g.annotation-connector'); - this.subject = annotation.disable.indexOf("subject") === -1 && a.select('g.annotation-subject'); - - if (dispatcher) { - var handler = addHandlers.bind(null, dispatcher, annotation); - handler({ component: this.note, name: 'note' }); - handler({ component: this.connector, name: 'connector' }); - handler({ component: this.subject, name: 'subject' }); - } - - this.annotation = annotation; - this.editMode = annotation.editMode || editMode; - this.notePadding = notePadding || 3; - this.offsetCornerX = 0; - this.offsetCornerY = 0; - - if (accessors && annotation.data) { - this.init(accessors); - } - } - - createClass(Type, [{ - key: 'init', - value: function init(accessors) { - if (!this.annotation.x) { - this.mapX(accessors); - } - if (!this.annotation.y) { - this.mapY(accessors); - } - } - }, { - key: 'mapY', - value: function mapY(accessors) { - if (accessors.y) { - this.annotation.y = accessors.y(this.annotation.data); - } - } - }, { - key: 'mapX', - value: function mapX(accessors) { - if (accessors.x) { - this.annotation.x = accessors.x(this.annotation.data); - } - } - }, { - key: 'updateEditMode', - value: function updateEditMode() { - this.a.selectAll('circle.handle').remove(); - } - }, { - key: 'drawOnSVG', - value: function drawOnSVG(component, builders) { - var _this = this; - - if (!Array.isArray(builders)) { - builders = [builders]; - } - - builders.filter(function (b) { - return b; - }).forEach(function (_ref2) { - var type = _ref2.type, - className = _ref2.className, - attrs = _ref2.attrs, - handles = _ref2.handles; - - if (type === "handle") { - addHandles({ group: component, r: attrs && attrs.r, handles: handles }); - } else { - (function () { - newWithClass(component, [_this.annotation], type, className); - - var el = component.select(type + '.' + className); - var attrKeys = Object.keys(attrs); - attrKeys.forEach(function (attr) { - if (attr === "text") { - el.text(attrs[attr]); - } else { - el.attr(attr, attrs[attr]); - } - }); - })(); - } - }); - } - - //TODO: how to extend this to a drawOnCanvas mode? - - }, { - key: 'getNoteBBox', - value: function getNoteBBox() { - return bboxWithoutHandles(this.note, '.annotation-note-content text'); - } - }, { - key: 'getNoteBBoxOffset', - value: function getNoteBBoxOffset() { - var bbox = bboxWithoutHandles(this.note, '.annotation-note-content'); - var transform = this.noteContent.attr('transform').split(/\(|\,|\)/g); - bbox.offsetCornerX = parseFloat(transform[1]) + this.annotation.dx; - bbox.offsetCornerY = parseFloat(transform[2]) + this.annotation.dy; - bbox.offsetX = this.annotation.dx; - bbox.offsetY = this.annotation.dy; - return bbox; - } - - // getConnectorBBox() { return bboxWithoutHandles(this.connector)} - // getSubjectBBox() { return bboxWithoutHandles(this.subject)} - // getAnnotationBBox() { return bboxWithoutHandles(this.a)} - - }, { - key: 'drawSubject', - value: function drawSubject() { - var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - var subjectData = this.annotation.subject; - var type = context.type; - var subjectParams = { type: this, subjectData: subjectData }; - - var subject = {}; - if (type === "circle") subject = subjectCircle(subjectParams);else if (type === "rect") subject = subjectRect(subjectParams);else if (type === "threshold") subject = subjectThreshold(subjectParams);else if (type === "badge") subject = subjectBadge(subjectParams); - - var _subject = subject, - _subject$components = _subject.components, - components = _subject$components === undefined ? [] : _subject$components, - _subject$handles = _subject.handles, - handles = _subject$handles === undefined ? [] : _subject$handles; - - if (this.editMode) { - handles = handles.concat(this.mapHandles([{ drag: this.dragSubject.bind(this) }])); - components.push({ type: "handle", handles: handles }); - } - - return components; - } - }, { - key: 'drawConnector', - value: function drawConnector() { - var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - var connectorData = this.annotation.connector; - var type = connectorData.type || context.type; - var connectorParams = { type: this, connectorData: connectorData }; - connectorParams.subjectType = this.typeSettings && this.typeSettings.subject && this.typeSettings.subject.type; - - var connector = {}; - if (type === "curve") connector = connectorCurve(connectorParams);else if (type === "elbow") connector = connectorElbow(connectorParams);else connector = connectorLine(connectorParams); - - var _connector = connector, - _connector$components = _connector.components, - components = _connector$components === undefined ? [] : _connector$components, - _connector$handles = _connector.handles, - handles = _connector$handles === undefined ? [] : _connector$handles; - - var line = components[0]; - var endType = connectorData.end || context.end; - var end = {}; - if (endType === "arrow") { - var s = line.data[1]; - var e = line.data[0]; - var distance = Math.sqrt(Math.pow(s[0] - e[0], 2) + Math.pow(s[1] - e[1], 2)); - if (distance < 5 && line.data[2]) { - s = line.data[2]; - } - - end = connectorArrow({ annotation: this.annotation, start: s, end: e }); - } else if (endType === "dot") { - end = connectorDot({ line: line }); - } - - if (end.components) { - components = components.concat(end.components); - } - - if (this.editMode) { - if (handles.length !== 0) components.push({ type: "handle", handles: handles }); - } - return components; - } - }, { - key: 'drawNote', - value: function drawNote() { - var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - var noteData = this.annotation.note; - var align = noteData.align || context.align || 'dynamic'; - var noteParams = { bbox: context.bbox, align: align, offset: this.annotation.offset }; - var lineType = noteData.lineType || context.lineType; - var note = {}; - if (lineType == "vertical") note = noteVertical(noteParams);else if (lineType == "horizontal") note = noteHorizontal(noteParams); - - var _note = note, - _note$components = _note.components, - components = _note$components === undefined ? [] : _note$components, - _note$handles = _note.handles, - handles = _note$handles === undefined ? [] : _note$handles; - - if (this.editMode) { - handles = this.mapHandles([{ x: 0, y: 0, drag: this.dragNote.bind(this) }]); - components.push({ type: "handle", handles: handles }); - } - return components; - } - }, { - key: 'drawNoteContent', - value: function drawNoteContent(context) { - var noteData = this.annotation.note; - var padding = noteData.padding || this.notePadding; - var orientation = noteData.orientation || context.orientation || 'topBottom'; - var lineType = noteData.lineType || context.lineType; - var align = noteData.align || context.align || 'dynamic'; - var subjectType = this.typeSettings && this.typeSettings.subject && this.typeSettings.subject.type; - - if (lineType == "vertical") orientation = "leftRight";else if (lineType == "horizontal") orientation = "topBottom"; - - var noteParams = { padding: padding, bbox: context.bbox, offset: this.annotation.offset, orientation: orientation, align: align }; - - var _noteAlignment = noteAlignment(noteParams), - x = _noteAlignment.x, - y = _noteAlignment.y; - - this.offsetCornerX = x + this.annotation.dx; - this.offsetCornerY = y + this.annotation.dy; - this.note && this.noteContent.attr('transform', 'translate(' + x + ', ' + y + ')'); - - return []; - } - }, { - key: 'drawOnScreen', - value: function drawOnScreen(component, drawFunction) { - return this.drawOnSVG(component, drawFunction); - } - }, { - key: 'redrawSubject', - value: function redrawSubject() { - this.subject && this.drawOnScreen(this.subject, this.drawSubject()); - } - }, { - key: 'redrawConnector', - value: function redrawConnector() { - var bbox = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getNoteBBox(); - - this.connector && this.drawOnScreen(this.connector, this.drawConnector()); - } - }, { - key: 'redrawNote', - value: function redrawNote() { - var bbox = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getNoteBBox(); - - this.noteContent && this.drawOnScreen(this.noteContent, this.drawNoteContent({ bbox: bbox })); - this.note && this.drawOnScreen(this.note, this.drawNote({ bbox: bbox })); - } - }, { - key: 'setPosition', - value: function setPosition() { - var position = this.annotation.position; - this.a.attr('transform', 'translate(' + position.x + ', ' + position.y + ')'); - } - }, { - key: 'setOffset', - value: function setOffset() { - if (this.note) { - var offset = this.annotation.offset; - this.note.attr('transform', 'translate(' + offset.x + ', ' + offset.y + ')'); - } - } - }, { - key: 'setPositionWithAccessors', - value: function setPositionWithAccessors(accessors) { - if (accessors && this.annotation.data) { - this.mapX(accessors); - this.mapY(accessors); - } - this.setPosition(); - } - }, { - key: 'setClassName', - value: function setClassName() { - this.a.attr("class", 'annotation ' + (this.className && this.className()) + ' ' + (this.editMode ? "editable" : "") + ' ' + (this.annotation.className || '')); - } - }, { - key: 'draw', - value: function draw() { - this.setClassName(); - this.setPosition(); - this.setOffset(); - this.redrawSubject(); - this.redrawConnector(); - this.redrawNote(); - } - }, { - key: 'dragstarted', - value: function dragstarted() { - d3Selection.event.sourceEvent.stopPropagation(); - this.a.classed("dragging", true); - this.a.selectAll("circle.handle").style("pointer-events", "none"); - } - }, { - key: 'dragended', - value: function dragended() { - this.a.classed("dragging", false); - this.a.selectAll("circle.handle").style("pointer-events", "all"); - } - }, { - key: 'dragSubject', - value: function dragSubject() { - var position = this.annotation.position; - position.x += d3Selection.event.dx; - position.y += d3Selection.event.dy; - this.annotation.position = position; - } - }, { - key: 'dragNote', - value: function dragNote() { - var offset = this.annotation.offset; - offset.x += d3Selection.event.dx; - offset.y += d3Selection.event.dy; - this.annotation.offset = offset; - } - }, { - key: 'mapHandles', - value: function mapHandles(handles) { - var _this2 = this; - - return handles.map(function (h) { - return _extends({}, h, { - start: _this2.dragstarted.bind(_this2), end: _this2.dragended.bind(_this2) }); - }); - } - }]); - return Type; - }(); - - var customType = function customType(initialType, typeSettings, _init) { - return function (_initialType) { - inherits(customType, _initialType); - - function customType(settings) { - classCallCheck(this, customType); - - var _this3 = possibleConstructorReturn(this, (customType.__proto__ || Object.getPrototypeOf(customType)).call(this, settings)); - - _this3.typeSettings = typeSettings; - - if (typeSettings.disable) { - typeSettings.disable.forEach(function (d) { - _this3[d] = undefined; - if (d == "note") { - _this3.noteContent = undefined; - } - }); - } - return _this3; - } - - createClass(customType, [{ - key: 'className', - value: function className() { - return (typeSettings.className || '') + ' ' + (get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'className', this) && get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'className', this).call(this) || ''); - } - }, { - key: 'drawSubject', - value: function drawSubject(context) { - this.typeSettings.subject = Object.assign({}, typeSettings.subject, this.typeSettings.subject); - return get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'drawSubject', this).call(this, _extends({}, context, this.typeSettings.subject)); - } - }, { - key: 'drawConnector', - value: function drawConnector(context, subjectContext) { - this.typeSettings.connector = Object.assign({}, typeSettings.connector, this.typeSettings.connector); - return get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'drawConnector', this).call(this, _extends({}, context, typeSettings.connector, this.typeSettings.connector)); - } - }, { - key: 'drawNote', - value: function drawNote(context) { - this.typeSettings.note = Object.assign({}, typeSettings.note, this.typeSettings.note); - return get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'drawNote', this).call(this, _extends({}, context, typeSettings.note, this.typeSettings.note)); - } - }, { - key: 'drawNoteContent', - value: function drawNoteContent(context) { - return get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'drawNoteContent', this).call(this, _extends({}, context, typeSettings.note, this.typeSettings.note)); - } - }], [{ - key: 'init', - value: function init(annotation, accessors) { - get(customType.__proto__ || Object.getPrototypeOf(customType), 'init', this).call(this, annotation, accessors); - if (_init) { - annotation = _init(annotation, accessors); - } - return annotation; - } - }]); - return customType; - }(initialType); - }; - - var d3NoteText = function (_Type) { - inherits(d3NoteText, _Type); - - function d3NoteText(params) { - classCallCheck(this, d3NoteText); - - var _this4 = possibleConstructorReturn(this, (d3NoteText.__proto__ || Object.getPrototypeOf(d3NoteText)).call(this, params)); - - _this4.textWrap = params.textWrap || 120; - _this4.drawText(); - return _this4; - } - - createClass(d3NoteText, [{ - key: 'updateTextWrap', - value: function updateTextWrap(textWrap) { - this.textWrap = textWrap; - this.drawText(); - } - - //TODO: add update text functionality - - }, { - key: 'drawText', - value: function drawText() { - if (this.note) { - - newWithClass(this.note, [this.annotation], 'g', 'annotation-note-content'); - - var noteContent = this.note.select('g.annotation-note-content'); - newWithClass(noteContent, [this.annotation], 'rect', 'annotation-note-bg'); - newWithClass(noteContent, [this.annotation], 'text', 'annotation-note-label'); - newWithClass(noteContent, [this.annotation], 'text', 'annotation-note-title'); - - var titleBBox = { height: 0 }; - var label = this.a.select('text.annotation-note-label'); - var wrapLength = this.annotation.note && this.annotation.note.wrap || this.typeSettings && this.typeSettings.note && this.typeSettings.note.wrap || this.textWrap; - - if (this.annotation.note.title) { - var title = this.a.select('text.annotation-note-title'); - title.text(this.annotation.note.title).attr('dy', '1.1em'); - title.call(wrap, wrapLength); - titleBBox = title.node().getBBox(); - } - - label.text(this.annotation.note.label).attr('dy', '1em'); - label.call(wrap, wrapLength); - - label.attr('y', titleBBox.height * 1.1 || 0); - - var bbox = this.getNoteBBox(); - this.a.select('rect.annotation-note-bg').attr('width', bbox.width).attr('height', bbox.height); - } - } - }]); - return d3NoteText; - }(Type); - - var d3Label = customType(d3NoteText, { - className: "label", - note: { align: "middle" } - }); - - var d3Callout = customType(d3NoteText, { - className: "callout", - note: { lineType: "horizontal" } - }); - - var d3CalloutElbow = customType(d3Callout, { - className: "callout elbow", - connector: { type: "elbow" } - }); - - var d3CalloutCurve = customType(d3Callout, { - className: "callout curve", - connector: { type: "curve" } - }); - - var d3Badge = customType(Type, { - className: "badge", - subject: { type: "badge" }, - disable: ['connector', 'note'] - }); - - var d3CalloutCircle = customType(d3CalloutElbow, { - className: "callout circle", - subject: { type: "circle" } - }); - - var d3CalloutRect = customType(d3CalloutElbow, { - className: "callout rect", - subject: { type: "rect" } - }); - - var ThresholdMap = function (_d3Callout) { - inherits(ThresholdMap, _d3Callout); - - function ThresholdMap() { - classCallCheck(this, ThresholdMap); - return possibleConstructorReturn(this, (ThresholdMap.__proto__ || Object.getPrototypeOf(ThresholdMap)).apply(this, arguments)); - } - - createClass(ThresholdMap, [{ - key: 'mapY', - value: function mapY(accessors) { - get(ThresholdMap.prototype.__proto__ || Object.getPrototypeOf(ThresholdMap.prototype), 'mapY', this).call(this, accessors); - var a = this.annotation; - if ((a.subject.x1 || a.subject.x2) && a.data && accessors.y) { - a.y = accessors.y(a.data); - } - } - }, { - key: 'mapX', - value: function mapX(accessors) { - get(ThresholdMap.prototype.__proto__ || Object.getPrototypeOf(ThresholdMap.prototype), 'mapX', this).call(this, accessors); - var a = this.annotation; - if ((a.subject.y1 || a.subject.y2) && a.data && accessors.x) { - a.x = accessors.x(a.data); - } - } - }]); - return ThresholdMap; - }(d3Callout); - - var d3XYThreshold = customType(ThresholdMap, { - className: "callout xythreshold", - subject: { type: "threshold" } - }); - - var newWithClass = function newWithClass(a, d, type, className) { - var group = a.selectAll(type + '.' + className).data(d); - group.enter().append(type).merge(group).attr('class', className); - - group.exit().remove(); - return a; - }; - - var addHandlers = function addHandlers(dispatcher, annotation, _ref3) { - var component = _ref3.component, - name = _ref3.name; - - if (component) { - component.on("mouseover.annotations", function () { - dispatcher.call(name + 'over', component, annotation); - }).on("mouseout.annotations", function () { - return dispatcher.call(name + 'out', component, annotation); - }).on("click.annotations", function () { - return dispatcher.call(name + 'click', component, annotation); - }); - } - }; - - //Text wrapping code adapted from Mike Bostock - var wrap = function wrap(text, width) { - text.each(function () { - var text = d3Selection.select(this), - words = text.text().split(/[ \t\r\n]+/).reverse(), - word, - line = [], - lineNumber = 0, - lineHeight = .2, - //ems - y = text.attr("y"), - dy = parseFloat(text.attr("dy")) || 0, - tspan = text.text(null).append("tspan").attr("x", 0).attr("dy", dy + "em"); - - while (word = words.pop()) { - line.push(word); - tspan.text(line.join(" ")); - if (tspan.node().getComputedTextLength() > width && line.length > 1) { - line.pop(); - tspan.text(line.join(" ")); - line = [word]; - tspan = text.append("tspan").attr("x", 0).attr("dy", lineHeight + dy + "em").text(word); - } - } - }); - }; - - var bboxWithoutHandles = function bboxWithoutHandles(selection) { - var selector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ':not(.handle)'; - - if (!selection) { - return { x: 0, y: 0, width: 0, height: 0 }; - } - - return selection.selectAll(selector).nodes().reduce(function (p, c) { - var bbox = c.getBBox(); - p.x = Math.min(p.x, bbox.x); - p.y = Math.min(p.y, bbox.y); - p.width = Math.max(p.width, bbox.width); - p.height += bbox.height; - return p; - }, { x: 0, y: 0, width: 0, height: 0 }); - }; - -function annotation() { - var annotations = [], - collection = void 0, - context = void 0, - //TODO: add canvas functionality - disable = [], - accessors = {}, - accessorsInverse = {}, - editMode = false, - ids = void 0, - type = d3Callout, - textWrap = void 0, - notePadding = void 0, - annotationDispatcher = d3Dispatch.dispatch("subjectover", "subjectout", "subjectclick", "connectorover", "connectorout", "connectorclick", "noteover", "noteout", "noteclick"), - sel = void 0; - - var annotation = function annotation(selection) { - sel = selection; - //TODO: check to see if this is still needed - if (!editMode) { - selection.selectAll("circle.handle").remove(); - } - - var translatedAnnotations = annotations.map(function (a) { - if (!a.type) { - a.type = type; - } - if (!a.disable) { - a.disable = disable; - } - return new Annotation(a); - }); - - collection = new AnnotationCollection({ - annotations: translatedAnnotations, - accessors: accessors, - accessorsInverse: accessorsInverse, - ids: ids - }); - - var annotationG = selection.selectAll('g').data([collection]); - annotationG.enter().append('g').attr('class', 'annotations'); - - var group = selection.select('g.annotations'); - newWithClass(group, collection.annotations, 'g', 'annotation'); - - var annotation = group.selectAll('g.annotation'); - - annotation.each(function (d) { - var a = d3Selection.select(this); var position = d.position; - - a.attr('class', 'annotation'); - - newWithClass(a, [d], 'g', 'annotation-connector'); - newWithClass(a, [d], 'g', 'annotation-subject'); - newWithClass(a, [d], 'g', 'annotation-note'); - newWithClass(a.select('g.annotation-note'), [d], 'g', 'annotation-note-content'); - - d.type = new d.type({ a: a, annotation: d, textWrap: textWrap, notePadding: notePadding, editMode: editMode, - dispatcher: annotationDispatcher, accessors: accessors }); - d.type.draw(); - }); - }; - - annotation.json = function () { - console.log('Annotations JSON was copied to your clipboard. Please note the annotation type is not JSON compatible. It appears in the objects array in the console, but not in the copied JSON.', collection.json); - window.copy(JSON.stringify(collection.json.map(function (a) { - delete a.type;return a; - }))); - return annotation; - }; - - annotation.update = function () { - if (annotations && collection) { - annotations = collection.annotations.map(function (a, i) { - a.type.draw();return a; - }); - } - return annotation; - }; - - annotation.updatedAccessors = function () { - collection.setPositionWithAccessors(); - annotations = collection.annotations; - return annotation; - }; - - annotation.disable = function (_) { - if (!arguments.length) return disable; - disable = _; - if (collection) { - collection.updateDisable(disable); - annotations = collection.annotations; - } - return annotation; - }; - - annotation.textWrap = function (_) { - if (!arguments.length) return textWrap; - textWrap = _; - if (collection) { - collection.updateTextWrap(textWrap); - annotations = collection.annotations; - } - return annotation; - }; - - annotation.notePadding = function (_) { - if (!arguments.length) return notePadding; - notePadding = _; - if (collection) { - collection.updateNotePadding(notePadding); - annotations = collection.annotations; - } - return annotation; - }; - - annotation.type = function (_, settings) { - if (!arguments.length) return type; - type = _; - if (collection) { - collection.annotations.map(function (a) { - - a.type.note && a.type.note.selectAll("*:not(.annotation-note-content)").remove(); - a.type.noteContent && a.type.noteContent.selectAll("*").remove(); - a.type.subject && a.type.subject.selectAll("*").remove(); - a.type.connector && a.type.connector.selectAll("*").remove(); - a.type.typeSettings = {}; - a.type = type; - - a.subject = settings && settings.subject || a.subject; - a.connector = settings && settings.connector || a.connector; - a.note = settings && settings.note || a.note; - }); - - annotations = collection.annotations; - } - return annotation; - }; - - annotation.annotations = function (_) { - if (!arguments.length) return collection && collection.annotations || annotations; - annotations = _; - return annotation; - }; - - annotation.context = function (_) { - if (!arguments.length) return context; - context = _; - return annotation; - }; - - annotation.accessors = function (_) { - if (!arguments.length) return accessors; - accessors = _; - return annotation; - }; - - annotation.accessorsInverse = function (_) { - if (!arguments.length) return accessorsInverse; - accessorsInverse = _; - return annotation; - }; - - annotation.ids = function (_) { - if (!arguments.length) return ids; - ids = _; - return annotation; - }; - - annotation.editMode = function (_) { - if (!arguments.length) return editMode; - editMode = _; - - if (sel) { - sel.selectAll('g.annotation').classed('editable', editMode); - } - - if (collection) { - collection.editMode(editMode); - annotations = collection.annotations; - } - return annotation; - }; - - annotation.collection = function (_) { - if (!arguments.length) return collection; - collection = _; - return annotation; - }; - - annotation.on = function () { - var value = annotationDispatcher.on.apply(annotationDispatcher, arguments); - return value === annotationDispatcher ? annotation : value; - }; - - return annotation; - }; - -var index = { annotation: annotation, - annotationTypeBase: Type, - annotationLabel: d3Label, - annotationCallout: d3Callout, - annotationCalloutCurve: d3CalloutCurve, - annotationCalloutElbow: d3CalloutElbow, - annotationCalloutCircle: d3CalloutCircle, - annotationCalloutRect: d3CalloutRect, - annotationXYThreshold: d3XYThreshold, - annotationBadge: d3Badge, - annotationCustomType: customType - }; - -export { annotation, Type as annotationTypeBase, d3Label as annotationLabel, d3Callout as annotationCallout, d3CalloutCurve as annotationCalloutCurve, d3CalloutElbow as annotationCalloutElbow, d3CalloutCircle as annotationCalloutCircle, d3CalloutRect as annotationCalloutRect, d3XYThreshold as annotationXYThreshold, d3Badge as annotationBadge, customType as annotationCustomType };export default index; -//# sourceMappingURL=indexRollup.mjs.map diff --git a/indexRollup.mjs.map b/indexRollup.mjs.map deleted file mode 100644 index 4d67945..0000000 --- a/indexRollup.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":null,"sources":["src/Annotation.js","src/AnnotationCollection.js","src/Handles.js","src/Note/alignment.js","src/Builder.js","src/Note/lineType-vertical.js","src/Note/lineType-horizontal.js","src/Connector/type-line.js","src/Connector/type-elbow.js","src/Connector/type-curve.js","src/Connector/end-arrow.js","src/Connector/end-dot.js","src/Subject/circle.js","src/Subject/rect.js","src/Subject/threshold.js","src/Subject/badge.js","src/Types-d3.js","src/Adapter-d3.js","index.js"],"sourcesContent":["\nexport default class Annotation {\n constructor({ x=0, y=0, dy=0, dx=0, data, type, subject, connector, note, \n disable, id, className }) {\n\n this._dx = dx\n this._dy = dy \n this._x = x \n this._y = y\n this.id = id\n this._className = className || ''\n\n this.type = type || ''\n this.data = data\n\n this.note = note || {}\n this.connector = connector || {}\n this.subject = subject || {}\n\n this.disable = disable || []\n }\n\n updatePosition(){\n if (this.type.setPosition) { \n this.type.setPosition() \n if (this.type.subject.selectAll(':not(.handle)').nodes().length !== 0) {\n this.type.redrawSubject()\n }\n }\n }\n\n get className() { return this._className }\n\n set className(className){\n this._className = className\n if (this.type.setClassName) this.type.setClassName()\n }\n\n updateOffset(){\n if (this.type.setOffset) {\n this.type.setOffset() \n \n if (this.type.connector.selectAll(':not(.handle)').nodes().length !== 0) {\n this.type.redrawConnector()\n }\n\n this.type.redrawNote()\n }\n }\n\n get x() { return this._x }\n set x(x) { \n this._x = x; \n this.updatePosition()\n }\n\n get y() { return this._y }\n set y(y) { \n this._y = y; \n this.updatePosition()\n }\n\n get dx() { return this._dx }\n set dx(dx) { \n this._dx = dx; \n this.updateOffset()\n }\n\n get dy() { return this._dy }\n set dy(dy) { \n this._dy = dy; \n this.updateOffset()\n }\n\n get offset() { return { x: this._dx, y: this._dy }}\n\n set offset({ x, y }) {\n this._dx = x\n this._dy = y\n this.updateOffset()\n }\n\n get position() { return { x: this._x, y: this._y }}\n\n set position({ x, y }) {\n this._x = x\n this._y = y\n this.updatePosition()\n }\n\n get translation() {\n return {\n x: this._x + this._dx,\n y: this._y + this._dy\n }}\n\n get json() { \n const json = {\n x: this._x,\n y: this._y,\n dx: this._dx,\n dy: this._dy\n }\n\n if (this.data && Object.keys(this.data).length > 0) json.data = this.data\n if (this.type) json.type = this.type\n if (this._className) json.className = this._className\n\n if (Object.keys(this.connector).length > 0) json.connector = this.connector\n if (Object.keys(this.subject).length > 0) json.subject = this.subject\n if (Object.keys(this.note).length > 0) json.note = this.note\n \n return json\n }\n}","export default class AnnotationCollection {\n\n constructor({ annotations, accessors, accessorsInverse }) {\n this.accessors = accessors\n this.accessorsInverse = accessorsInverse\n this.annotations = annotations\n }\n\n clearTypes(newSettings) {\n this.annotations.forEach(d => {\n d.type = undefined\n d.subject = newSettings && newSettings.subject || d.subject\n d.connector = newSettings && newSettings.connector || d.connector\n d.note = newSettings && newSettings.note || d.note\n })\n }\n\n setPositionWithAccessors() {\n this.annotations.forEach(d => {\n d.type.setPositionWithAccessors(this.accessors)\n })\n }\n\n editMode(editMode) { this.annotations.forEach(a => {\n if (a.type) {\n a.type.editMode = editMode\n a.type.updateEditMode()\n }\n })\n }\n\n updateDisable(disable) {\n this.annotations.forEach(a => {\n a.disable = disable\n if (a.type){\n disable.forEach(d => {\n if (a.type[d]){\n a.type[d].remove && a.type[d].remove()\n a.type[d] = undefined\n }\n })\n }\n })\n }\n\n updateTextWrap(textWrap) {\n this.annotations.forEach(a => {\n if (a.type && a.type.updateTextWrap){\n a.type.updateTextWrap(textWrap)\n }\n })\n }\n\n updateNotePadding(notePadding) {\n this.annotations.forEach(a => {\n if (a.type){\n a.type.notePadding = notePadding\n }\n })\n }\n\n get json() { \n return this.annotations.map(a => { \n const json = a.json\n if (this.accessorsInverse && a.data){\n json.data = {}\n Object.keys(this.accessorsInverse).forEach(k => {\n json.data[k] = this.accessorsInverse[k]({ x: a.x, y: a.y})\n\n //TODO make this feasible to map back to data for other types of subjects\n })\n }\n return json\n })\n }\n\n get noteNodes(){\n return this.annotations.map(a => ({ ...a.type.getNoteBBoxOffset(), positionX: a.x, positionY: a.y }))\n }\n\n //TODO: come back and rethink if a.x and a.y are applicable in all situations\n // get connectorNodes() {\n // return this.annotations.map(a => ({ ...a.type.getConnectorBBox(), startX: a.x, startY: a.y}))\n // }\n\n // get subjectNodes() {\n // return this.annotations.map(a => ({ ...a.type.getSubjectBBox(), startX: a.x, startY: a.y}))\n // }\n\n // get annotationNodes() {\n // return this.annotations.map(a => ({ ...a.type.getAnnotationBBox(), startX: a.x, startY: a.y}))\n // }\n}\n","import { select } from 'd3-selection'\nimport { drag } from 'd3-drag'\n\n\nexport const pointHandle = ({ cx=0, cy=0 }) => {\n return { move: { x: cx, y: cy} }\n}\n\nexport const circleHandles = ({ cx=0, cy =0, r1, r2, padding }) => {\n const h = { move: { x: cx, y: cy}}\n \n if (r1 !== undefined) {\n h.r1 = { x: cx + r1/Math.sqrt(2), y: cy + r1/Math.sqrt(2) }\n }\n \n if (r2 !== undefined) {\n h.r2 = { x: cx + r2/Math.sqrt(2), y: cy + r2/Math.sqrt(2) }\n }\n\n if (padding !== undefined) {\n h.padding = { x: cx + r1 + padding, y: cy}\n }\n\n return h\n}\n\nexport const rectHandles = ({ x1=0, y1=0, x2=x1, y2=y1, width, height }) => {\n \n const w = width || Math.abs(x2 - x1)\n const h = height || Math.abs(y2 - y1)\n\n return {\n move: {\n x: Math.min(x1, x2) + w/2,\n y: Math.min(y1, y2) - 10\n },\n width: {\n x: Math.max(x1, x2),\n y: Math.min(y1, y2) + h/2\n },\n height: {\n x: Math.min(x1, x2) + w/2,\n y: Math.max(y1, y2)\n }\n }\n}\n\nexport const lineHandles = ({ x1, y1, x2, y2, x, y}) => {\n\n const minY = Math.min(y1, y2)\n const minX = Math.min(x1, x2)\n\n const height = Math.abs(y2 - y1)\n const width = Math.abs(x2 - x1)\n \n return {\n move: {\n x: x || minX + width/2,\n y: y || minY + height/2\n }\n }\n}\n\n//arc handles\nexport const addHandles = ({ group, handles, r=10}) => { \n //give it a group and x,y to draw handles\n //then give it instructions on what the handles change \n const h = group.selectAll('circle.handle')\n .data(handles)\n\n h.enter()\n .append('circle')\n .attr('class', 'handle')\n .call(drag()\n .container(select('g.annotations').node())\n .on('start', d => d.start && d.start(d))\n .on('drag', d => d.drag && d.drag(d))\n .on('end', d => d.end && d.end(d))\n )\n\n group.selectAll('circle.handle')\n .attr('cx', d => d.x)\n .attr('cy', d => d.y)\n .attr('r', d => d.r || r)\n .attr('class', d => `handle ${d.className || ''}`)\n\n h.exit()\n .remove()\n \n}\n\n","\nexport const leftRightDynamic = (align, y) => {\n if (align == \"dynamic\" || align == \"left\" || align == \"right\"){\n if (y < 0){ align = \"top\" }\n else { align = \"bottom\" } \n }\n return align\n}\n\nexport const topBottomDynamic = (align, x) => {\n if (align == \"dynamic\" || align == \"top\" || align == \"bottom\"){\n if (x < 0){ align = \"right\" }\n else { align = \"left\" } \n }\n return align\n}\n\n\nexport default ({ padding, bbox, align, orientation, offset }) => {\n let x = -bbox.x \n let y = -bbox.y\n\n if ( orientation === \"topBottom\" ){\n align = topBottomDynamic(align, offset.x)\n if (offset.y < 0){ \n y -= (bbox.height + padding)\n } else {\n y += padding\n }\n\n if ( align === \"middle\" ) {\n x -= bbox.width/2\n } else if (align === \"right\" ) {\n x -= (bbox.width)\n } \n\n } else if ( orientation === \"leftRight\" ){\n align = leftRightDynamic(align, offset.y)\n if (offset.x < 0){ \n x -= (bbox.width + padding) \n } else {\n x += padding\n }\n\n if ( align === \"middle\" ) {\n y -= bbox.height/2\n } else if (align === \"top\" ){\n y -= (bbox.height )\n }\n } \n\n return { x, y }\n}","import { line, arc, curveLinear, symbol, symbolTriangle } from \"d3-shape\"\n\nexport const lineBuilder = ({ data, curve=curveLinear, canvasContext, className }) => { \n const lineGen = line()\n .curve(curve)\n\n const builder = {\n type: 'path',\n className,\n data\n }\n\n if (canvasContext) {\n lineGen.context(canvasContext)\n builder.pathMethods = lineGen\n\n } else {\n builder.attrs = {\n d: lineGen(data)\n }\n }\n\n return builder\n}\n\nexport const arcBuilder = ({ data, canvasContext, className }) => {\n\n const builder = {\n type: 'path',\n className,\n data\n }\n\n const arcShape = arc()\n .innerRadius(data.innerRadius || 0)\n .outerRadius(data.outerRadius || data.radius || 2)\n .startAngle(data.startAngle || 0)\n .endAngle(data.endAngle || 2*Math.PI)\n\n if (canvasContext) {\n arcShape.context(canvasContext)\n builder.pathMethods = lineGen\n\n } else {\n \n builder.attrs = {\n d: arcShape()\n }\n }\n\n return builder\n}","import { lineBuilder } from '../Builder'\nimport { leftRightDynamic } from './alignment'\n\nexport default ({ align, x=0, y=0, bbox, offset, padding }) => {\n align = leftRightDynamic(align, offset.y)\n\n if (align == \"top\") { y -= bbox.height } \n else if (align == \"middle\"){ y -= bbox.height/2 }\n\n const data = [[x, y], [x, y + bbox.height]]\n return { components: [lineBuilder({ data, className : \"note-line\" })] }\n}","import { lineBuilder } from '../Builder'\nimport { topBottomDynamic } from './alignment'\n\nexport default ({ align, x=0, y=0, offset, bbox, padding }) => {\n align = topBottomDynamic(align, offset.x)\n\n if (align == \"right\") { x -= bbox.width }\n else if (align == \"middle\"){ x -= bbox.width/2 }\n\n const data = [[x, y], [x + bbox.width, y]]\n return { components: [lineBuilder({ data, className : \"note-line\" })] }\n}","import { lineBuilder } from '../Builder'\n\nexport const lineSetup = ({ type, subjectType }) => {\n let annotation = type.annotation\n let offset = annotation.position\n \n let x1 = annotation.x - offset.x,\n x2 = x1 + annotation.dx,\n y1 = annotation.y - offset.y,\n y2 = y1 + annotation.dy\n\n\n const subjectData = annotation.subject\n\n if (subjectType == \"circle\" && (subjectData.outerRadius || subjectData.radius)){\n const h = Math.sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2))\n const angle = Math.asin(-y2/h)\n const r = subjectData.outerRadius || subjectData.radius + (subjectData.radiusPadding || 0)\n\n x1 = Math.abs(Math.cos(angle)*r)*(x2 < 0 ? -1 : 1)\n y1 = Math.abs(Math.sin(angle)*r)*(y2 < 0 ? -1 : 1)\n\n }\n\n if (subjectType == \"rect\"){\n const { width, height } = subjectData\n \n if ((width > 0 && annotation.dx > 0) || (width < 0 && annotation.dx < 0)) {\n if (Math.abs(width) > Math.abs(annotation.dx)) x1 = width/2\n else x1 = width\n } \n if ((height > 0 && annotation.dy > 0) || (height < 0 && annotation.dy < 0)) {\n if (Math.abs(height) > Math.abs(annotation.dy)) y1 = height/2\n else y1 = height\n }\n if (x1 == width/2 && y1 == height/2){ x1 = x2; y1 = y2;}\n }\n\n\n return [[x1, y1], [x2, y2]]\n}\n\nexport default (connectorData) => {\n const data = lineSetup(connectorData)\n return { components: [lineBuilder({ data, className : \"connector\" })]} \n}","import { lineBuilder } from '../Builder'\n\nexport default ({ type, subjectType }) => {\n\n const annotation = type.annotation\n const offset = annotation.position\n\n let x1 = annotation.x - offset.x,\n x2 = x1 + annotation.dx,\n y1 = annotation.y - offset.y,\n y2 = y1 + annotation.dy\n\n const subjectData = annotation.subject\n\n if (subjectType == \"rect\"){\n const { width, height } = subjectData\n \n if ((width > 0 && annotation.dx > 0) || (width < 0 && annotation.dx < 0)) {\n if (Math.abs(width) > Math.abs(annotation.dx)) x1 = width/2\n else x1 = width\n } \n if ((height > 0 && annotation.dy > 0) || (height < 0 && annotation.dy < 0)) {\n if (Math.abs(height) > Math.abs(annotation.dy)) y1 = height/2\n else y1 = height\n }\n if (x1 == width/2 && y1 == height/2){ x1 = x2; y1 = y2;}\n }\n\n let data = [[x1, y1], [x2, y2]]\n\n let diffY = (y2 - y1)\n let diffX = (x2 - x1)\n let xe = x2 \n let ye = y2\n let opposite = (y2 < y1 && x2 > x1 || x2 < x1 && y2 > y1)? -1 : 1\n\n if (Math.abs(diffX) < Math.abs(diffY)){\n xe = x2\n ye = y1 + diffX*opposite\n } else {\n ye = y2\n xe = x1 + diffY*opposite\n }\n \n if (subjectType == \"circle\" && (subjectData.outerRadius || subjectData.radius)){\n const r = (subjectData.outerRadius || subjectData.radius) + (subjectData.radiusPadding || 0)\n const length = r/Math.sqrt(2)\n\n if (Math.abs(diffX) > length && Math.abs(diffY) > length){\n x1 = length*(x2 < 0 ? -1 : 1)\n y1 = length*(y2 < 0 ? -1 : 1)\n data = [[x1, y1], [xe , ye ], [x2, y2]]\n\n } else if (Math.abs(diffX) > Math.abs(diffY)){\n const angle = Math.asin(-y2/r)\n x1 = Math.abs(Math.cos(angle)*r)*(x2 < 0 ? -1 : 1)\n data = [[ x1, y2], [x2, y2]]\n } else {\n const angle = Math.acos(x2/r)\n y1 = Math.abs(Math.sin(angle)*r)*(y2 < 0 ? -1 : 1)\n data = [[ x2, y1], [x2, y2]]\n }\n } else {\n data = [[x1, y1], [xe , ye], [x2, y2]]\n }\n\n return { components: [lineBuilder({ data, className: \"connector\"})]}\n}\n","import { lineBuilder } from '../Builder'\nimport { event } from 'd3-selection'\nimport { lineSetup } from './type-line'\nimport { curveCatmullRom } from 'd3-shape'\nimport { pointHandle } from '../Handles'\n\nexport default ({ type, connectorData, subjectType }) => {\n\n if (!connectorData){ connectorData = {} }\n if (!connectorData.points || typeof connectorData.points === \"number\"){ \n connectorData.points = createPoints(type.annotation.offset, connectorData.points) \n }\n if (!connectorData.curve){ connectorData.curve = curveCatmullRom }\n\n let handles = []\n\n if (type.editMode) {\n const cHandles = connectorData.points\n .map((c,i) => ({...pointHandle({cx: c[0], cy: c[1]}), index: i}))\n\n const updatePoint = (index) => { \n connectorData.points[index][0] += event.dx\n connectorData.points[index][1] += event.dy\n type.redrawConnector()\n }\n \n handles = type.mapHandles(cHandles\n .map(h => ({ ...h.move, drag: updatePoint.bind(type, h.index)})))\n\n }\n\n let data = lineSetup({ type, subjectType })\n data = [data[0], ...connectorData.points, data[1]]\n const components = [lineBuilder({ data, curve: connectorData.curve, className: \"connector\" })]\n\n return { components , handles }\n}\n\nconst createPoints = function( offset, anchors=2){\n const diff = { x: offset.x/(anchors + 1), y: offset.y/(anchors + 1) }\n const p = []\n\n let i = 1 \n for (; i <= anchors; i++){\n p.push([diff.x*i + i%2*20, diff.y*i - i%2*20])\n }\n return p\n}","import { lineBuilder } from '../Builder'\n\nexport default ({ annotation, start, end }) => {\n const offset = annotation.position\n if (!start) { start = [annotation.dx, annotation.dy]} \n else { start = [-end[0] + start[0], - end[1] + start[1]]}\n if (!end) { end = [annotation.x - offset.x, annotation.y - offset.y]}\n\n let x1 = end[0],\n y1 = end[1];\n\n let dx = start[0] \n let dy = start[1] \n\n let size = 10;\n let angleOffset = 16/180*Math.PI\n let angle = Math.atan(dy/dx) \n\n if (dx < 0 ) {\n angle += Math.PI\n }\n\n const data = [[x1, y1], \n [Math.cos(angle + angleOffset)*size + x1, Math.sin(angle + angleOffset)*size + y1],\n [Math.cos(angle - angleOffset)*size + x1, Math.sin(angle - angleOffset)*size + y1],\n [x1, y1]]\n\n //TODO add in reverse\n // if (canvasContext.arrowReverse){\n // data = [[x1, y1], \n // [Math.cos(angle + angleOffset)*size, Math.sin(angle + angleOffset)*size],\n // [Math.cos(angle - angleOffset)*size, Math.sin(angle - angleOffset)*size],\n // [x1, y1]\n // ]\n // } else {\n // data = [[x1, y1], \n // [Math.cos(angle + angleOffset)*size, Math.sin(angle + angleOffset)*size],\n // [Math.cos(angle - angleOffset)*size, Math.sin(angle - angleOffset)*size],\n // [x1, y1]\n // ]\n // }\n\n return { components: [lineBuilder({ data, className : 'connector-arrow' })] }\n}\n","import { arcBuilder } from '../Builder'\n\nexport default ({ line }) => {\n \n let dot = arcBuilder({ className: 'connector-dot', data: { radius: 3} })\n dot.attrs.transform = `translate(${line.data[0][0]}, ${line.data[0][1]})`\n \n return { components: [dot] }\n}\n","import { circleHandles } from '../Handles'\nimport { arcBuilder } from '../Builder'\nimport { event } from 'd3-selection'\n\nexport default ({ subjectData, type}) => {\n if (!subjectData.radius && !subjectData.outerRadius ){ subjectData.radius = 20 }\n\n let handles = []\n const c = arcBuilder({ data: subjectData, className: \"subject\" })\n if (type.editMode){\n const h = circleHandles({\n r1: c.data.outerRadius || c.data.radius,\n r2: c.data.innerRadius,\n padding: subjectData.radiusPadding\n })\n\n const updateRadius = (attr) => { \n const r = subjectData[attr] + event.dx*Math.sqrt(2)\n subjectData[attr] = r\n type.redrawSubject()\n type.redrawConnector()\n }\n\n const cHandles = [\n { ...h.r1, drag: updateRadius.bind(type, subjectData.outerRadius !== undefined ? 'outerRadius': 'radius')}\n ]\n\n if (subjectData.innerRadius){\n cHandles.push({ ...h.r2, drag: updateRadius.bind(type, 'innerRadius')})\n }\n handles = type.mapHandles(cHandles)\n }\n\n return { components: [c], handles }\n}","import { circleHandles } from '../Handles'\nimport { lineBuilder } from '../Builder'\nimport { event } from 'd3-selection'\n\nexport default ({ subjectData, type}) => {\n if (!subjectData.width){ subjectData.width = 100 }\n if (!subjectData.height){ subjectData.height = 100 }\n\n let handles = []\n let { width, height } = subjectData\n\n const data = [[0, 0], \n [ width, 0], \n [ width, height], \n [0, height],\n [0, 0]]\n let rect = lineBuilder({ data, className : 'subject'})\n\n if (type.editMode){\n\n const updateWidth = (attr) => { \n subjectData.width = event.x\n type.redrawSubject()\n type.redrawConnector()\n }\n\n const updateHeight = () => {\n subjectData.height = event.y\n type.redrawSubject()\n type.redrawConnector()\n }\n\n const rHandles = [{ x: width, y: height/2, drag: updateWidth.bind(type) },\n { x: width/2, y: height, drag: updateHeight.bind(type) }\n ]\n\n handles = type.mapHandles(rHandles)\n\n }\n\n return { components: [rect], handles }\n}","import { circleHandles } from '../Handles'\nimport { lineBuilder } from '../Builder'\n\n\nexport default ({ subjectData, type }) => {\n const offset = type.annotation.position\n\n let x1 = (subjectData.x1 !== undefined ? subjectData.x1 : offset.x) - offset.x,\n x2 = (subjectData.x2 !== undefined ? subjectData.x2 : offset.x) - offset.x,\n y1 = (subjectData.y1 !== undefined ? subjectData.y1 : offset.y) - offset.y,\n y2 = (subjectData.y2 !== undefined ? subjectData.y2 : offset.y) - offset.y\n\n const data = [[x1, y1], [x2, y2]]\n return { components: [lineBuilder({ data, className : 'subject'})]}\n}","import { circleHandles } from '../Handles'\nimport { lineBuilder, arcBuilder } from '../Builder'\nimport { event } from 'd3-selection'\n\nexport default ({ subjectData, type }) => {\n if (!subjectData.radius ) subjectData.radius = 14\n if (!subjectData.x) subjectData.x =\"left\"\n if (!subjectData.y) subjectData.y = \"top\"\n\n let handles = []\n const radius = subjectData.radius\n const innerRadius = radius*.7\n const x = subjectData.x == \"left\" ? -radius : radius\n const y = subjectData.y == \"top\" ? -radius : radius\n const transform = `translate(${x}, ${y})`\n const circlebg = arcBuilder({ className: 'subject', data: { radius} }) \n circlebg.attrs.transform = transform\n\n const circle = arcBuilder({ className: 'subject-ring', data: { outerRadius: radius, innerRadius} })\n circle.attrs.transform = transform\n\n const pointer = lineBuilder({ className: 'subject-pointer',\n data: [[0, 0], [x, 0], [0, y], [0, 0]]\n })\n\n if (type.editMode){\n\n const dragBadge = () => {\n subjectData.x = event.x < 0 ? \"left\" : \"right\"\n subjectData.y = event.y < 0 ? \"top\" : \"bottom\"\n type.redrawSubject()\n }\n\n const bHandles = [{ x: x*2, y: y*2, drag: dragBadge.bind(type)}]\n handles = type.mapHandles(bHandles)\n\n }\n\n let text\n if (subjectData.text){\n text = {\n type: \"text\",\n className: \"badge-text\",\n attrs: {\n text: subjectData.text,\n \"text-anchor\": \"middle\",\n dy: \".25em\",\n x,\n y\n }\n }\n }\n return { components: [pointer, circlebg, circle, text], handles }\n}","import { select, event } from 'd3-selection'\nimport { drag } from 'd3-drag'\nimport { Annotation } from './Annotation'\nimport { addHandles } from './Handles'\n\n//Note options\nimport noteAlignment from './Note/alignment'\nimport noteVertical from './Note/lineType-vertical'\nimport noteHorizontal from './Note/lineType-horizontal'\n\n//Connector options\nimport connectorLine from './Connector/type-line'\nimport connectorElbow from './Connector/type-elbow'\nimport connectorCurve from './Connector/type-curve'\nimport connectorArrow from './Connector/end-arrow'\nimport connectorDot from './Connector/end-dot'\n\n//Subject options\nimport subjectCircle from './Subject/circle'\nimport subjectRect from './Subject/rect'\nimport subjectThreshold from './Subject/threshold'\nimport subjectBadge from './Subject/badge'\n\nexport class Type {\n constructor({ a, annotation, editMode, dispatcher, notePadding, accessors }) {\n this.a = a\n\n this.note = annotation.disable.indexOf(\"note\") === -1 && a.select('g.annotation-note')\n this.noteContent = this.note && a.select('g.annotation-note-content')\n this.connector = annotation.disable.indexOf(\"connector\") === -1 && a.select('g.annotation-connector')\n this.subject = annotation.disable.indexOf(\"subject\") === -1 && a.select('g.annotation-subject')\n\n if (dispatcher){\n const handler = addHandlers.bind(null, dispatcher, annotation)\n handler({ component: this.note, name: 'note' })\n handler({ component: this.connector, name: 'connector' })\n handler({ component: this.subject, name: 'subject' })\n }\n \n this.annotation = annotation\n this.editMode = annotation.editMode || editMode\n this.notePadding = notePadding || 3\n this.offsetCornerX = 0\n this.offsetCornerY = 0\n\n if (accessors && annotation.data){\n this.init(accessors)\n }\n }\n\n init(accessors) {\n if (!this.annotation.x){\n this.mapX(accessors)\n }\n if (!this.annotation.y){\n this.mapY(accessors)\n }\n }\n\n mapY(accessors){\n if (accessors.y){\n this.annotation.y = accessors.y(this.annotation.data)\n }\n }\n\n mapX(accessors) {\n if (accessors.x){\n this.annotation.x = accessors.x(this.annotation.data)\n }\n }\n\n\n updateEditMode () {\n this.a.selectAll('circle.handle')\n .remove()\n }\n\n drawOnSVG (component, builders) {\n if (!Array.isArray(builders)){\n builders = [ builders ]\n }\n\n builders\n .filter(b => b)\n .forEach(({ type, className, attrs, handles}) => {\n if (type === \"handle\"){\n addHandles({ group: component, r: attrs && attrs.r, handles })\n } else {\n newWithClass(component, [this.annotation], type, className)\n \n const el = component.select(`${type}.${className}`) \n const attrKeys = Object.keys(attrs)\n attrKeys.forEach(attr => {\n if (attr === \"text\"){\n el.text(attrs[attr])\n } else {\n el.attr(attr, attrs[attr])\n }\n })\n }\n })\n }\n\n //TODO: how to extend this to a drawOnCanvas mode? \n\n getNoteBBox() { return bboxWithoutHandles(this.note, '.annotation-note-content text')}\n getNoteBBoxOffset() { \n const bbox = bboxWithoutHandles(this.note, '.annotation-note-content')\n const transform = this.noteContent.attr('transform').split(/\\(|\\,|\\)/g)\n bbox.offsetCornerX = parseFloat(transform[1]) + this.annotation.dx\n bbox.offsetCornerY = parseFloat(transform[2]) + this.annotation.dy\n bbox.offsetX = this.annotation.dx\n bbox.offsetY = this.annotation.dy\n return bbox \n }\n\n // getConnectorBBox() { return bboxWithoutHandles(this.connector)}\n // getSubjectBBox() { return bboxWithoutHandles(this.subject)}\n // getAnnotationBBox() { return bboxWithoutHandles(this.a)}\n\n drawSubject (context={}) {\n const subjectData = this.annotation.subject\n const type = context.type\n const subjectParams = { type: this, subjectData}\n\n let subject = {}\n if (type === \"circle\") subject = subjectCircle(subjectParams)\n else if (type === \"rect\") subject = subjectRect(subjectParams)\n else if (type === \"threshold\") subject = subjectThreshold(subjectParams)\n else if (type === \"badge\") subject = subjectBadge(subjectParams)\n\n let { components=[], handles=[] } = subject\n if (this.editMode){\n handles = handles.concat(this.mapHandles([{ drag: this.dragSubject.bind(this)}]))\n components.push({ type: \"handle\", handles })\n }\n\n return components\n }\n\n drawConnector (context={}) {\n const connectorData = this.annotation.connector\n const type = connectorData.type || context.type\n const connectorParams = { type: this, connectorData}\n connectorParams.subjectType = this.typeSettings && this.typeSettings.subject && this.typeSettings.subject.type \n\n let connector = {}\n if (type === \"curve\") connector = connectorCurve(connectorParams)\n else if (type === \"elbow\") connector = connectorElbow(connectorParams)\n else connector = connectorLine(connectorParams)\n\n let { components=[], handles=[] } = connector\n const line = components[0]\n const endType = connectorData.end || context.end\n let end = {}\n if (endType === \"arrow\") {\n let s = line.data[1]\n const e = line.data[0]\n const distance = Math.sqrt(Math.pow((s[0] - e[0]),2) + Math.pow((s[1] - e[1]),2))\n if (distance < 5 && line.data[2]) {\n s = line.data[2]\n }\n\n end = connectorArrow({ annotation: this.annotation, start: s, end: e })\n } else if (endType === \"dot\") {\n end = connectorDot({ line })\n }\n\n if (end.components){ components = components.concat(end.components)}\n\n if (this.editMode){\n if (handles.length !== 0) components.push({ type: \"handle\", handles })\n }\n return components;\n }\n\n drawNote (context={}) {\n const noteData = this.annotation.note\n const align = noteData.align || context.align || 'dynamic'\n const noteParams = { bbox: context.bbox, align, offset: this.annotation.offset }\n const lineType = noteData.lineType || context.lineType\n let note={}\n if (lineType == \"vertical\") note = noteVertical(noteParams)\n else if (lineType == \"horizontal\") note = noteHorizontal(noteParams)\n\n let { components=[], handles=[] } = note\n if (this.editMode) {\n handles = this.mapHandles([{ x: 0, y: 0, drag: this.dragNote.bind(this)}])\n components.push({ type: \"handle\", handles })\n }\n return components\n }\n\n drawNoteContent (context) {\n const noteData = this.annotation.note\n const padding = noteData.padding || this.notePadding\n let orientation = noteData.orientation || context.orientation || 'topBottom'\n const lineType = noteData.lineType || context.lineType\n const align = noteData.align || context.align || 'dynamic'\n const subjectType = this.typeSettings && this.typeSettings.subject && this.typeSettings.subject.type \n \n if (lineType == \"vertical\") orientation = \"leftRight\"\n else if (lineType == \"horizontal\") orientation = \"topBottom\"\n\n const noteParams = { padding, bbox: context.bbox, offset: \n this.annotation.offset, orientation, align }\n\n const { x, y } = noteAlignment(noteParams)\n this.offsetCornerX = x + this.annotation.dx\n this.offsetCornerY = y + this.annotation.dy\n this.note && this.noteContent.attr('transform', `translate(${x}, ${y})`)\n \n return []\n } \n\n drawOnScreen(component, drawFunction) { return this.drawOnSVG( component, drawFunction) }\n\n redrawSubject(){\n this.subject && this.drawOnScreen( this.subject, this.drawSubject())\n }\n\n redrawConnector(bbox=this.getNoteBBox()){\n this.connector && this.drawOnScreen( this.connector, this.drawConnector())\n }\n\n redrawNote(bbox=this.getNoteBBox()){\n this.noteContent && this.drawOnScreen( this.noteContent, this.drawNoteContent({ bbox }))\n this.note && this.drawOnScreen( this.note, this.drawNote({ bbox })) \n }\n\n setPosition(){\n const position = this.annotation.position \n this.a.attr('transform', `translate(${position.x}, ${position.y})`)\n }\n\n setOffset(){\n if (this.note){\n const offset = this.annotation.offset\n this.note.attr('transform', `translate(${offset.x}, ${offset.y})`)\n }\n }\n\n setPositionWithAccessors(accessors){\n if (accessors && this.annotation.data){\n this.mapX(accessors)\n this.mapY(accessors)\n }\n this.setPosition()\n }\n\n\n setClassName(){\n this.a.attr(\"class\", `annotation ${this.className && this.className()} ${this.editMode ? \"editable\" : \"\"} ${this.annotation.className || ''}`)\n }\n\n draw() {\n this.setClassName()\n this.setPosition()\n this.setOffset()\n this.redrawSubject()\n this.redrawConnector()\n this.redrawNote()\n }\n\n dragstarted() { event.sourceEvent.stopPropagation(); \n this.a.classed(\"dragging\", true) \n this.a.selectAll(\"circle.handle\").style(\"pointer-events\", \"none\")\n }\n dragended() { \n this.a.classed(\"dragging\", false)\n this.a.selectAll(\"circle.handle\").style(\"pointer-events\", \"all\")\n }\n\n dragSubject() {\n const position = this.annotation.position\n position.x += event.dx\n position.y += event.dy\n this.annotation.position = position\n }\n\n dragNote() {\n const offset = this.annotation.offset\n offset.x += event.dx\n offset.y += event.dy\n this.annotation.offset = offset\n }\n\n mapHandles(handles) {\n return handles\n .map(h => ({ ...h, \n start: this.dragstarted.bind(this), end: this.dragended.bind(this) }))\n }\n}\n\nexport const customType = (initialType, typeSettings, init) => {\n return class customType extends initialType {\n constructor (settings) {\n super(settings)\n this.typeSettings = typeSettings\n\n if (typeSettings.disable){\n typeSettings.disable.forEach(d => {\n this[d] = undefined\n if (d == \"note\"){\n this.noteContent = undefined\n }\n })\n }\n }\n\n static init(annotation, accessors){ \n super.init(annotation, accessors); \n if (init) {\n annotation = init(annotation, accessors) \n }\n return annotation\n }\n\n className(){ return `${typeSettings.className || ''} ${super.className && super.className() || ''}`}\n\n drawSubject(context){\n this.typeSettings.subject = Object.assign({}, typeSettings.subject, this.typeSettings.subject)\n return super.drawSubject({ ...context, ...this.typeSettings.subject })\n }\n\n drawConnector(context, subjectContext){\n this.typeSettings.connector = Object.assign({}, typeSettings.connector, this.typeSettings.connector)\n return super.drawConnector({ ...context, ...typeSettings.connector, ...this.typeSettings.connector })\n }\n\n drawNote(context){\n this.typeSettings.note = Object.assign({}, typeSettings.note, this.typeSettings.note)\n return super.drawNote({ ...context, ...typeSettings.note, ...this.typeSettings.note })\n }\n\n drawNoteContent(context){\n return super.drawNoteContent({ ...context, ...typeSettings.note, ...this.typeSettings.note })\n }\n }\n}\n\nexport class d3NoteText extends Type {\n\n constructor(params){\n super(params)\n this.textWrap = params.textWrap || 120\n this.drawText()\n }\n\n updateTextWrap (textWrap) {\n this.textWrap = textWrap\n this.drawText()\n }\n\n //TODO: add update text functionality\n\n drawText () {\n if (this.note){\n \n newWithClass(this.note, [this.annotation], 'g', 'annotation-note-content')\n\n const noteContent = this.note.select('g.annotation-note-content')\n newWithClass(noteContent, [this.annotation], 'rect', 'annotation-note-bg')\n newWithClass(noteContent, [this.annotation], 'text', 'annotation-note-label')\n newWithClass(noteContent, [this.annotation], 'text', 'annotation-note-title')\n\n let titleBBox = { height: 0 }\n const label = this.a.select('text.annotation-note-label')\n const wrapLength = this.annotation.note && this.annotation.note.wrap || \n this.typeSettings && this.typeSettings.note && this.typeSettings.note.wrap ||\n this.textWrap \n\n if (this.annotation.note.title){\n const title = this.a.select('text.annotation-note-title')\n title.text(this.annotation.note.title)\n .attr('dy', '1.1em')\n title.call(wrap, wrapLength)\n titleBBox = title.node().getBBox()\n }\n\n label.text(this.annotation.note.label)\n .attr('dy', '1em')\n label.call(wrap, wrapLength)\n\n label.attr('y', titleBBox.height * 1.1 || 0)\n\n const bbox = this.getNoteBBox()\n this.a.select('rect.annotation-note-bg')\n .attr('width', bbox.width)\n .attr('height', bbox.height)\n }\n }\n}\n\nexport const d3Label = customType(d3NoteText, {\n className: \"label\", \n note: { align: \"middle\"}\n})\n\nexport const d3Callout = customType(d3NoteText, {\n className: \"callout\",\n note: { lineType: \"horizontal\" }\n})\n\nexport const d3CalloutElbow = customType(d3Callout, {\n className: \"callout elbow\",\n connector: { type: \"elbow\" }\n})\n\nexport const d3CalloutCurve = customType(d3Callout, {\n className: \"callout curve\",\n connector: { type: \"curve\" }\n})\n\nexport const d3Badge = customType(Type, {\n className: \"badge\",\n subject: { type: \"badge\"},\n disable: ['connector', 'note']\n})\n\n\nexport const d3CalloutCircle = customType(d3CalloutElbow, {\n className: \"callout circle\",\n subject: { type: \"circle\"}\n})\n\nexport const d3CalloutRect = customType(d3CalloutElbow, {\n className: \"callout rect\",\n subject: { type: \"rect\"}\n})\n\n\nclass ThresholdMap extends d3Callout {\n\n mapY(accessors){\n super.mapY(accessors)\n const a = this.annotation\n if ((a.subject.x1 || a.subject.x2) && a.data && accessors.y){\n a.y = accessors.y(a.data)\n }\n }\n\n mapX(accessors) {\n super.mapX(accessors)\n const a = this.annotation\n if ((a.subject.y1 || a.subject.y2) && a.data && accessors.x){\n a.x = accessors.x(a.data)\n }\n }\n}\n\nexport const d3XYThreshold = customType(ThresholdMap, {\n className: \"callout xythreshold\",\n subject: { type: \"threshold\"}\n})\n\n\n\nexport const newWithClass = (a, d, type, className) => {\n const group = a.selectAll(`${type}.${className}`).data(d)\n group.enter()\n .append(type)\n .merge(group)\n .attr('class', className)\n\n group.exit().remove()\n return a\n}\n\n\nconst addHandlers = ( dispatcher, annotation, { component, name }) => {\n if (component){\n component\n .on(\"mouseover.annotations\", () => {\n dispatcher.call(`${name}over`, component, annotation)})\n .on(\"mouseout.annotations\", () => dispatcher.call(`${name}out`, component, annotation))\n .on(\"click.annotations\", () => dispatcher.call(`${name}click`, component, annotation))\n }\n}\n\n//Text wrapping code adapted from Mike Bostock\nconst wrap = (text, width) => {\n text.each(function() {\n var text = select(this),\n words = text.text().split(/[ \\t\\r\\n]+/).reverse(),\n word,\n line = [],\n lineNumber = 0,\n lineHeight = .2, //ems\n y = text.attr(\"y\"),\n dy = parseFloat(text.attr(\"dy\")) || 0,\n tspan = text.text(null)\n .append(\"tspan\")\n .attr(\"x\", 0)\n .attr(\"dy\", dy + \"em\");\n\n while (word = words.pop()) {\n line.push(word);\n tspan.text(line.join(\" \"));\n if (tspan.node().getComputedTextLength() > width && line.length > 1) {\n line.pop();\n tspan.text(line.join(\" \"));\n line = [word];\n tspan = text.append(\"tspan\")\n .attr(\"x\", 0)\n .attr(\"dy\", lineHeight + dy + \"em\").text(word);\n }\n }\n });\n}\n\nconst bboxWithoutHandles = (selection, selector=':not(.handle)') => {\n if (!selection){\n return { x: 0, y: 0, width: 0, height: 0}\n }\n\n return selection.selectAll(selector).nodes().reduce((p, c) => {\n const bbox = c.getBBox()\n p.x = Math.min(p.x, bbox.x)\n p.y = Math.min(p.y, bbox.y)\n p.width = Math.max(p.width, bbox.width)\n p.height += bbox.height\n return p\n }, { x: 0, y: 0, width: 0, height: 0});\n}\n\nexport default {\n Type,\n d3Label,\n d3Callout,\n d3CalloutElbow,\n d3CalloutCurve,\n d3CalloutCircle,\n d3CalloutRect,\n d3XYThreshold,\n d3Badge,\n customType\n}\n","import Annotation from './Annotation'\nimport AnnotationCollection from './AnnotationCollection'\nimport { newWithClass, d3Callout } from './Types-d3'\nimport { select } from 'd3-selection'\nimport { dispatch } from 'd3-dispatch';\n\n\nexport default function annotation(){\n let annotations = [],\n collection,\n context, //TODO: add canvas functionality\n disable = [],\n accessors = {},\n accessorsInverse = {},\n editMode = false,\n ids,\n type = d3Callout,\n textWrap,\n notePadding,\n annotationDispatcher = dispatch(\n \"subjectover\", \"subjectout\", \"subjectclick\", \n \"connectorover\", \"connectorout\", \"connectorclick\", \n \"noteover\", \"noteout\", \"noteclick\"),\n sel;\n\n const annotation = function(selection){\n sel = selection\n //TODO: check to see if this is still needed \n if (!editMode){\n selection.selectAll(\"circle.handle\")\n .remove()\n }\n\n const translatedAnnotations = annotations\n .map(a => {\n if (!a.type) { a.type = type }\n if (!a.disable) {a.disable = disable}\n return new Annotation(a)\n });\n\n collection = new AnnotationCollection ({\n annotations: translatedAnnotations,\n accessors,\n accessorsInverse,\n ids\n })\n \n\n const annotationG = selection.selectAll('g').data([collection])\n annotationG.enter().append('g').attr('class', `annotations`)\n \n const group = selection.select('g.annotations')\n newWithClass(group, collection.annotations, 'g', 'annotation')\n\n const annotation = group.selectAll('g.annotation')\n \n annotation \n .each(function(d) {\n const a = select(this)\n const position = d.position\n\n a.attr('class', 'annotation')\n\n newWithClass(a, [d], 'g', 'annotation-connector')\n newWithClass(a, [d], 'g', 'annotation-subject')\n newWithClass(a, [d], 'g', 'annotation-note')\n newWithClass(a.select('g.annotation-note'), [d], 'g', 'annotation-note-content')\n\n d.type = new d.type({ a, annotation: d, textWrap, notePadding, editMode, \n dispatcher: annotationDispatcher, accessors })\n d.type.draw()\n })\n }\n\n annotation.json = function() {\n console.log('Annotations JSON was copied to your clipboard. Please note the annotation type is not JSON compatible. It appears in the objects array in the console, but not in the copied JSON.', collection.json)\n window.copy(JSON.stringify(collection.json.map(a => { delete a.type; return a })))\n return annotation\n }\n\n annotation.update = function(){\n if (annotations && collection){\n annotations = collection.annotations.map((a, i) => { a.type.draw(); return a }) \n }\n return annotation\n }\n\n annotation.updatedAccessors = function(){\n collection.setPositionWithAccessors()\n annotations = collection.annotations\n return annotation\n }\n\n annotation.disable = function(_){\n if (!arguments.length) return disable;\n disable = _\n if (collection) { \n collection.updateDisable(disable)\n annotations = collection.annotations\n }\n return annotation;\n }\n\n annotation.textWrap = function(_){\n if (!arguments.length) return textWrap;\n textWrap = _\n if (collection) { \n collection.updateTextWrap(textWrap)\n annotations = collection.annotations\n }\n return annotation;\n }\n\n annotation.notePadding = function(_){\n if (!arguments.length) return notePadding;\n notePadding = _\n if (collection) { \n collection.updateNotePadding(notePadding)\n annotations = collection.annotations\n }\n return annotation;\n }\n\n annotation.type = function(_, settings) {\n if (!arguments.length) return type;\n type = _;\n if (collection) { \n collection.annotations.map(a => {\n \n a.type.note && a.type.note.selectAll(\"*:not(.annotation-note-content)\").remove()\n a.type.noteContent && a.type.noteContent.selectAll(\"*\").remove()\n a.type.subject && a.type.subject.selectAll(\"*\").remove()\n a.type.connector && a.type.connector.selectAll(\"*\").remove()\n a.type.typeSettings = {}\n a.type = type\n\n a.subject = settings && settings.subject || a.subject\n a.connector = settings && settings.connector || a.connector\n a.note = settings && settings.note || a.note\n })\n\n annotations = collection.annotations\n }\n return annotation;\n }\n\n annotation.annotations = function(_) {\n if (!arguments.length) return collection && collection.annotations || annotations;\n annotations = _\n return annotation;\n };\n\n annotation.context = function(_) {\n if (!arguments.length) return context;\n context = _\n return annotation;\n }; \n\n annotation.accessors = function(_) {\n if (!arguments.length) return accessors;\n accessors = _;\n return annotation\n }\n\n annotation.accessorsInverse = function(_) {\n if (!arguments.length) return accessorsInverse;\n accessorsInverse = _;\n return annotation\n }\n\n annotation.ids = function(_) {\n if (!arguments.length) return ids;\n ids = _;\n return annotation\n }\n\n annotation.editMode = function(_) {\n if (!arguments.length) return editMode;\n editMode = _\n\n if (sel){\n sel.selectAll('g.annotation')\n .classed('editable', editMode)\n }\n\n if (collection) { \n collection.editMode(editMode)\n annotations = collection.annotations\n }\n return annotation\n }\n\n annotation.collection = function(_) {\n if (!arguments.length) return collection;\n collection = _\n return annotation\n }\n\n annotation.on = function(){\n const value = annotationDispatcher.on.apply(annotationDispatcher, arguments)\n return value === annotationDispatcher ? annotation : value;\n }\n\n return annotation;\n\n};","import annotation from './src/Adapter-d3'\nimport { Type, d3Label, d3Callout, d3CalloutCurve, d3CalloutElbow, d3CalloutCircle, \n d3CalloutRect, d3XYThreshold, d3Badge, customType } from './src/Types-d3'\n\nexport {\n annotation,\n Type as annotationTypeBase ,\n d3Label as annotationLabel ,\n d3Callout as annotationCallout ,\n d3CalloutCurve as annotationCalloutCurve ,\n d3CalloutElbow as annotationCalloutElbow ,\n d3CalloutCircle as annotationCalloutCircle ,\n d3CalloutRect as annotationCalloutRect ,\n d3XYThreshold as annotationXYThreshold ,\n d3Badge as annotationBadge ,\n customType as annotationCustomType \n}\n\nexport default {\n annotation,\n annotationTypeBase : Type,\n annotationLabel : d3Label,\n annotationCallout : d3Callout,\n annotationCalloutCurve : d3CalloutCurve,\n annotationCalloutElbow : d3CalloutElbow,\n annotationCalloutCircle : d3CalloutCircle,\n annotationCalloutRect : d3CalloutRect,\n annotationXYThreshold : d3XYThreshold,\n annotationBadge : d3Badge,\n annotationCustomType : customType\n}"],"names":["Annotation","x","y","dy","dx","data","type","subject","connector","note","disable","id","className","_dx","_dy","_x","_y","_className","setPosition","selectAll","nodes","length","redrawSubject","setOffset","redrawConnector","redrawNote","setClassName","updatePosition","updateOffset","json","Object","keys","AnnotationCollection","annotations","accessors","accessorsInverse","newSettings","forEach","d","undefined","setPositionWithAccessors","editMode","a","updateEditMode","remove","textWrap","updateTextWrap","notePadding","map","k","getNoteBBoxOffset","positionX","positionY","pointHandle","cx","cy","move","circleHandles","r1","r2","padding","h","Math","sqrt","addHandles","group","handles","r","enter","append","attr","call","drag","container","select","node","on","start","end","exit","leftRightDynamic","align","topBottomDynamic","bbox","orientation","offset","height","width","lineBuilder","curve","curveLinear","canvasContext","lineGen","line","builder","context","pathMethods","attrs","arcBuilder","arcShape","arc","innerRadius","outerRadius","radius","startAngle","endAngle","PI","components","lineSetup","subjectType","annotation","position","x1","x2","y1","y2","subjectData","angle","asin","radiusPadding","abs","cos","sin","connectorData","diffY","diffX","xe","ye","opposite","acos","points","createPoints","curveCatmullRom","cHandles","c","i","index","updatePoint","event","mapHandles","bind","anchors","diff","p","push","size","angleOffset","atan","dot","transform","updateRadius","rect","updateWidth","updateHeight","rHandles","circlebg","circle","pointer","dragBadge","bHandles","text","Type","dispatcher","indexOf","noteContent","handler","addHandlers","component","name","offsetCornerX","offsetCornerY","init","mapX","mapY","builders","Array","isArray","filter","b","newWithClass","el","attrKeys","bboxWithoutHandles","split","parseFloat","offsetX","offsetY","subjectParams","subjectCircle","subjectRect","subjectThreshold","subjectBadge","concat","dragSubject","connectorParams","typeSettings","connectorCurve","connectorElbow","connectorLine","endType","s","e","distance","pow","connectorArrow","connectorDot","noteData","noteParams","lineType","noteVertical","noteHorizontal","dragNote","noteAlignment","drawFunction","drawOnSVG","drawOnScreen","drawSubject","getNoteBBox","drawConnector","drawNoteContent","drawNote","sourceEvent","stopPropagation","classed","style","dragstarted","dragended","customType","initialType","settings","babelHelpers.get","assign","subjectContext","d3NoteText","params","drawText","titleBBox","label","wrapLength","wrap","title","getBBox","d3Label","d3Callout","d3CalloutElbow","d3CalloutCurve","d3Badge","d3CalloutCircle","d3CalloutRect","ThresholdMap","d3XYThreshold","merge","each","words","reverse","word","lineNumber","lineHeight","tspan","pop","join","getComputedTextLength","selection","selector","reduce","min","max","collection","ids","annotationDispatcher","dispatch","sel","translatedAnnotations","annotationG","draw","console","log","window","copy","JSON","stringify","update","updatedAccessors","_","arguments","updateDisable","updateNotePadding","value","apply","annotationTypeBase","annotationLabel","annotationCallout","annotationCalloutCurve","annotationCalloutElbow","annotationCalloutCircle","annotationCalloutRect","annotationXYThreshold","annotationBadge","annotationCustomType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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sP,UAAP;AACvBA,EAAAA,iBAAagB,CAAb;AACA,EAAA,WAAO7K,UAAP;AACD,EAAA,GAJD;;AAMAA,EAAAA,aAAWlC,EAAX,GAAgB,YAAU;AACxB,EAAA,QAAMmN,QAAQlB,qBAAqBjM,EAArB,CAAwBoN,KAAxB,CAA8BnB,oBAA9B,EAAoDe,SAApD,CAAd;AACA,EAAA,WAAOG,UAAUlB,oBAAV,GAAiC/J,UAAjC,GAA8CiL,KAArD;AACD,EAAA,GAHD;;AAKA,EAAA,SAAOjL,UAAP;AAED,EAAA;;AC3LD,YAAe,CACbA,EAAAA,wBADa;AAEbmL,EAAAA,sBAAqBhI,IAFR;AAGbiI,EAAAA,mBAAkBhD,OAHL;AAIbiD,EAAAA,qBAAoBhD,SAJP;AAKbiD,EAAAA,0BAAyB/C,cALZ;AAMbgD,EAAAA,0BAAyBjD,cANZ;AAObkD,EAAAA,2BAA0B/C,eAPb;AAQbgD,EAAAA,yBAAwB/C,aARX;AASbgD,EAAAA,yBAAwB9C,aATX;AAUb+C,EAAAA,mBAAkBnD,OAVL;AAWboD,EAAAA,wBAAuBvE;AAXV,EAAA,CAAf;;"} \ No newline at end of file diff --git a/indexRollupNext.js b/indexRollupNext.js new file mode 100644 index 0000000..03ea71d --- /dev/null +++ b/indexRollupNext.js @@ -0,0 +1,1852 @@ +import { event, select } from 'd3-selection'; +import { drag } from 'd3-drag'; +import { arc, curveCatmullRom, curveLinear, line } from 'd3-shape'; +import { dispatch } from 'd3-dispatch'; + +var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +}; + +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 _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 get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + + if (getter === undefined) { + return undefined; + } + + return getter.call(receiver); + } +}; + +var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + 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 possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; +}; + + + + + + + + + + + + + + + + + + + +var toConsumableArray = function (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); + } +}; + +var Annotation = function () { + function Annotation(_ref) { + var _ref$x = _ref.x, + x = _ref$x === undefined ? 0 : _ref$x, + _ref$y = _ref.y, + y = _ref$y === undefined ? 0 : _ref$y, + _ref$dy = _ref.dy, + dy = _ref$dy === undefined ? 0 : _ref$dy, + _ref$dx = _ref.dx, + dx = _ref$dx === undefined ? 0 : _ref$dx, + data = _ref.data, + type = _ref.type, + subject = _ref.subject, + connector = _ref.connector, + note = _ref.note, + disable = _ref.disable, + id = _ref.id, + className = _ref.className; + classCallCheck(this, Annotation); + + + this._dx = dx; + this._dy = dy; + this._x = x; + this._y = y; + this.id = id; + this._className = className || ''; + + this.type = type || ''; + this.data = data; + + this.note = note || {}; + this.connector = connector || {}; + this.subject = subject || {}; + + this.disable = disable || []; + } + + createClass(Annotation, [{ + key: 'updatePosition', + value: function updatePosition() { + if (this.type.setPosition) { + this.type.setPosition(); + if (this.type.subject.selectAll(':not(.handle)').nodes().length !== 0) { + this.type.redrawSubject(); + } + } + } + }, { + key: 'updateOffset', + value: function updateOffset() { + if (this.type.setOffset) { + this.type.setOffset(); + + if (this.type.connector.selectAll(':not(.handle)').nodes().length !== 0) { + this.type.redrawConnector(); + } + + this.type.redrawNote(); + } + } + }, { + key: 'className', + get: function get$$1() { + return this._className; + }, + set: function set$$1(className) { + this._className = className; + if (this.type.setClassName) this.type.setClassName(); + } + }, { + key: 'x', + get: function get$$1() { + return this._x; + }, + set: function set$$1(x) { + this._x = x; + this.updatePosition(); + } + }, { + key: 'y', + get: function get$$1() { + return this._y; + }, + set: function set$$1(y) { + this._y = y; + this.updatePosition(); + } + }, { + key: 'dx', + get: function get$$1() { + return this._dx; + }, + set: function set$$1(dx) { + this._dx = dx; + this.updateOffset(); + } + }, { + key: 'dy', + get: function get$$1() { + return this._dy; + }, + set: function set$$1(dy) { + this._dy = dy; + this.updateOffset(); + } + }, { + key: 'offset', + get: function get$$1() { + return { x: this._dx, y: this._dy }; + }, + set: function set$$1(_ref2) { + var x = _ref2.x, + y = _ref2.y; + + this._dx = x; + this._dy = y; + this.updateOffset(); + } + }, { + key: 'position', + get: function get$$1() { + return { x: this._x, y: this._y }; + }, + set: function set$$1(_ref3) { + var x = _ref3.x, + y = _ref3.y; + + this._x = x; + this._y = y; + this.updatePosition(); + } + }, { + key: 'translation', + get: function get$$1() { + return { + x: this._x + this._dx, + y: this._y + this._dy + }; + } + }, { + key: 'json', + get: function get$$1() { + var json = { + x: this._x, + y: this._y, + dx: this._dx, + dy: this._dy + }; + + if (this.data && Object.keys(this.data).length > 0) json.data = this.data; + if (this.type) json.type = this.type; + if (this._className) json.className = this._className; + + if (Object.keys(this.connector).length > 0) json.connector = this.connector; + if (Object.keys(this.subject).length > 0) json.subject = this.subject; + if (Object.keys(this.note).length > 0) json.note = this.note; + + return json; + } + }]); + return Annotation; +}(); + +var AnnotationCollection = function () { + function AnnotationCollection(_ref) { + var annotations = _ref.annotations, + accessors = _ref.accessors, + accessorsInverse = _ref.accessorsInverse; + classCallCheck(this, AnnotationCollection); + + this.accessors = accessors; + this.accessorsInverse = accessorsInverse; + this.annotations = annotations; + } + + createClass(AnnotationCollection, [{ + key: "clearTypes", + value: function clearTypes(newSettings) { + this.annotations.forEach(function (d) { + d.type = undefined; + d.subject = newSettings && newSettings.subject || d.subject; + d.connector = newSettings && newSettings.connector || d.connector; + d.note = newSettings && newSettings.note || d.note; + }); + } + }, { + key: "setPositionWithAccessors", + value: function setPositionWithAccessors() { + var _this = this; + + this.annotations.forEach(function (d) { + d.type.setPositionWithAccessors(_this.accessors); + }); + } + }, { + key: "editMode", + value: function editMode(_editMode) { + this.annotations.forEach(function (a) { + if (a.type) { + a.type.editMode = _editMode; + a.type.updateEditMode(); + } + }); + } + }, { + key: "updateDisable", + value: function updateDisable(disable) { + this.annotations.forEach(function (a) { + a.disable = disable; + if (a.type) { + disable.forEach(function (d) { + if (a.type[d]) { + a.type[d].remove && a.type[d].remove(); + a.type[d] = undefined; + } + }); + } + }); + } + }, { + key: "updateTextWrap", + value: function updateTextWrap(textWrap) { + this.annotations.forEach(function (a) { + if (a.type && a.type.updateTextWrap) { + a.type.updateTextWrap(textWrap); + } + }); + } + }, { + key: "updateNotePadding", + value: function updateNotePadding(notePadding) { + this.annotations.forEach(function (a) { + if (a.type) { + a.type.notePadding = notePadding; + } + }); + } + }, { + key: "json", + get: function get$$1() { + var _this2 = this; + + return this.annotations.map(function (a) { + var json = a.json; + if (_this2.accessorsInverse && a.data) { + json.data = {}; + Object.keys(_this2.accessorsInverse).forEach(function (k) { + json.data[k] = _this2.accessorsInverse[k]({ x: a.x, y: a.y }); + + //TODO make this feasible to map back to data for other types of subjects + }); + } + return json; + }); + } + }, { + key: "noteNodes", + get: function get$$1() { + return this.annotations.map(function (a) { + return _extends({}, a.type.getNoteBBoxOffset(), { positionX: a.x, positionY: a.y }); + }); + } + + //TODO: come back and rethink if a.x and a.y are applicable in all situations + // get connectorNodes() { + // return this.annotations.map(a => ({ ...a.type.getConnectorBBox(), startX: a.x, startY: a.y})) + // } + + // get subjectNodes() { + // return this.annotations.map(a => ({ ...a.type.getSubjectBBox(), startX: a.x, startY: a.y})) + // } + + // get annotationNodes() { + // return this.annotations.map(a => ({ ...a.type.getAnnotationBBox(), startX: a.x, startY: a.y})) + // } + + }]); + return AnnotationCollection; +}(); + +var pointHandle = function pointHandle(_ref) { + var _ref$cx = _ref.cx, + cx = _ref$cx === undefined ? 0 : _ref$cx, + _ref$cy = _ref.cy, + cy = _ref$cy === undefined ? 0 : _ref$cy; + + return { move: { x: cx, y: cy } }; +}; + +var circleHandles = function circleHandles(_ref2) { + var _ref2$cx = _ref2.cx, + cx = _ref2$cx === undefined ? 0 : _ref2$cx, + _ref2$cy = _ref2.cy, + cy = _ref2$cy === undefined ? 0 : _ref2$cy, + r1 = _ref2.r1, + r2 = _ref2.r2, + padding = _ref2.padding; + + var h = { move: { x: cx, y: cy } }; + + if (r1 !== undefined) { + h.r1 = { x: cx + r1 / Math.sqrt(2), y: cy + r1 / Math.sqrt(2) }; + } + + if (r2 !== undefined) { + h.r2 = { x: cx + r2 / Math.sqrt(2), y: cy + r2 / Math.sqrt(2) }; + } + + if (padding !== undefined) { + h.padding = { x: cx + r1 + padding, y: cy }; + } + + return h; +}; + + + + + +//arc handles +var addHandles = function addHandles(_ref5) { + var group = _ref5.group, + handles = _ref5.handles, + _ref5$r = _ref5.r, + r = _ref5$r === undefined ? 10 : _ref5$r; + + //give it a group and x,y to draw handles + //then give it instructions on what the handles change + var h = group.selectAll('circle.handle').data(handles); + + h.enter().append('circle').attr('class', 'handle').call(drag().container(select('g.annotations').node()).on('start', function (d) { + return d.start && d.start(d); + }).on('drag', function (d) { + return d.drag && d.drag(d); + }).on('end', function (d) { + return d.end && d.end(d); + })); + + group.selectAll('circle.handle').attr('cx', function (d) { + return d.x; + }).attr('cy', function (d) { + return d.y; + }).attr('r', function (d) { + return d.r || r; + }).attr('class', function (d) { + return 'handle ' + (d.className || ''); + }); + + h.exit().remove(); +}; + +var leftRightDynamic = function leftRightDynamic(align, y) { + if (align == "dynamic" || align == "left" || align == "right") { + if (y < 0) { + align = "top"; + } else { + align = "bottom"; + } + } + return align; +}; + +var topBottomDynamic = function topBottomDynamic(align, x) { + if (align == "dynamic" || align == "top" || align == "bottom") { + if (x < 0) { + align = "right"; + } else { + align = "left"; + } + } + return align; +}; + +var noteAlignment = (function (_ref) { + var padding = _ref.padding, + bbox = _ref.bbox, + align = _ref.align, + orientation = _ref.orientation, + offset = _ref.offset; + + var x = -bbox.x; + var y = -bbox.y; + + if (orientation === "topBottom") { + align = topBottomDynamic(align, offset.x); + if (offset.y < 0) { + y -= bbox.height + padding; + } else { + y += padding; + } + + if (align === "middle") { + x -= bbox.width / 2; + } else if (align === "right") { + x -= bbox.width; + } + } else if (orientation === "leftRight") { + align = leftRightDynamic(align, offset.y); + if (offset.x < 0) { + x -= bbox.width + padding; + } else { + x += padding; + } + + if (align === "middle") { + y -= bbox.height / 2; + } else if (align === "top") { + y -= bbox.height; + } + } + + return { x: x, y: y }; +}); + +var lineBuilder = function lineBuilder(_ref) { + var data = _ref.data, + _ref$curve = _ref.curve, + curve = _ref$curve === undefined ? curveLinear : _ref$curve, + canvasContext = _ref.canvasContext, + className = _ref.className; + + var lineGen = line().curve(curve); + + var builder = { + type: 'path', + className: className, + data: data + }; + + if (canvasContext) { + lineGen.context(canvasContext); + builder.pathMethods = lineGen; + } else { + builder.attrs = { + d: lineGen(data) + }; + } + + return builder; +}; + +var arcBuilder = function arcBuilder(_ref2) { + var data = _ref2.data, + canvasContext = _ref2.canvasContext, + className = _ref2.className; + + + var builder = { + type: 'path', + className: className, + data: data + }; + + var arcShape = arc().innerRadius(data.innerRadius || 0).outerRadius(data.outerRadius || data.radius || 2).startAngle(data.startAngle || 0).endAngle(data.endAngle || 2 * Math.PI); + + if (canvasContext) { + arcShape.context(canvasContext); + builder.pathMethods = lineGen; + } else { + + builder.attrs = { + d: arcShape() + }; + } + + return builder; +}; + +var noteVertical = (function (_ref) { + var align = _ref.align, + _ref$x = _ref.x, + x = _ref$x === undefined ? 0 : _ref$x, + _ref$y = _ref.y, + y = _ref$y === undefined ? 0 : _ref$y, + bbox = _ref.bbox, + offset = _ref.offset, + padding = _ref.padding; + + align = leftRightDynamic(align, offset.y); + + if (align == "top") { + y -= bbox.height; + } else if (align == "middle") { + y -= bbox.height / 2; + } + + var data = [[x, y], [x, y + bbox.height]]; + return { components: [lineBuilder({ data: data, className: "note-line" })] }; +}); + +var noteHorizontal = (function (_ref) { + var align = _ref.align, + _ref$x = _ref.x, + x = _ref$x === undefined ? 0 : _ref$x, + _ref$y = _ref.y, + y = _ref$y === undefined ? 0 : _ref$y, + offset = _ref.offset, + bbox = _ref.bbox, + padding = _ref.padding; + + align = topBottomDynamic(align, offset.x); + + if (align == "right") { + x -= bbox.width; + } else if (align == "middle") { + x -= bbox.width / 2; + } + + var data = [[x, y], [x + bbox.width, y]]; + return { components: [lineBuilder({ data: data, className: "note-line" })] }; +}); + +var lineSetup = function lineSetup(_ref) { + var type = _ref.type, + subjectType = _ref.subjectType; + + var annotation = type.annotation; + var offset = annotation.position; + + var x1 = annotation.x - offset.x, + x2 = x1 + annotation.dx, + y1 = annotation.y - offset.y, + y2 = y1 + annotation.dy; + + var subjectData = annotation.subject; + + if (subjectType == "circle" && (subjectData.outerRadius || subjectData.radius)) { + var h = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); + var angle = Math.asin(-y2 / h); + var r = subjectData.outerRadius || subjectData.radius + (subjectData.radiusPadding || 0); + + x1 = Math.abs(Math.cos(angle) * r) * (x2 < 0 ? -1 : 1); + y1 = Math.abs(Math.sin(angle) * r) * (y2 < 0 ? -1 : 1); + } + + if (subjectType == "rect") { + var width = subjectData.width, + height = subjectData.height; + + + if (width > 0 && annotation.dx > 0 || width < 0 && annotation.dx < 0) { + if (Math.abs(width) > Math.abs(annotation.dx)) x1 = width / 2;else x1 = width; + } + if (height > 0 && annotation.dy > 0 || height < 0 && annotation.dy < 0) { + if (Math.abs(height) > Math.abs(annotation.dy)) y1 = height / 2;else y1 = height; + } + if (x1 == width / 2 && y1 == height / 2) { + x1 = x2;y1 = y2; + } + } + + return [[x1, y1], [x2, y2]]; +}; + +var connectorLine = (function (connectorData) { + var data = lineSetup(connectorData); + return { components: [lineBuilder({ data: data, className: "connector" })] }; +}); + +var connectorElbow = (function (_ref) { + var type = _ref.type, + subjectType = _ref.subjectType; + + + var annotation = type.annotation; + var offset = annotation.position; + + var x1 = annotation.x - offset.x, + x2 = x1 + annotation.dx, + y1 = annotation.y - offset.y, + y2 = y1 + annotation.dy; + + var subjectData = annotation.subject; + + if (subjectType == "rect") { + var width = subjectData.width, + height = subjectData.height; + + + if (width > 0 && annotation.dx > 0 || width < 0 && annotation.dx < 0) { + if (Math.abs(width) > Math.abs(annotation.dx)) x1 = width / 2;else x1 = width; + } + if (height > 0 && annotation.dy > 0 || height < 0 && annotation.dy < 0) { + if (Math.abs(height) > Math.abs(annotation.dy)) y1 = height / 2;else y1 = height; + } + if (x1 == width / 2 && y1 == height / 2) { + x1 = x2;y1 = y2; + } + } + + var data = [[x1, y1], [x2, y2]]; + + var diffY = y2 - y1; + var diffX = x2 - x1; + var xe = x2; + var ye = y2; + var opposite = y2 < y1 && x2 > x1 || x2 < x1 && y2 > y1 ? -1 : 1; + + if (Math.abs(diffX) < Math.abs(diffY)) { + xe = x2; + ye = y1 + diffX * opposite; + } else { + ye = y2; + xe = x1 + diffY * opposite; + } + + if (subjectType == "circle" && (subjectData.outerRadius || subjectData.radius)) { + var r = (subjectData.outerRadius || subjectData.radius) + (subjectData.radiusPadding || 0); + var length = r / Math.sqrt(2); + + if (Math.abs(diffX) > length && Math.abs(diffY) > length) { + x1 = length * (x2 < 0 ? -1 : 1); + y1 = length * (y2 < 0 ? -1 : 1); + data = [[x1, y1], [xe, ye], [x2, y2]]; + } else if (Math.abs(diffX) > Math.abs(diffY)) { + var angle = Math.asin(-y2 / r); + x1 = Math.abs(Math.cos(angle) * r) * (x2 < 0 ? -1 : 1); + data = [[x1, y2], [x2, y2]]; + } else { + var _angle = Math.acos(x2 / r); + y1 = Math.abs(Math.sin(_angle) * r) * (y2 < 0 ? -1 : 1); + data = [[x2, y1], [x2, y2]]; + } + } else { + data = [[x1, y1], [xe, ye], [x2, y2]]; + } + + return { components: [lineBuilder({ data: data, className: "connector" })] }; +}); + +var connectorCurve = (function (_ref) { + var type = _ref.type, + connectorData = _ref.connectorData, + subjectType = _ref.subjectType; + + + if (!connectorData) { + connectorData = {}; + } + if (!connectorData.points || typeof connectorData.points === "number") { + connectorData.points = createPoints(type.annotation.offset, connectorData.points); + } + if (!connectorData.curve) { + connectorData.curve = curveCatmullRom; + } + + var handles = []; + + if (type.editMode) { + (function () { + var cHandles = connectorData.points.map(function (c, i) { + return _extends({}, pointHandle({ cx: c[0], cy: c[1] }), { index: i }); + }); + + var updatePoint = function updatePoint(index) { + connectorData.points[index][0] += event.dx; + connectorData.points[index][1] += event.dy; + type.redrawConnector(); + }; + + handles = type.mapHandles(cHandles.map(function (h) { + return _extends({}, h.move, { drag: updatePoint.bind(type, h.index) }); + })); + })(); + } + + var data = lineSetup({ type: type, subjectType: subjectType }); + data = [data[0]].concat(toConsumableArray(connectorData.points), [data[1]]); + var components = [lineBuilder({ data: data, curve: connectorData.curve, className: "connector" })]; + + return { components: components, handles: handles }; +}); + +var createPoints = function createPoints(offset) { + var anchors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2; + + var diff = { x: offset.x / (anchors + 1), y: offset.y / (anchors + 1) }; + var p = []; + + var i = 1; + for (; i <= anchors; i++) { + p.push([diff.x * i + i % 2 * 20, diff.y * i - i % 2 * 20]); + } + return p; +}; + +var connectorArrow = (function (_ref) { + var annotation = _ref.annotation, + start = _ref.start, + end = _ref.end; + + var offset = annotation.position; + if (!start) { + start = [annotation.dx, annotation.dy]; + } else { + start = [-end[0] + start[0], -end[1] + start[1]]; + } + if (!end) { + end = [annotation.x - offset.x, annotation.y - offset.y]; + } + + var x1 = end[0], + y1 = end[1]; + + var dx = start[0]; + var dy = start[1]; + + var size = 10; + var angleOffset = 16 / 180 * Math.PI; + var angle = Math.atan(dy / dx); + + if (dx < 0) { + angle += Math.PI; + } + + var data = [[x1, y1], [Math.cos(angle + angleOffset) * size + x1, Math.sin(angle + angleOffset) * size + y1], [Math.cos(angle - angleOffset) * size + x1, Math.sin(angle - angleOffset) * size + y1], [x1, y1]]; + + //TODO add in reverse + // if (canvasContext.arrowReverse){ + // data = [[x1, y1], + // [Math.cos(angle + angleOffset)*size, Math.sin(angle + angleOffset)*size], + // [Math.cos(angle - angleOffset)*size, Math.sin(angle - angleOffset)*size], + // [x1, y1] + // ] + // } else { + // data = [[x1, y1], + // [Math.cos(angle + angleOffset)*size, Math.sin(angle + angleOffset)*size], + // [Math.cos(angle - angleOffset)*size, Math.sin(angle - angleOffset)*size], + // [x1, y1] + // ] + // } + + return { components: [lineBuilder({ data: data, className: 'connector-arrow' })] }; +}); + +var connectorDot = (function (_ref) { + var line$$1 = _ref.line; + + + var dot = arcBuilder({ className: 'connector-dot', data: { radius: 3 } }); + dot.attrs.transform = 'translate(' + line$$1.data[0][0] + ', ' + line$$1.data[0][1] + ')'; + + return { components: [dot] }; +}); + +var subjectCircle = (function (_ref) { + var subjectData = _ref.subjectData, + type = _ref.type; + + if (!subjectData.radius && !subjectData.outerRadius) { + subjectData.radius = 20; + } + + var handles = []; + var c = arcBuilder({ data: subjectData, className: "subject" }); + if (type.editMode) { + var h = circleHandles({ + r1: c.data.outerRadius || c.data.radius, + r2: c.data.innerRadius, + padding: subjectData.radiusPadding + }); + + var updateRadius = function updateRadius(attr) { + var r = subjectData[attr] + event.dx * Math.sqrt(2); + subjectData[attr] = r; + type.redrawSubject(); + type.redrawConnector(); + }; + + var cHandles = [_extends({}, h.r1, { drag: updateRadius.bind(type, subjectData.outerRadius !== undefined ? 'outerRadius' : 'radius') })]; + + if (subjectData.innerRadius) { + cHandles.push(_extends({}, h.r2, { drag: updateRadius.bind(type, 'innerRadius') })); + } + handles = type.mapHandles(cHandles); + } + + return { components: [c], handles: handles }; +}); + +var subjectRect = (function (_ref) { + var subjectData = _ref.subjectData, + type = _ref.type; + + if (!subjectData.width) { + subjectData.width = 100; + } + if (!subjectData.height) { + subjectData.height = 100; + } + + var handles = []; + var width = subjectData.width, + height = subjectData.height; + + + var data = [[0, 0], [width, 0], [width, height], [0, height], [0, 0]]; + var rect = lineBuilder({ data: data, className: 'subject' }); + + if (type.editMode) { + + var updateWidth = function updateWidth(attr) { + subjectData.width = event.x; + type.redrawSubject(); + type.redrawConnector(); + }; + + var updateHeight = function updateHeight() { + subjectData.height = event.y; + type.redrawSubject(); + type.redrawConnector(); + }; + + var rHandles = [{ x: width, y: height / 2, drag: updateWidth.bind(type) }, { x: width / 2, y: height, drag: updateHeight.bind(type) }]; + + handles = type.mapHandles(rHandles); + } + + return { components: [rect], handles: handles }; +}); + +var subjectThreshold = (function (_ref) { + var subjectData = _ref.subjectData, + type = _ref.type; + + var offset = type.annotation.position; + + var x1 = (subjectData.x1 !== undefined ? subjectData.x1 : offset.x) - offset.x, + x2 = (subjectData.x2 !== undefined ? subjectData.x2 : offset.x) - offset.x, + y1 = (subjectData.y1 !== undefined ? subjectData.y1 : offset.y) - offset.y, + y2 = (subjectData.y2 !== undefined ? subjectData.y2 : offset.y) - offset.y; + + var data = [[x1, y1], [x2, y2]]; + return { components: [lineBuilder({ data: data, className: 'subject' })] }; +}); + +var subjectBadge = (function (_ref) { + var subjectData = _ref.subjectData, + type = _ref.type; + + if (!subjectData.radius) subjectData.radius = 14; + if (!subjectData.x) subjectData.x = "left"; + if (!subjectData.y) subjectData.y = "top"; + + var handles = []; + var radius = subjectData.radius; + var innerRadius = radius * .7; + var x = subjectData.x == "left" ? -radius : radius; + var y = subjectData.y == "top" ? -radius : radius; + var transform = 'translate(' + x + ', ' + y + ')'; + var circlebg = arcBuilder({ className: 'subject', data: { radius: radius } }); + circlebg.attrs.transform = transform; + + var circle = arcBuilder({ className: 'subject-ring', data: { outerRadius: radius, innerRadius: innerRadius } }); + circle.attrs.transform = transform; + + var pointer = lineBuilder({ className: 'subject-pointer', + data: [[0, 0], [x, 0], [0, y], [0, 0]] + }); + + if (type.editMode) { + + var dragBadge = function dragBadge() { + subjectData.x = event.x < 0 ? "left" : "right"; + subjectData.y = event.y < 0 ? "top" : "bottom"; + type.redrawSubject(); + }; + + var bHandles = [{ x: x * 2, y: y * 2, drag: dragBadge.bind(type) }]; + handles = type.mapHandles(bHandles); + } + + var text = void 0; + if (subjectData.text) { + text = { + type: "text", + className: "badge-text", + attrs: { + text: subjectData.text, + "text-anchor": "middle", + dy: ".25em", + x: x, + y: y + } + }; + } + return { components: [pointer, circlebg, circle, text], handles: handles }; +}); + +//Note options +//Connector options +//Subject options +var Type = function () { + function Type(_ref) { + var a = _ref.a, + annotation = _ref.annotation, + editMode = _ref.editMode, + dispatcher = _ref.dispatcher, + notePadding = _ref.notePadding, + accessors = _ref.accessors; + classCallCheck(this, Type); + + this.a = a; + + this.note = annotation.disable.indexOf("note") === -1 && a.select('g.annotation-note'); + this.noteContent = this.note && a.select('g.annotation-note-content'); + this.connector = annotation.disable.indexOf("connector") === -1 && a.select('g.annotation-connector'); + this.subject = annotation.disable.indexOf("subject") === -1 && a.select('g.annotation-subject'); + + if (dispatcher) { + var handler = addHandlers.bind(null, dispatcher, annotation); + handler({ component: this.note, name: 'note' }); + handler({ component: this.connector, name: 'connector' }); + handler({ component: this.subject, name: 'subject' }); + } + + this.annotation = annotation; + this.editMode = annotation.editMode || editMode; + this.notePadding = notePadding || 3; + this.offsetCornerX = 0; + this.offsetCornerY = 0; + + if (accessors && annotation.data) { + this.init(accessors); + } + } + + createClass(Type, [{ + key: 'init', + value: function init(accessors) { + if (!this.annotation.x) { + this.mapX(accessors); + } + if (!this.annotation.y) { + this.mapY(accessors); + } + } + }, { + key: 'mapY', + value: function mapY(accessors) { + if (accessors.y) { + this.annotation.y = accessors.y(this.annotation.data); + } + } + }, { + key: 'mapX', + value: function mapX(accessors) { + if (accessors.x) { + this.annotation.x = accessors.x(this.annotation.data); + } + } + }, { + key: 'updateEditMode', + value: function updateEditMode() { + this.a.selectAll('circle.handle').remove(); + } + }, { + key: 'drawOnSVG', + value: function drawOnSVG(component, builders) { + var _this = this; + + if (!Array.isArray(builders)) { + builders = [builders]; + } + + builders.filter(function (b) { + return b; + }).forEach(function (_ref2) { + var type = _ref2.type, + className = _ref2.className, + attrs = _ref2.attrs, + handles = _ref2.handles; + + if (type === "handle") { + addHandles({ group: component, r: attrs && attrs.r, handles: handles }); + } else { + (function () { + newWithClass(component, [_this.annotation], type, className); + + var el = component.select(type + '.' + className); + var attrKeys = Object.keys(attrs); + attrKeys.forEach(function (attr) { + if (attr === "text") { + el.text(attrs[attr]); + } else { + el.attr(attr, attrs[attr]); + } + }); + })(); + } + }); + } + + //TODO: how to extend this to a drawOnCanvas mode? + + }, { + key: 'getNoteBBox', + value: function getNoteBBox() { + return bboxWithoutHandles(this.note, '.annotation-note-content text'); + } + }, { + key: 'getNoteBBoxOffset', + value: function getNoteBBoxOffset() { + var bbox = bboxWithoutHandles(this.note, '.annotation-note-content'); + var transform = this.noteContent.attr('transform').split(/\(|\,|\)/g); + bbox.offsetCornerX = parseFloat(transform[1]) + this.annotation.dx; + bbox.offsetCornerY = parseFloat(transform[2]) + this.annotation.dy; + bbox.offsetX = this.annotation.dx; + bbox.offsetY = this.annotation.dy; + return bbox; + } + + // getConnectorBBox() { return bboxWithoutHandles(this.connector)} + // getSubjectBBox() { return bboxWithoutHandles(this.subject)} + // getAnnotationBBox() { return bboxWithoutHandles(this.a)} + + }, { + key: 'drawSubject', + value: function drawSubject() { + var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var subjectData = this.annotation.subject; + var type = context.type; + var subjectParams = { type: this, subjectData: subjectData }; + + var subject = {}; + if (type === "circle") subject = subjectCircle(subjectParams);else if (type === "rect") subject = subjectRect(subjectParams);else if (type === "threshold") subject = subjectThreshold(subjectParams);else if (type === "badge") subject = subjectBadge(subjectParams); + + var _subject = subject, + _subject$components = _subject.components, + components = _subject$components === undefined ? [] : _subject$components, + _subject$handles = _subject.handles, + handles = _subject$handles === undefined ? [] : _subject$handles; + + if (this.editMode) { + handles = handles.concat(this.mapHandles([{ drag: this.dragSubject.bind(this) }])); + components.push({ type: "handle", handles: handles }); + } + + return components; + } + }, { + key: 'drawConnector', + value: function drawConnector() { + var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var connectorData = this.annotation.connector; + var type = connectorData.type || context.type; + var connectorParams = { type: this, connectorData: connectorData }; + connectorParams.subjectType = this.typeSettings && this.typeSettings.subject && this.typeSettings.subject.type; + + var connector = {}; + if (type === "curve") connector = connectorCurve(connectorParams);else if (type === "elbow") connector = connectorElbow(connectorParams);else connector = connectorLine(connectorParams); + + var _connector = connector, + _connector$components = _connector.components, + components = _connector$components === undefined ? [] : _connector$components, + _connector$handles = _connector.handles, + handles = _connector$handles === undefined ? [] : _connector$handles; + + var line$$1 = components[0]; + var endType = connectorData.end || context.end; + var end = {}; + if (endType === "arrow") { + var s = line$$1.data[1]; + var e = line$$1.data[0]; + var distance = Math.sqrt(Math.pow(s[0] - e[0], 2) + Math.pow(s[1] - e[1], 2)); + if (distance < 5 && line$$1.data[2]) { + s = line$$1.data[2]; + } + + end = connectorArrow({ annotation: this.annotation, start: s, end: e }); + } else if (endType === "dot") { + end = connectorDot({ line: line$$1 }); + } + + if (end.components) { + components = components.concat(end.components); + } + + if (this.editMode) { + if (handles.length !== 0) components.push({ type: "handle", handles: handles }); + } + return components; + } + }, { + key: 'drawNote', + value: function drawNote() { + var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var noteData = this.annotation.note; + var align = noteData.align || context.align || 'dynamic'; + var noteParams = { bbox: context.bbox, align: align, offset: this.annotation.offset }; + var lineType = noteData.lineType || context.lineType; + var note = {}; + if (lineType == "vertical") note = noteVertical(noteParams);else if (lineType == "horizontal") note = noteHorizontal(noteParams); + + var _note = note, + _note$components = _note.components, + components = _note$components === undefined ? [] : _note$components, + _note$handles = _note.handles, + handles = _note$handles === undefined ? [] : _note$handles; + + if (this.editMode) { + handles = this.mapHandles([{ x: 0, y: 0, drag: this.dragNote.bind(this) }]); + components.push({ type: "handle", handles: handles }); + } + return components; + } + }, { + key: 'drawNoteContent', + value: function drawNoteContent(context) { + var noteData = this.annotation.note; + var padding = noteData.padding || this.notePadding; + var orientation = noteData.orientation || context.orientation || 'topBottom'; + var lineType = noteData.lineType || context.lineType; + var align = noteData.align || context.align || 'dynamic'; + var subjectType = this.typeSettings && this.typeSettings.subject && this.typeSettings.subject.type; + + if (lineType == "vertical") orientation = "leftRight";else if (lineType == "horizontal") orientation = "topBottom"; + + var noteParams = { padding: padding, bbox: context.bbox, offset: this.annotation.offset, orientation: orientation, align: align }; + + var _noteAlignment = noteAlignment(noteParams), + x = _noteAlignment.x, + y = _noteAlignment.y; + + this.offsetCornerX = x + this.annotation.dx; + this.offsetCornerY = y + this.annotation.dy; + this.note && this.noteContent.attr('transform', 'translate(' + x + ', ' + y + ')'); + + return []; + } + }, { + key: 'drawOnScreen', + value: function drawOnScreen(component, drawFunction) { + return this.drawOnSVG(component, drawFunction); + } + }, { + key: 'redrawSubject', + value: function redrawSubject() { + this.subject && this.drawOnScreen(this.subject, this.drawSubject()); + } + }, { + key: 'redrawConnector', + value: function redrawConnector() { + var bbox = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getNoteBBox(); + + this.connector && this.drawOnScreen(this.connector, this.drawConnector()); + } + }, { + key: 'redrawNote', + value: function redrawNote() { + var bbox = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getNoteBBox(); + + this.noteContent && this.drawOnScreen(this.noteContent, this.drawNoteContent({ bbox: bbox })); + this.note && this.drawOnScreen(this.note, this.drawNote({ bbox: bbox })); + } + }, { + key: 'setPosition', + value: function setPosition() { + var position = this.annotation.position; + this.a.attr('transform', 'translate(' + position.x + ', ' + position.y + ')'); + } + }, { + key: 'setOffset', + value: function setOffset() { + if (this.note) { + var offset = this.annotation.offset; + this.note.attr('transform', 'translate(' + offset.x + ', ' + offset.y + ')'); + } + } + }, { + key: 'setPositionWithAccessors', + value: function setPositionWithAccessors(accessors) { + if (accessors && this.annotation.data) { + this.mapX(accessors); + this.mapY(accessors); + } + this.setPosition(); + } + }, { + key: 'setClassName', + value: function setClassName() { + this.a.attr("class", 'annotation ' + (this.className && this.className()) + ' ' + (this.editMode ? "editable" : "") + ' ' + (this.annotation.className || '')); + } + }, { + key: 'draw', + value: function draw() { + this.setClassName(); + this.setPosition(); + this.setOffset(); + this.redrawSubject(); + this.redrawConnector(); + this.redrawNote(); + } + }, { + key: 'dragstarted', + value: function dragstarted() { + event.sourceEvent.stopPropagation(); + this.a.classed("dragging", true); + this.a.selectAll("circle.handle").style("pointer-events", "none"); + } + }, { + key: 'dragended', + value: function dragended() { + this.a.classed("dragging", false); + this.a.selectAll("circle.handle").style("pointer-events", "all"); + } + }, { + key: 'dragSubject', + value: function dragSubject() { + var position = this.annotation.position; + position.x += event.dx; + position.y += event.dy; + this.annotation.position = position; + } + }, { + key: 'dragNote', + value: function dragNote() { + var offset = this.annotation.offset; + offset.x += event.dx; + offset.y += event.dy; + this.annotation.offset = offset; + } + }, { + key: 'mapHandles', + value: function mapHandles(handles) { + var _this2 = this; + + return handles.map(function (h) { + return _extends({}, h, { + start: _this2.dragstarted.bind(_this2), end: _this2.dragended.bind(_this2) }); + }); + } + }]); + return Type; +}(); + +var customType = function customType(initialType, typeSettings, _init) { + return function (_initialType) { + inherits(customType, _initialType); + + function customType(settings) { + classCallCheck(this, customType); + + var _this3 = possibleConstructorReturn(this, (customType.__proto__ || Object.getPrototypeOf(customType)).call(this, settings)); + + _this3.typeSettings = typeSettings; + + if (typeSettings.disable) { + typeSettings.disable.forEach(function (d) { + _this3[d] = undefined; + if (d == "note") { + _this3.noteContent = undefined; + } + }); + } + return _this3; + } + + createClass(customType, [{ + key: 'className', + value: function className() { + return (typeSettings.className || '') + ' ' + (get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'className', this) && get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'className', this).call(this) || ''); + } + }, { + key: 'drawSubject', + value: function drawSubject(context) { + this.typeSettings.subject = Object.assign({}, typeSettings.subject, this.typeSettings.subject); + return get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'drawSubject', this).call(this, _extends({}, context, this.typeSettings.subject)); + } + }, { + key: 'drawConnector', + value: function drawConnector(context, subjectContext) { + this.typeSettings.connector = Object.assign({}, typeSettings.connector, this.typeSettings.connector); + return get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'drawConnector', this).call(this, _extends({}, context, typeSettings.connector, this.typeSettings.connector)); + } + }, { + key: 'drawNote', + value: function drawNote(context) { + this.typeSettings.note = Object.assign({}, typeSettings.note, this.typeSettings.note); + return get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'drawNote', this).call(this, _extends({}, context, typeSettings.note, this.typeSettings.note)); + } + }, { + key: 'drawNoteContent', + value: function drawNoteContent(context) { + return get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'drawNoteContent', this).call(this, _extends({}, context, typeSettings.note, this.typeSettings.note)); + } + }], [{ + key: 'init', + value: function init(annotation, accessors) { + get(customType.__proto__ || Object.getPrototypeOf(customType), 'init', this).call(this, annotation, accessors); + if (_init) { + annotation = _init(annotation, accessors); + } + return annotation; + } + }]); + return customType; + }(initialType); +}; + +var d3NoteText = function (_Type) { + inherits(d3NoteText, _Type); + + function d3NoteText(params) { + classCallCheck(this, d3NoteText); + + var _this4 = possibleConstructorReturn(this, (d3NoteText.__proto__ || Object.getPrototypeOf(d3NoteText)).call(this, params)); + + _this4.textWrap = params.textWrap || 120; + _this4.drawText(); + return _this4; + } + + createClass(d3NoteText, [{ + key: 'updateTextWrap', + value: function updateTextWrap(textWrap) { + this.textWrap = textWrap; + this.drawText(); + } + + //TODO: add update text functionality + + }, { + key: 'drawText', + value: function drawText() { + if (this.note) { + + newWithClass(this.note, [this.annotation], 'g', 'annotation-note-content'); + + var noteContent = this.note.select('g.annotation-note-content'); + newWithClass(noteContent, [this.annotation], 'rect', 'annotation-note-bg'); + newWithClass(noteContent, [this.annotation], 'text', 'annotation-note-label'); + newWithClass(noteContent, [this.annotation], 'text', 'annotation-note-title'); + + var titleBBox = { height: 0 }; + var label = this.a.select('text.annotation-note-label'); + var wrapLength = this.annotation.note && this.annotation.note.wrap || this.typeSettings && this.typeSettings.note && this.typeSettings.note.wrap || this.textWrap; + + if (this.annotation.note.title) { + var title = this.a.select('text.annotation-note-title'); + title.text(this.annotation.note.title).attr('dy', '1.1em'); + title.call(wrap, wrapLength); + titleBBox = title.node().getBBox(); + } + + label.text(this.annotation.note.label).attr('dy', '1em'); + label.call(wrap, wrapLength); + + label.attr('y', titleBBox.height * 1.1 || 0); + + var bbox = this.getNoteBBox(); + this.a.select('rect.annotation-note-bg').attr('width', bbox.width).attr('height', bbox.height); + } + } + }]); + return d3NoteText; +}(Type); + +var d3Label = customType(d3NoteText, { + className: "label", + note: { align: "middle" } +}); + +var d3Callout = customType(d3NoteText, { + className: "callout", + note: { lineType: "horizontal" } +}); + +var d3CalloutElbow = customType(d3Callout, { + className: "callout elbow", + connector: { type: "elbow" } +}); + +var d3CalloutCurve = customType(d3Callout, { + className: "callout curve", + connector: { type: "curve" } +}); + +var d3Badge = customType(Type, { + className: "badge", + subject: { type: "badge" }, + disable: ['connector', 'note'] +}); + +var d3CalloutCircle = customType(d3CalloutElbow, { + className: "callout circle", + subject: { type: "circle" } +}); + +var d3CalloutRect = customType(d3CalloutElbow, { + className: "callout rect", + subject: { type: "rect" } +}); + +var ThresholdMap = function (_d3Callout) { + inherits(ThresholdMap, _d3Callout); + + function ThresholdMap() { + classCallCheck(this, ThresholdMap); + return possibleConstructorReturn(this, (ThresholdMap.__proto__ || Object.getPrototypeOf(ThresholdMap)).apply(this, arguments)); + } + + createClass(ThresholdMap, [{ + key: 'mapY', + value: function mapY(accessors) { + get(ThresholdMap.prototype.__proto__ || Object.getPrototypeOf(ThresholdMap.prototype), 'mapY', this).call(this, accessors); + var a = this.annotation; + if ((a.subject.x1 || a.subject.x2) && a.data && accessors.y) { + a.y = accessors.y(a.data); + } + } + }, { + key: 'mapX', + value: function mapX(accessors) { + get(ThresholdMap.prototype.__proto__ || Object.getPrototypeOf(ThresholdMap.prototype), 'mapX', this).call(this, accessors); + var a = this.annotation; + if ((a.subject.y1 || a.subject.y2) && a.data && accessors.x) { + a.x = accessors.x(a.data); + } + } + }]); + return ThresholdMap; +}(d3Callout); + +var d3XYThreshold = customType(ThresholdMap, { + className: "callout xythreshold", + subject: { type: "threshold" } +}); + +var newWithClass = function newWithClass(a, d, type, className) { + var group = a.selectAll(type + '.' + className).data(d); + group.enter().append(type).merge(group).attr('class', className); + + group.exit().remove(); + return a; +}; + +var addHandlers = function addHandlers(dispatcher, annotation, _ref3) { + var component = _ref3.component, + name = _ref3.name; + + if (component) { + component.on("mouseover.annotations", function () { + dispatcher.call(name + 'over', component, annotation); + }).on("mouseout.annotations", function () { + return dispatcher.call(name + 'out', component, annotation); + }).on("click.annotations", function () { + return dispatcher.call(name + 'click', component, annotation); + }); + } +}; + +//Text wrapping code adapted from Mike Bostock +var wrap = function wrap(text, width) { + text.each(function () { + var text = select(this), + words = text.text().split(/[ \t\r\n]+/).reverse(), + word, + line$$1 = [], + lineNumber = 0, + lineHeight = .2, + //ems + y = text.attr("y"), + dy = parseFloat(text.attr("dy")) || 0, + tspan = text.text(null).append("tspan").attr("x", 0).attr("dy", dy + "em"); + + while (word = words.pop()) { + line$$1.push(word); + tspan.text(line$$1.join(" ")); + if (tspan.node().getComputedTextLength() > width && line$$1.length > 1) { + line$$1.pop(); + tspan.text(line$$1.join(" ")); + line$$1 = [word]; + tspan = text.append("tspan").attr("x", 0).attr("dy", lineHeight + dy + "em").text(word); + } + } + }); +}; + +var bboxWithoutHandles = function bboxWithoutHandles(selection) { + var selector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ':not(.handle)'; + + if (!selection) { + return { x: 0, y: 0, width: 0, height: 0 }; + } + + return selection.selectAll(selector).nodes().reduce(function (p, c) { + var bbox = c.getBBox(); + p.x = Math.min(p.x, bbox.x); + p.y = Math.min(p.y, bbox.y); + p.width = Math.max(p.width, bbox.width); + p.height += bbox.height; + return p; + }, { x: 0, y: 0, width: 0, height: 0 }); +}; + +function annotation() { + var annotations = [], + collection = void 0, + context = void 0, + //TODO: add canvas functionality + disable = [], + accessors = {}, + accessorsInverse = {}, + editMode = false, + ids = void 0, + type = d3Callout, + textWrap = void 0, + notePadding = void 0, + annotationDispatcher = dispatch("subjectover", "subjectout", "subjectclick", "connectorover", "connectorout", "connectorclick", "noteover", "noteout", "noteclick"), + sel = void 0; + + var annotation = function annotation(selection) { + sel = selection; + //TODO: check to see if this is still needed + if (!editMode) { + selection.selectAll("circle.handle").remove(); + } + + var translatedAnnotations = annotations.map(function (a) { + if (!a.type) { + a.type = type; + } + if (!a.disable) { + a.disable = disable; + } + return new Annotation(a); + }); + + collection = new AnnotationCollection({ + annotations: translatedAnnotations, + accessors: accessors, + accessorsInverse: accessorsInverse, + ids: ids + }); + + var annotationG = selection.selectAll('g').data([collection]); + annotationG.enter().append('g').attr('class', 'annotations'); + + var group = selection.select('g.annotations'); + newWithClass(group, collection.annotations, 'g', 'annotation'); + + var annotation = group.selectAll('g.annotation'); + + annotation.each(function (d) { + var a = select(this); + var position = d.position; + + a.attr('class', 'annotation'); + + newWithClass(a, [d], 'g', 'annotation-connector'); + newWithClass(a, [d], 'g', 'annotation-subject'); + newWithClass(a, [d], 'g', 'annotation-note'); + newWithClass(a.select('g.annotation-note'), [d], 'g', 'annotation-note-content'); + + d.type = new d.type({ a: a, annotation: d, textWrap: textWrap, notePadding: notePadding, editMode: editMode, + dispatcher: annotationDispatcher, accessors: accessors }); + d.type.draw(); + }); + }; + + annotation.json = function () { + console.log('Annotations JSON was copied to your clipboard. Please note the annotation type is not JSON compatible. It appears in the objects array in the console, but not in the copied JSON.', collection.json); + window.copy(JSON.stringify(collection.json.map(function (a) { + delete a.type;return a; + }))); + return annotation; + }; + + annotation.update = function () { + if (annotations && collection) { + annotations = collection.annotations.map(function (a, i) { + a.type.draw();return a; + }); + } + return annotation; + }; + + annotation.updatedAccessors = function () { + collection.setPositionWithAccessors(); + annotations = collection.annotations; + return annotation; + }; + + annotation.disable = function (_) { + if (!arguments.length) return disable; + disable = _; + if (collection) { + collection.updateDisable(disable); + annotations = collection.annotations; + } + return annotation; + }; + + annotation.textWrap = function (_) { + if (!arguments.length) return textWrap; + textWrap = _; + if (collection) { + collection.updateTextWrap(textWrap); + annotations = collection.annotations; + } + return annotation; + }; + + annotation.notePadding = function (_) { + if (!arguments.length) return notePadding; + notePadding = _; + if (collection) { + collection.updateNotePadding(notePadding); + annotations = collection.annotations; + } + return annotation; + }; + + annotation.type = function (_, settings) { + if (!arguments.length) return type; + type = _; + if (collection) { + collection.annotations.map(function (a) { + + a.type.note && a.type.note.selectAll("*:not(.annotation-note-content)").remove(); + a.type.noteContent && a.type.noteContent.selectAll("*").remove(); + a.type.subject && a.type.subject.selectAll("*").remove(); + a.type.connector && a.type.connector.selectAll("*").remove(); + a.type.typeSettings = {}; + a.type = type; + + a.subject = settings && settings.subject || a.subject; + a.connector = settings && settings.connector || a.connector; + a.note = settings && settings.note || a.note; + }); + + annotations = collection.annotations; + } + return annotation; + }; + + annotation.annotations = function (_) { + if (!arguments.length) return collection && collection.annotations || annotations; + annotations = _; + return annotation; + }; + + annotation.context = function (_) { + if (!arguments.length) return context; + context = _; + return annotation; + }; + + annotation.accessors = function (_) { + if (!arguments.length) return accessors; + accessors = _; + return annotation; + }; + + annotation.accessorsInverse = function (_) { + if (!arguments.length) return accessorsInverse; + accessorsInverse = _; + return annotation; + }; + + annotation.ids = function (_) { + if (!arguments.length) return ids; + ids = _; + return annotation; + }; + + annotation.editMode = function (_) { + if (!arguments.length) return editMode; + editMode = _; + + if (sel) { + sel.selectAll('g.annotation').classed('editable', editMode); + } + + if (collection) { + collection.editMode(editMode); + annotations = collection.annotations; + } + return annotation; + }; + + annotation.collection = function (_) { + if (!arguments.length) return collection; + collection = _; + return annotation; + }; + + annotation.on = function () { + var value = annotationDispatcher.on.apply(annotationDispatcher, arguments); + return value === annotationDispatcher ? annotation : value; + }; + + return annotation; +} + +var index = { + annotation: annotation, + annotationTypeBase: Type, + annotationLabel: d3Label, + annotationCallout: d3Callout, + annotationCalloutCurve: d3CalloutCurve, + annotationCalloutElbow: d3CalloutElbow, + annotationCalloutCircle: d3CalloutCircle, + annotationCalloutRect: d3CalloutRect, + annotationXYThreshold: d3XYThreshold, + annotationBadge: d3Badge, + annotationCustomType: customType +}; + +export { annotation, Type as annotationTypeBase, d3Label as annotationLabel, d3Callout as annotationCallout, d3CalloutCurve as annotationCalloutCurve, d3CalloutElbow as annotationCalloutElbow, d3CalloutCircle as annotationCalloutCircle, d3CalloutRect as annotationCalloutRect, d3XYThreshold as annotationXYThreshold, d3Badge as annotationBadge, customType as annotationCustomType };export default index; +//# sourceMappingURL=indexRollupNext.js.map diff --git a/indexRollupNext.js.map b/indexRollupNext.js.map new file mode 100644 index 0000000..a6fc53c --- /dev/null +++ b/indexRollupNext.js.map @@ -0,0 +1 @@ +{"version":3,"file":"indexRollupNext.js","sources":["src/Annotation.js","src/AnnotationCollection.js","src/Handles.js","src/Note/alignment.js","src/Builder.js","src/Note/lineType-vertical.js","src/Note/lineType-horizontal.js","src/Connector/type-line.js","src/Connector/type-elbow.js","src/Connector/type-curve.js","src/Connector/end-arrow.js","src/Connector/end-dot.js","src/Subject/circle.js","src/Subject/rect.js","src/Subject/threshold.js","src/Subject/badge.js","src/Types-d3.js","src/Adapter-d3.js","index.js"],"sourcesContent":["\nexport default class Annotation {\n constructor({ x=0, y=0, dy=0, dx=0, data, type, subject, connector, note, \n disable, id, className }) {\n\n this._dx = dx\n this._dy = dy \n this._x = x \n this._y = y\n this.id = id\n this._className = className || ''\n\n this.type = type || ''\n this.data = data\n\n this.note = note || {}\n this.connector = connector || {}\n this.subject = subject || {}\n\n this.disable = disable || []\n }\n\n updatePosition(){\n if (this.type.setPosition) { \n this.type.setPosition() \n if (this.type.subject.selectAll(':not(.handle)').nodes().length !== 0) {\n this.type.redrawSubject()\n }\n }\n }\n\n get className() { return this._className }\n\n set className(className){\n this._className = className\n if (this.type.setClassName) this.type.setClassName()\n }\n\n updateOffset(){\n if (this.type.setOffset) {\n this.type.setOffset() \n \n if (this.type.connector.selectAll(':not(.handle)').nodes().length !== 0) {\n this.type.redrawConnector()\n }\n\n this.type.redrawNote()\n }\n }\n\n get x() { return this._x }\n set x(x) { \n this._x = x; \n this.updatePosition()\n }\n\n get y() { return this._y }\n set y(y) { \n this._y = y; \n this.updatePosition()\n }\n\n get dx() { return this._dx }\n set dx(dx) { \n this._dx = dx; \n this.updateOffset()\n }\n\n get dy() { return this._dy }\n set dy(dy) { \n this._dy = dy; \n this.updateOffset()\n }\n\n get offset() { return { x: this._dx, y: this._dy }}\n\n set offset({ x, y }) {\n this._dx = x\n this._dy = y\n this.updateOffset()\n }\n\n get position() { return { x: this._x, y: this._y }}\n\n set position({ x, y }) {\n this._x = x\n this._y = y\n this.updatePosition()\n }\n\n get translation() {\n return {\n x: this._x + this._dx,\n y: this._y + this._dy\n }}\n\n get json() { \n const json = {\n x: this._x,\n y: this._y,\n dx: this._dx,\n dy: this._dy\n }\n\n if (this.data && Object.keys(this.data).length > 0) json.data = this.data\n if (this.type) json.type = this.type\n if (this._className) json.className = this._className\n\n if (Object.keys(this.connector).length > 0) json.connector = this.connector\n if (Object.keys(this.subject).length > 0) json.subject = this.subject\n if (Object.keys(this.note).length > 0) json.note = this.note\n \n return json\n }\n}","export default class AnnotationCollection {\n\n constructor({ annotations, accessors, accessorsInverse }) {\n this.accessors = accessors\n this.accessorsInverse = accessorsInverse\n this.annotations = annotations\n }\n\n clearTypes(newSettings) {\n this.annotations.forEach(d => {\n d.type = undefined\n d.subject = newSettings && newSettings.subject || d.subject\n d.connector = newSettings && newSettings.connector || d.connector\n d.note = newSettings && newSettings.note || d.note\n })\n }\n\n setPositionWithAccessors() {\n this.annotations.forEach(d => {\n d.type.setPositionWithAccessors(this.accessors)\n })\n }\n\n editMode(editMode) { this.annotations.forEach(a => {\n if (a.type) {\n a.type.editMode = editMode\n a.type.updateEditMode()\n }\n })\n }\n\n updateDisable(disable) {\n this.annotations.forEach(a => {\n a.disable = disable\n if (a.type){\n disable.forEach(d => {\n if (a.type[d]){\n a.type[d].remove && a.type[d].remove()\n a.type[d] = undefined\n }\n })\n }\n })\n }\n\n updateTextWrap(textWrap) {\n this.annotations.forEach(a => {\n if (a.type && a.type.updateTextWrap){\n a.type.updateTextWrap(textWrap)\n }\n })\n }\n\n updateNotePadding(notePadding) {\n this.annotations.forEach(a => {\n if (a.type){\n a.type.notePadding = notePadding\n }\n })\n }\n\n get json() { \n return this.annotations.map(a => { \n const json = a.json\n if (this.accessorsInverse && a.data){\n json.data = {}\n Object.keys(this.accessorsInverse).forEach(k => {\n json.data[k] = this.accessorsInverse[k]({ x: a.x, y: a.y})\n\n //TODO make this feasible to map back to data for other types of subjects\n })\n }\n return json\n })\n }\n\n get noteNodes(){\n return this.annotations.map(a => ({ ...a.type.getNoteBBoxOffset(), positionX: a.x, positionY: a.y }))\n }\n\n //TODO: come back and rethink if a.x and a.y are applicable in all situations\n // get connectorNodes() {\n // return this.annotations.map(a => ({ ...a.type.getConnectorBBox(), startX: a.x, startY: a.y}))\n // }\n\n // get subjectNodes() {\n // return this.annotations.map(a => ({ ...a.type.getSubjectBBox(), startX: a.x, startY: a.y}))\n // }\n\n // get annotationNodes() {\n // return this.annotations.map(a => ({ ...a.type.getAnnotationBBox(), startX: a.x, startY: a.y}))\n // }\n}\n","import { select } from 'd3-selection'\nimport { drag } from 'd3-drag'\n\n\nexport const pointHandle = ({ cx=0, cy=0 }) => {\n return { move: { x: cx, y: cy} }\n}\n\nexport const circleHandles = ({ cx=0, cy =0, r1, r2, padding }) => {\n const h = { move: { x: cx, y: cy}}\n \n if (r1 !== undefined) {\n h.r1 = { x: cx + r1/Math.sqrt(2), y: cy + r1/Math.sqrt(2) }\n }\n \n if (r2 !== undefined) {\n h.r2 = { x: cx + r2/Math.sqrt(2), y: cy + r2/Math.sqrt(2) }\n }\n\n if (padding !== undefined) {\n h.padding = { x: cx + r1 + padding, y: cy}\n }\n\n return h\n}\n\nexport const rectHandles = ({ x1=0, y1=0, x2=x1, y2=y1, width, height }) => {\n \n const w = width || Math.abs(x2 - x1)\n const h = height || Math.abs(y2 - y1)\n\n return {\n move: {\n x: Math.min(x1, x2) + w/2,\n y: Math.min(y1, y2) - 10\n },\n width: {\n x: Math.max(x1, x2),\n y: Math.min(y1, y2) + h/2\n },\n height: {\n x: Math.min(x1, x2) + w/2,\n y: Math.max(y1, y2)\n }\n }\n}\n\nexport const lineHandles = ({ x1, y1, x2, y2, x, y}) => {\n\n const minY = Math.min(y1, y2)\n const minX = Math.min(x1, x2)\n\n const height = Math.abs(y2 - y1)\n const width = Math.abs(x2 - x1)\n \n return {\n move: {\n x: x || minX + width/2,\n y: y || minY + height/2\n }\n }\n}\n\n//arc handles\nexport const addHandles = ({ group, handles, r=10}) => { \n //give it a group and x,y to draw handles\n //then give it instructions on what the handles change \n const h = group.selectAll('circle.handle')\n .data(handles)\n\n h.enter()\n .append('circle')\n .attr('class', 'handle')\n .call(drag()\n .container(select('g.annotations').node())\n .on('start', d => d.start && d.start(d))\n .on('drag', d => d.drag && d.drag(d))\n .on('end', d => d.end && d.end(d))\n )\n\n group.selectAll('circle.handle')\n .attr('cx', d => d.x)\n .attr('cy', d => d.y)\n .attr('r', d => d.r || r)\n .attr('class', d => `handle ${d.className || ''}`)\n\n h.exit()\n .remove()\n \n}\n\n","\nexport const leftRightDynamic = (align, y) => {\n if (align == \"dynamic\" || align == \"left\" || align == \"right\"){\n if (y < 0){ align = \"top\" }\n else { align = \"bottom\" } \n }\n return align\n}\n\nexport const topBottomDynamic = (align, x) => {\n if (align == \"dynamic\" || align == \"top\" || align == \"bottom\"){\n if (x < 0){ align = \"right\" }\n else { align = \"left\" } \n }\n return align\n}\n\n\nexport default ({ padding, bbox, align, orientation, offset }) => {\n let x = -bbox.x \n let y = -bbox.y\n\n if ( orientation === \"topBottom\" ){\n align = topBottomDynamic(align, offset.x)\n if (offset.y < 0){ \n y -= (bbox.height + padding)\n } else {\n y += padding\n }\n\n if ( align === \"middle\" ) {\n x -= bbox.width/2\n } else if (align === \"right\" ) {\n x -= (bbox.width)\n } \n\n } else if ( orientation === \"leftRight\" ){\n align = leftRightDynamic(align, offset.y)\n if (offset.x < 0){ \n x -= (bbox.width + padding) \n } else {\n x += padding\n }\n\n if ( align === \"middle\" ) {\n y -= bbox.height/2\n } else if (align === \"top\" ){\n y -= (bbox.height )\n }\n } \n\n return { x, y }\n}","import { line, arc, curveLinear, symbol, symbolTriangle } from \"d3-shape\"\n\nexport const lineBuilder = ({ data, curve=curveLinear, canvasContext, className }) => { \n const lineGen = line()\n .curve(curve)\n\n const builder = {\n type: 'path',\n className,\n data\n }\n\n if (canvasContext) {\n lineGen.context(canvasContext)\n builder.pathMethods = lineGen\n\n } else {\n builder.attrs = {\n d: lineGen(data)\n }\n }\n\n return builder\n}\n\nexport const arcBuilder = ({ data, canvasContext, className }) => {\n\n const builder = {\n type: 'path',\n className,\n data\n }\n\n const arcShape = arc()\n .innerRadius(data.innerRadius || 0)\n .outerRadius(data.outerRadius || data.radius || 2)\n .startAngle(data.startAngle || 0)\n .endAngle(data.endAngle || 2*Math.PI)\n\n if (canvasContext) {\n arcShape.context(canvasContext)\n builder.pathMethods = lineGen\n\n } else {\n \n builder.attrs = {\n d: arcShape()\n }\n }\n\n return builder\n}","import { lineBuilder } from '../Builder'\nimport { leftRightDynamic } from './alignment'\n\nexport default ({ align, x=0, y=0, bbox, offset, padding }) => {\n align = leftRightDynamic(align, offset.y)\n\n if (align == \"top\") { y -= bbox.height } \n else if (align == \"middle\"){ y -= bbox.height/2 }\n\n const data = [[x, y], [x, y + bbox.height]]\n return { components: [lineBuilder({ data, className : \"note-line\" })] }\n}","import { lineBuilder } from '../Builder'\nimport { topBottomDynamic } from './alignment'\n\nexport default ({ align, x=0, y=0, offset, bbox, padding }) => {\n align = topBottomDynamic(align, offset.x)\n\n if (align == \"right\") { x -= bbox.width }\n else if (align == \"middle\"){ x -= bbox.width/2 }\n\n const data = [[x, y], [x + bbox.width, y]]\n return { components: [lineBuilder({ data, className : \"note-line\" })] }\n}","import { lineBuilder } from '../Builder'\n\nexport const lineSetup = ({ type, subjectType }) => {\n let annotation = type.annotation\n let offset = annotation.position\n \n let x1 = annotation.x - offset.x,\n x2 = x1 + annotation.dx,\n y1 = annotation.y - offset.y,\n y2 = y1 + annotation.dy\n\n\n const subjectData = annotation.subject\n\n if (subjectType == \"circle\" && (subjectData.outerRadius || subjectData.radius)){\n const h = Math.sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2))\n const angle = Math.asin(-y2/h)\n const r = subjectData.outerRadius || subjectData.radius + (subjectData.radiusPadding || 0)\n\n x1 = Math.abs(Math.cos(angle)*r)*(x2 < 0 ? -1 : 1)\n y1 = Math.abs(Math.sin(angle)*r)*(y2 < 0 ? -1 : 1)\n\n }\n\n if (subjectType == \"rect\"){\n const { width, height } = subjectData\n \n if ((width > 0 && annotation.dx > 0) || (width < 0 && annotation.dx < 0)) {\n if (Math.abs(width) > Math.abs(annotation.dx)) x1 = width/2\n else x1 = width\n } \n if ((height > 0 && annotation.dy > 0) || (height < 0 && annotation.dy < 0)) {\n if (Math.abs(height) > Math.abs(annotation.dy)) y1 = height/2\n else y1 = height\n }\n if (x1 == width/2 && y1 == height/2){ x1 = x2; y1 = y2;}\n }\n\n\n return [[x1, y1], [x2, y2]]\n}\n\nexport default (connectorData) => {\n const data = lineSetup(connectorData)\n return { components: [lineBuilder({ data, className : \"connector\" })]} \n}","import { lineBuilder } from '../Builder'\n\nexport default ({ type, subjectType }) => {\n\n const annotation = type.annotation\n const offset = annotation.position\n\n let x1 = annotation.x - offset.x,\n x2 = x1 + annotation.dx,\n y1 = annotation.y - offset.y,\n y2 = y1 + annotation.dy\n\n const subjectData = annotation.subject\n\n if (subjectType == \"rect\"){\n const { width, height } = subjectData\n \n if ((width > 0 && annotation.dx > 0) || (width < 0 && annotation.dx < 0)) {\n if (Math.abs(width) > Math.abs(annotation.dx)) x1 = width/2\n else x1 = width\n } \n if ((height > 0 && annotation.dy > 0) || (height < 0 && annotation.dy < 0)) {\n if (Math.abs(height) > Math.abs(annotation.dy)) y1 = height/2\n else y1 = height\n }\n if (x1 == width/2 && y1 == height/2){ x1 = x2; y1 = y2;}\n }\n\n let data = [[x1, y1], [x2, y2]]\n\n let diffY = (y2 - y1)\n let diffX = (x2 - x1)\n let xe = x2 \n let ye = y2\n let opposite = (y2 < y1 && x2 > x1 || x2 < x1 && y2 > y1)? -1 : 1\n\n if (Math.abs(diffX) < Math.abs(diffY)){\n xe = x2\n ye = y1 + diffX*opposite\n } else {\n ye = y2\n xe = x1 + diffY*opposite\n }\n \n if (subjectType == \"circle\" && (subjectData.outerRadius || subjectData.radius)){\n const r = (subjectData.outerRadius || subjectData.radius) + (subjectData.radiusPadding || 0)\n const length = r/Math.sqrt(2)\n\n if (Math.abs(diffX) > length && Math.abs(diffY) > length){\n x1 = length*(x2 < 0 ? -1 : 1)\n y1 = length*(y2 < 0 ? -1 : 1)\n data = [[x1, y1], [xe , ye ], [x2, y2]]\n\n } else if (Math.abs(diffX) > Math.abs(diffY)){\n const angle = Math.asin(-y2/r)\n x1 = Math.abs(Math.cos(angle)*r)*(x2 < 0 ? -1 : 1)\n data = [[ x1, y2], [x2, y2]]\n } else {\n const angle = Math.acos(x2/r)\n y1 = Math.abs(Math.sin(angle)*r)*(y2 < 0 ? -1 : 1)\n data = [[ x2, y1], [x2, y2]]\n }\n } else {\n data = [[x1, y1], [xe , ye], [x2, y2]]\n }\n\n return { components: [lineBuilder({ data, className: \"connector\"})]}\n}\n","import { lineBuilder } from '../Builder'\nimport { event } from 'd3-selection'\nimport { lineSetup } from './type-line'\nimport { curveCatmullRom } from 'd3-shape'\nimport { pointHandle } from '../Handles'\n\nexport default ({ type, connectorData, subjectType }) => {\n\n if (!connectorData){ connectorData = {} }\n if (!connectorData.points || typeof connectorData.points === \"number\"){ \n connectorData.points = createPoints(type.annotation.offset, connectorData.points) \n }\n if (!connectorData.curve){ connectorData.curve = curveCatmullRom }\n\n let handles = []\n\n if (type.editMode) {\n const cHandles = connectorData.points\n .map((c,i) => ({...pointHandle({cx: c[0], cy: c[1]}), index: i}))\n\n const updatePoint = (index) => { \n connectorData.points[index][0] += event.dx\n connectorData.points[index][1] += event.dy\n type.redrawConnector()\n }\n \n handles = type.mapHandles(cHandles\n .map(h => ({ ...h.move, drag: updatePoint.bind(type, h.index)})))\n\n }\n\n let data = lineSetup({ type, subjectType })\n data = [data[0], ...connectorData.points, data[1]]\n const components = [lineBuilder({ data, curve: connectorData.curve, className: \"connector\" })]\n\n return { components , handles }\n}\n\nconst createPoints = function( offset, anchors=2){\n const diff = { x: offset.x/(anchors + 1), y: offset.y/(anchors + 1) }\n const p = []\n\n let i = 1 \n for (; i <= anchors; i++){\n p.push([diff.x*i + i%2*20, diff.y*i - i%2*20])\n }\n return p\n}","import { lineBuilder } from '../Builder'\n\nexport default ({ annotation, start, end }) => {\n const offset = annotation.position\n if (!start) { start = [annotation.dx, annotation.dy]} \n else { start = [-end[0] + start[0], - end[1] + start[1]]}\n if (!end) { end = [annotation.x - offset.x, annotation.y - offset.y]}\n\n let x1 = end[0],\n y1 = end[1];\n\n let dx = start[0] \n let dy = start[1] \n\n let size = 10;\n let angleOffset = 16/180*Math.PI\n let angle = Math.atan(dy/dx) \n\n if (dx < 0 ) {\n angle += Math.PI\n }\n\n const data = [[x1, y1], \n [Math.cos(angle + angleOffset)*size + x1, Math.sin(angle + angleOffset)*size + y1],\n [Math.cos(angle - angleOffset)*size + x1, Math.sin(angle - angleOffset)*size + y1],\n [x1, y1]]\n\n //TODO add in reverse\n // if (canvasContext.arrowReverse){\n // data = [[x1, y1], \n // [Math.cos(angle + angleOffset)*size, Math.sin(angle + angleOffset)*size],\n // [Math.cos(angle - angleOffset)*size, Math.sin(angle - angleOffset)*size],\n // [x1, y1]\n // ]\n // } else {\n // data = [[x1, y1], \n // [Math.cos(angle + angleOffset)*size, Math.sin(angle + angleOffset)*size],\n // [Math.cos(angle - angleOffset)*size, Math.sin(angle - angleOffset)*size],\n // [x1, y1]\n // ]\n // }\n\n return { components: [lineBuilder({ data, className : 'connector-arrow' })] }\n}\n","import { arcBuilder } from '../Builder'\n\nexport default ({ line }) => {\n \n let dot = arcBuilder({ className: 'connector-dot', data: { radius: 3} })\n dot.attrs.transform = `translate(${line.data[0][0]}, ${line.data[0][1]})`\n \n return { components: [dot] }\n}\n","import { circleHandles } from '../Handles'\nimport { arcBuilder } from '../Builder'\nimport { event } from 'd3-selection'\n\nexport default ({ subjectData, type}) => {\n if (!subjectData.radius && !subjectData.outerRadius ){ subjectData.radius = 20 }\n\n let handles = []\n const c = arcBuilder({ data: subjectData, className: \"subject\" })\n if (type.editMode){\n const h = circleHandles({\n r1: c.data.outerRadius || c.data.radius,\n r2: c.data.innerRadius,\n padding: subjectData.radiusPadding\n })\n\n const updateRadius = (attr) => { \n const r = subjectData[attr] + event.dx*Math.sqrt(2)\n subjectData[attr] = r\n type.redrawSubject()\n type.redrawConnector()\n }\n\n const cHandles = [\n { ...h.r1, drag: updateRadius.bind(type, subjectData.outerRadius !== undefined ? 'outerRadius': 'radius')}\n ]\n\n if (subjectData.innerRadius){\n cHandles.push({ ...h.r2, drag: updateRadius.bind(type, 'innerRadius')})\n }\n handles = type.mapHandles(cHandles)\n }\n\n return { components: [c], handles }\n}","import { circleHandles } from '../Handles'\nimport { lineBuilder } from '../Builder'\nimport { event } from 'd3-selection'\n\nexport default ({ subjectData, type}) => {\n if (!subjectData.width){ subjectData.width = 100 }\n if (!subjectData.height){ subjectData.height = 100 }\n\n let handles = []\n let { width, height } = subjectData\n\n const data = [[0, 0], \n [ width, 0], \n [ width, height], \n [0, height],\n [0, 0]]\n let rect = lineBuilder({ data, className : 'subject'})\n\n if (type.editMode){\n\n const updateWidth = (attr) => { \n subjectData.width = event.x\n type.redrawSubject()\n type.redrawConnector()\n }\n\n const updateHeight = () => {\n subjectData.height = event.y\n type.redrawSubject()\n type.redrawConnector()\n }\n\n const rHandles = [{ x: width, y: height/2, drag: updateWidth.bind(type) },\n { x: width/2, y: height, drag: updateHeight.bind(type) }\n ]\n\n handles = type.mapHandles(rHandles)\n\n }\n\n return { components: [rect], handles }\n}","import { circleHandles } from '../Handles'\nimport { lineBuilder } from '../Builder'\n\n\nexport default ({ subjectData, type }) => {\n const offset = type.annotation.position\n\n let x1 = (subjectData.x1 !== undefined ? subjectData.x1 : offset.x) - offset.x,\n x2 = (subjectData.x2 !== undefined ? subjectData.x2 : offset.x) - offset.x,\n y1 = (subjectData.y1 !== undefined ? subjectData.y1 : offset.y) - offset.y,\n y2 = (subjectData.y2 !== undefined ? subjectData.y2 : offset.y) - offset.y\n\n const data = [[x1, y1], [x2, y2]]\n return { components: [lineBuilder({ data, className : 'subject'})]}\n}","import { circleHandles } from '../Handles'\nimport { lineBuilder, arcBuilder } from '../Builder'\nimport { event } from 'd3-selection'\n\nexport default ({ subjectData, type }) => {\n if (!subjectData.radius ) subjectData.radius = 14\n if (!subjectData.x) subjectData.x =\"left\"\n if (!subjectData.y) subjectData.y = \"top\"\n\n let handles = []\n const radius = subjectData.radius\n const innerRadius = radius*.7\n const x = subjectData.x == \"left\" ? -radius : radius\n const y = subjectData.y == \"top\" ? -radius : radius\n const transform = `translate(${x}, ${y})`\n const circlebg = arcBuilder({ className: 'subject', data: { radius} }) \n circlebg.attrs.transform = transform\n\n const circle = arcBuilder({ className: 'subject-ring', data: { outerRadius: radius, innerRadius} })\n circle.attrs.transform = transform\n\n const pointer = lineBuilder({ className: 'subject-pointer',\n data: [[0, 0], [x, 0], [0, y], [0, 0]]\n })\n\n if (type.editMode){\n\n const dragBadge = () => {\n subjectData.x = event.x < 0 ? \"left\" : \"right\"\n subjectData.y = event.y < 0 ? \"top\" : \"bottom\"\n type.redrawSubject()\n }\n\n const bHandles = [{ x: x*2, y: y*2, drag: dragBadge.bind(type)}]\n handles = type.mapHandles(bHandles)\n\n }\n\n let text\n if (subjectData.text){\n text = {\n type: \"text\",\n className: \"badge-text\",\n attrs: {\n text: subjectData.text,\n \"text-anchor\": \"middle\",\n dy: \".25em\",\n x,\n y\n }\n }\n }\n return { components: [pointer, circlebg, circle, text], handles }\n}","import { select, event } from 'd3-selection'\nimport { drag } from 'd3-drag'\nimport { addHandles } from './Handles'\n\n//Note options\nimport noteAlignment from './Note/alignment'\nimport noteVertical from './Note/lineType-vertical'\nimport noteHorizontal from './Note/lineType-horizontal'\n\n//Connector options\nimport connectorLine from './Connector/type-line'\nimport connectorElbow from './Connector/type-elbow'\nimport connectorCurve from './Connector/type-curve'\nimport connectorArrow from './Connector/end-arrow'\nimport connectorDot from './Connector/end-dot'\n\n//Subject options\nimport subjectCircle from './Subject/circle'\nimport subjectRect from './Subject/rect'\nimport subjectThreshold from './Subject/threshold'\nimport subjectBadge from './Subject/badge'\n\nexport class Type {\n constructor({ a, annotation, editMode, dispatcher, notePadding, accessors }) {\n this.a = a\n\n this.note = annotation.disable.indexOf(\"note\") === -1 && a.select('g.annotation-note')\n this.noteContent = this.note && a.select('g.annotation-note-content')\n this.connector = annotation.disable.indexOf(\"connector\") === -1 && a.select('g.annotation-connector')\n this.subject = annotation.disable.indexOf(\"subject\") === -1 && a.select('g.annotation-subject')\n\n if (dispatcher){\n const handler = addHandlers.bind(null, dispatcher, annotation)\n handler({ component: this.note, name: 'note' })\n handler({ component: this.connector, name: 'connector' })\n handler({ component: this.subject, name: 'subject' })\n }\n \n this.annotation = annotation\n this.editMode = annotation.editMode || editMode\n this.notePadding = notePadding || 3\n this.offsetCornerX = 0\n this.offsetCornerY = 0\n\n if (accessors && annotation.data){\n this.init(accessors)\n }\n }\n\n init(accessors) {\n if (!this.annotation.x){\n this.mapX(accessors)\n }\n if (!this.annotation.y){\n this.mapY(accessors)\n }\n }\n\n mapY(accessors){\n if (accessors.y){\n this.annotation.y = accessors.y(this.annotation.data)\n }\n }\n\n mapX(accessors) {\n if (accessors.x){\n this.annotation.x = accessors.x(this.annotation.data)\n }\n }\n\n\n updateEditMode () {\n this.a.selectAll('circle.handle')\n .remove()\n }\n\n drawOnSVG (component, builders) {\n if (!Array.isArray(builders)){\n builders = [ builders ]\n }\n\n builders\n .filter(b => b)\n .forEach(({ type, className, attrs, handles}) => {\n if (type === \"handle\"){\n addHandles({ group: component, r: attrs && attrs.r, handles })\n } else {\n newWithClass(component, [this.annotation], type, className)\n \n const el = component.select(`${type}.${className}`) \n const attrKeys = Object.keys(attrs)\n attrKeys.forEach(attr => {\n if (attr === \"text\"){\n el.text(attrs[attr])\n } else {\n el.attr(attr, attrs[attr])\n }\n })\n }\n })\n }\n\n //TODO: how to extend this to a drawOnCanvas mode? \n\n getNoteBBox() { return bboxWithoutHandles(this.note, '.annotation-note-content text')}\n getNoteBBoxOffset() { \n const bbox = bboxWithoutHandles(this.note, '.annotation-note-content')\n const transform = this.noteContent.attr('transform').split(/\\(|\\,|\\)/g)\n bbox.offsetCornerX = parseFloat(transform[1]) + this.annotation.dx\n bbox.offsetCornerY = parseFloat(transform[2]) + this.annotation.dy\n bbox.offsetX = this.annotation.dx\n bbox.offsetY = this.annotation.dy\n return bbox \n }\n\n // getConnectorBBox() { return bboxWithoutHandles(this.connector)}\n // getSubjectBBox() { return bboxWithoutHandles(this.subject)}\n // getAnnotationBBox() { return bboxWithoutHandles(this.a)}\n\n drawSubject (context={}) {\n const subjectData = this.annotation.subject\n const type = context.type\n const subjectParams = { type: this, subjectData}\n\n let subject = {}\n if (type === \"circle\") subject = subjectCircle(subjectParams)\n else if (type === \"rect\") subject = subjectRect(subjectParams)\n else if (type === \"threshold\") subject = subjectThreshold(subjectParams)\n else if (type === \"badge\") subject = subjectBadge(subjectParams)\n\n let { components=[], handles=[] } = subject\n if (this.editMode){\n handles = handles.concat(this.mapHandles([{ drag: this.dragSubject.bind(this)}]))\n components.push({ type: \"handle\", handles })\n }\n\n return components\n }\n\n drawConnector (context={}) {\n const connectorData = this.annotation.connector\n const type = connectorData.type || context.type\n const connectorParams = { type: this, connectorData}\n connectorParams.subjectType = this.typeSettings && this.typeSettings.subject && this.typeSettings.subject.type \n\n let connector = {}\n if (type === \"curve\") connector = connectorCurve(connectorParams)\n else if (type === \"elbow\") connector = connectorElbow(connectorParams)\n else connector = connectorLine(connectorParams)\n\n let { components=[], handles=[] } = connector\n const line = components[0]\n const endType = connectorData.end || context.end\n let end = {}\n if (endType === \"arrow\") {\n let s = line.data[1]\n const e = line.data[0]\n const distance = Math.sqrt(Math.pow((s[0] - e[0]),2) + Math.pow((s[1] - e[1]),2))\n if (distance < 5 && line.data[2]) {\n s = line.data[2]\n }\n\n end = connectorArrow({ annotation: this.annotation, start: s, end: e })\n } else if (endType === \"dot\") {\n end = connectorDot({ line })\n }\n\n if (end.components){ components = components.concat(end.components)}\n\n if (this.editMode){\n if (handles.length !== 0) components.push({ type: \"handle\", handles })\n }\n return components;\n }\n\n drawNote (context={}) {\n const noteData = this.annotation.note\n const align = noteData.align || context.align || 'dynamic'\n const noteParams = { bbox: context.bbox, align, offset: this.annotation.offset }\n const lineType = noteData.lineType || context.lineType\n let note={}\n if (lineType == \"vertical\") note = noteVertical(noteParams)\n else if (lineType == \"horizontal\") note = noteHorizontal(noteParams)\n\n let { components=[], handles=[] } = note\n if (this.editMode) {\n handles = this.mapHandles([{ x: 0, y: 0, drag: this.dragNote.bind(this)}])\n components.push({ type: \"handle\", handles })\n }\n return components\n }\n\n drawNoteContent (context) {\n const noteData = this.annotation.note\n const padding = noteData.padding || this.notePadding\n let orientation = noteData.orientation || context.orientation || 'topBottom'\n const lineType = noteData.lineType || context.lineType\n const align = noteData.align || context.align || 'dynamic'\n const subjectType = this.typeSettings && this.typeSettings.subject && this.typeSettings.subject.type \n \n if (lineType == \"vertical\") orientation = \"leftRight\"\n else if (lineType == \"horizontal\") orientation = \"topBottom\"\n\n const noteParams = { padding, bbox: context.bbox, offset: \n this.annotation.offset, orientation, align }\n\n const { x, y } = noteAlignment(noteParams)\n this.offsetCornerX = x + this.annotation.dx\n this.offsetCornerY = y + this.annotation.dy\n this.note && this.noteContent.attr('transform', `translate(${x}, ${y})`)\n \n return []\n } \n\n drawOnScreen(component, drawFunction) { return this.drawOnSVG( component, drawFunction) }\n\n redrawSubject(){\n this.subject && this.drawOnScreen( this.subject, this.drawSubject())\n }\n\n redrawConnector(bbox=this.getNoteBBox()){\n this.connector && this.drawOnScreen( this.connector, this.drawConnector())\n }\n\n redrawNote(bbox=this.getNoteBBox()){\n this.noteContent && this.drawOnScreen( this.noteContent, this.drawNoteContent({ bbox }))\n this.note && this.drawOnScreen( this.note, this.drawNote({ bbox })) \n }\n\n setPosition(){\n const position = this.annotation.position \n this.a.attr('transform', `translate(${position.x}, ${position.y})`)\n }\n\n setOffset(){\n if (this.note){\n const offset = this.annotation.offset\n this.note.attr('transform', `translate(${offset.x}, ${offset.y})`)\n }\n }\n\n setPositionWithAccessors(accessors){\n if (accessors && this.annotation.data){\n this.mapX(accessors)\n this.mapY(accessors)\n }\n this.setPosition()\n }\n\n\n setClassName(){\n this.a.attr(\"class\", `annotation ${this.className && this.className()} ${this.editMode ? \"editable\" : \"\"} ${this.annotation.className || ''}`)\n }\n\n draw() {\n this.setClassName()\n this.setPosition()\n this.setOffset()\n this.redrawSubject()\n this.redrawConnector()\n this.redrawNote()\n }\n\n dragstarted() { event.sourceEvent.stopPropagation(); \n this.a.classed(\"dragging\", true) \n this.a.selectAll(\"circle.handle\").style(\"pointer-events\", \"none\")\n }\n dragended() { \n this.a.classed(\"dragging\", false)\n this.a.selectAll(\"circle.handle\").style(\"pointer-events\", \"all\")\n }\n\n dragSubject() {\n const position = this.annotation.position\n position.x += event.dx\n position.y += event.dy\n this.annotation.position = position\n }\n\n dragNote() {\n const offset = this.annotation.offset\n offset.x += event.dx\n offset.y += event.dy\n this.annotation.offset = offset\n }\n\n mapHandles(handles) {\n return handles\n .map(h => ({ ...h, \n start: this.dragstarted.bind(this), end: this.dragended.bind(this) }))\n }\n}\n\nexport const customType = (initialType, typeSettings, init) => {\n return class customType extends initialType {\n constructor (settings) {\n super(settings)\n this.typeSettings = typeSettings\n\n if (typeSettings.disable){\n typeSettings.disable.forEach(d => {\n this[d] = undefined\n if (d == \"note\"){\n this.noteContent = undefined\n }\n })\n }\n }\n\n static init(annotation, accessors){ \n super.init(annotation, accessors); \n if (init) {\n annotation = init(annotation, accessors) \n }\n return annotation\n }\n\n className(){ return `${typeSettings.className || ''} ${super.className && super.className() || ''}`}\n\n drawSubject(context){\n this.typeSettings.subject = Object.assign({}, typeSettings.subject, this.typeSettings.subject)\n return super.drawSubject({ ...context, ...this.typeSettings.subject })\n }\n\n drawConnector(context, subjectContext){\n this.typeSettings.connector = Object.assign({}, typeSettings.connector, this.typeSettings.connector)\n return super.drawConnector({ ...context, ...typeSettings.connector, ...this.typeSettings.connector })\n }\n\n drawNote(context){\n this.typeSettings.note = Object.assign({}, typeSettings.note, this.typeSettings.note)\n return super.drawNote({ ...context, ...typeSettings.note, ...this.typeSettings.note })\n }\n\n drawNoteContent(context){\n return super.drawNoteContent({ ...context, ...typeSettings.note, ...this.typeSettings.note })\n }\n }\n}\n\nexport class d3NoteText extends Type {\n\n constructor(params){\n super(params)\n this.textWrap = params.textWrap || 120\n this.drawText()\n }\n\n updateTextWrap (textWrap) {\n this.textWrap = textWrap\n this.drawText()\n }\n\n //TODO: add update text functionality\n\n drawText () {\n if (this.note){\n \n newWithClass(this.note, [this.annotation], 'g', 'annotation-note-content')\n\n const noteContent = this.note.select('g.annotation-note-content')\n newWithClass(noteContent, [this.annotation], 'rect', 'annotation-note-bg')\n newWithClass(noteContent, [this.annotation], 'text', 'annotation-note-label')\n newWithClass(noteContent, [this.annotation], 'text', 'annotation-note-title')\n\n let titleBBox = { height: 0 }\n const label = this.a.select('text.annotation-note-label')\n const wrapLength = this.annotation.note && this.annotation.note.wrap || \n this.typeSettings && this.typeSettings.note && this.typeSettings.note.wrap ||\n this.textWrap \n\n if (this.annotation.note.title){\n const title = this.a.select('text.annotation-note-title')\n title.text(this.annotation.note.title)\n .attr('dy', '1.1em')\n title.call(wrap, wrapLength)\n titleBBox = title.node().getBBox()\n }\n\n label.text(this.annotation.note.label)\n .attr('dy', '1em')\n label.call(wrap, wrapLength)\n\n label.attr('y', titleBBox.height * 1.1 || 0)\n\n const bbox = this.getNoteBBox()\n this.a.select('rect.annotation-note-bg')\n .attr('width', bbox.width)\n .attr('height', bbox.height)\n }\n }\n}\n\nexport const d3Label = customType(d3NoteText, {\n className: \"label\", \n note: { align: \"middle\"}\n})\n\nexport const d3Callout = customType(d3NoteText, {\n className: \"callout\",\n note: { lineType: \"horizontal\" }\n})\n\nexport const d3CalloutElbow = customType(d3Callout, {\n className: \"callout elbow\",\n connector: { type: \"elbow\" }\n})\n\nexport const d3CalloutCurve = customType(d3Callout, {\n className: \"callout curve\",\n connector: { type: \"curve\" }\n})\n\nexport const d3Badge = customType(Type, {\n className: \"badge\",\n subject: { type: \"badge\"},\n disable: ['connector', 'note']\n})\n\n\nexport const d3CalloutCircle = customType(d3CalloutElbow, {\n className: \"callout circle\",\n subject: { type: \"circle\"}\n})\n\nexport const d3CalloutRect = customType(d3CalloutElbow, {\n className: \"callout rect\",\n subject: { type: \"rect\"}\n})\n\n\nclass ThresholdMap extends d3Callout {\n\n mapY(accessors){\n super.mapY(accessors)\n const a = this.annotation\n if ((a.subject.x1 || a.subject.x2) && a.data && accessors.y){\n a.y = accessors.y(a.data)\n }\n }\n\n mapX(accessors) {\n super.mapX(accessors)\n const a = this.annotation\n if ((a.subject.y1 || a.subject.y2) && a.data && accessors.x){\n a.x = accessors.x(a.data)\n }\n }\n}\n\nexport const d3XYThreshold = customType(ThresholdMap, {\n className: \"callout xythreshold\",\n subject: { type: \"threshold\"}\n})\n\n\n\nexport const newWithClass = (a, d, type, className) => {\n const group = a.selectAll(`${type}.${className}`).data(d)\n group.enter()\n .append(type)\n .merge(group)\n .attr('class', className)\n\n group.exit().remove()\n return a\n}\n\n\nconst addHandlers = ( dispatcher, annotation, { component, name }) => {\n if (component){\n component\n .on(\"mouseover.annotations\", () => {\n dispatcher.call(`${name}over`, component, annotation)})\n .on(\"mouseout.annotations\", () => dispatcher.call(`${name}out`, component, annotation))\n .on(\"click.annotations\", () => dispatcher.call(`${name}click`, component, annotation))\n }\n}\n\n//Text wrapping code adapted from Mike Bostock\nconst wrap = (text, width) => {\n text.each(function() {\n var text = select(this),\n words = text.text().split(/[ \\t\\r\\n]+/).reverse(),\n word,\n line = [],\n lineNumber = 0,\n lineHeight = .2, //ems\n y = text.attr(\"y\"),\n dy = parseFloat(text.attr(\"dy\")) || 0,\n tspan = text.text(null)\n .append(\"tspan\")\n .attr(\"x\", 0)\n .attr(\"dy\", dy + \"em\");\n\n while (word = words.pop()) {\n line.push(word);\n tspan.text(line.join(\" \"));\n if (tspan.node().getComputedTextLength() > width && line.length > 1) {\n line.pop();\n tspan.text(line.join(\" \"));\n line = [word];\n tspan = text.append(\"tspan\")\n .attr(\"x\", 0)\n .attr(\"dy\", lineHeight + dy + \"em\").text(word);\n }\n }\n });\n}\n\nconst bboxWithoutHandles = (selection, selector=':not(.handle)') => {\n if (!selection){\n return { x: 0, y: 0, width: 0, height: 0}\n }\n\n return selection.selectAll(selector).nodes().reduce((p, c) => {\n const bbox = c.getBBox()\n p.x = Math.min(p.x, bbox.x)\n p.y = Math.min(p.y, bbox.y)\n p.width = Math.max(p.width, bbox.width)\n p.height += bbox.height\n return p\n }, { x: 0, y: 0, width: 0, height: 0});\n}\n\nexport default {\n Type,\n d3Label,\n d3Callout,\n d3CalloutElbow,\n d3CalloutCurve,\n d3CalloutCircle,\n d3CalloutRect,\n d3XYThreshold,\n d3Badge,\n customType\n}\n","import Annotation from './Annotation'\nimport AnnotationCollection from './AnnotationCollection'\nimport { newWithClass, d3Callout } from './Types-d3'\nimport { select } from 'd3-selection'\nimport { dispatch } from 'd3-dispatch';\n\n\nexport default function annotation(){\n let annotations = [],\n collection,\n context, //TODO: add canvas functionality\n disable = [],\n accessors = {},\n accessorsInverse = {},\n editMode = false,\n ids,\n type = d3Callout,\n textWrap,\n notePadding,\n annotationDispatcher = dispatch(\n \"subjectover\", \"subjectout\", \"subjectclick\", \n \"connectorover\", \"connectorout\", \"connectorclick\", \n \"noteover\", \"noteout\", \"noteclick\"),\n sel;\n\n const annotation = function(selection){\n sel = selection\n //TODO: check to see if this is still needed \n if (!editMode){\n selection.selectAll(\"circle.handle\")\n .remove()\n }\n\n const translatedAnnotations = annotations\n .map(a => {\n if (!a.type) { a.type = type }\n if (!a.disable) {a.disable = disable}\n return new Annotation(a)\n });\n\n collection = new AnnotationCollection ({\n annotations: translatedAnnotations,\n accessors,\n accessorsInverse,\n ids\n })\n \n\n const annotationG = selection.selectAll('g').data([collection])\n annotationG.enter().append('g').attr('class', `annotations`)\n \n const group = selection.select('g.annotations')\n newWithClass(group, collection.annotations, 'g', 'annotation')\n\n const annotation = group.selectAll('g.annotation')\n \n annotation \n .each(function(d) {\n const a = select(this)\n const position = d.position\n\n a.attr('class', 'annotation')\n\n newWithClass(a, [d], 'g', 'annotation-connector')\n newWithClass(a, [d], 'g', 'annotation-subject')\n newWithClass(a, [d], 'g', 'annotation-note')\n newWithClass(a.select('g.annotation-note'), [d], 'g', 'annotation-note-content')\n\n d.type = new d.type({ a, annotation: d, textWrap, notePadding, editMode, \n dispatcher: annotationDispatcher, accessors })\n d.type.draw()\n })\n }\n\n annotation.json = function() {\n console.log('Annotations JSON was copied to your clipboard. Please note the annotation type is not JSON compatible. It appears in the objects array in the console, but not in the copied JSON.', collection.json)\n window.copy(JSON.stringify(collection.json.map(a => { delete a.type; return a })))\n return annotation\n }\n\n annotation.update = function(){\n if (annotations && collection){\n annotations = collection.annotations.map((a, i) => { a.type.draw(); return a }) \n }\n return annotation\n }\n\n annotation.updatedAccessors = function(){\n collection.setPositionWithAccessors()\n annotations = collection.annotations\n return annotation\n }\n\n annotation.disable = function(_){\n if (!arguments.length) return disable;\n disable = _\n if (collection) { \n collection.updateDisable(disable)\n annotations = collection.annotations\n }\n return annotation;\n }\n\n annotation.textWrap = function(_){\n if (!arguments.length) return textWrap;\n textWrap = _\n if (collection) { \n collection.updateTextWrap(textWrap)\n annotations = collection.annotations\n }\n return annotation;\n }\n\n annotation.notePadding = function(_){\n if (!arguments.length) return notePadding;\n notePadding = _\n if (collection) { \n collection.updateNotePadding(notePadding)\n annotations = collection.annotations\n }\n return annotation;\n }\n\n annotation.type = function(_, settings) {\n if (!arguments.length) return type;\n type = _;\n if (collection) { \n collection.annotations.map(a => {\n \n a.type.note && a.type.note.selectAll(\"*:not(.annotation-note-content)\").remove()\n a.type.noteContent && a.type.noteContent.selectAll(\"*\").remove()\n a.type.subject && a.type.subject.selectAll(\"*\").remove()\n a.type.connector && a.type.connector.selectAll(\"*\").remove()\n a.type.typeSettings = {}\n a.type = type\n\n a.subject = settings && settings.subject || a.subject\n a.connector = settings && settings.connector || a.connector\n a.note = settings && settings.note || a.note\n })\n\n annotations = collection.annotations\n }\n return annotation;\n }\n\n annotation.annotations = function(_) {\n if (!arguments.length) return collection && collection.annotations || annotations;\n annotations = _\n return annotation;\n };\n\n annotation.context = function(_) {\n if (!arguments.length) return context;\n context = _\n return annotation;\n }; \n\n annotation.accessors = function(_) {\n if (!arguments.length) return accessors;\n accessors = _;\n return annotation\n }\n\n annotation.accessorsInverse = function(_) {\n if (!arguments.length) return accessorsInverse;\n accessorsInverse = _;\n return annotation\n }\n\n annotation.ids = function(_) {\n if (!arguments.length) return ids;\n ids = _;\n return annotation\n }\n\n annotation.editMode = function(_) {\n if (!arguments.length) return editMode;\n editMode = _\n\n if (sel){\n sel.selectAll('g.annotation')\n .classed('editable', editMode)\n }\n\n if (collection) { \n collection.editMode(editMode)\n annotations = collection.annotations\n }\n return annotation\n }\n\n annotation.collection = function(_) {\n if (!arguments.length) return collection;\n collection = _\n return annotation\n }\n\n annotation.on = function(){\n const value = annotationDispatcher.on.apply(annotationDispatcher, arguments)\n return value === annotationDispatcher ? annotation : value;\n }\n\n return annotation;\n\n};","import annotation from './src/Adapter-d3'\nimport { Type, d3Label, d3Callout, d3CalloutCurve, d3CalloutElbow, d3CalloutCircle, \n d3CalloutRect, d3XYThreshold, d3Badge, customType } from './src/Types-d3'\n\n\nexport {\n annotation,\n Type as annotationTypeBase ,\n d3Label as annotationLabel ,\n d3Callout as annotationCallout ,\n d3CalloutCurve as annotationCalloutCurve ,\n d3CalloutElbow as annotationCalloutElbow ,\n d3CalloutCircle as annotationCalloutCircle ,\n d3CalloutRect as annotationCalloutRect ,\n d3XYThreshold as annotationXYThreshold ,\n d3Badge as annotationBadge ,\n customType as annotationCustomType \n}\n\nexport default {\n annotation,\n annotationTypeBase : Type,\n annotationLabel : d3Label,\n annotationCallout : d3Callout,\n annotationCalloutCurve : d3CalloutCurve,\n annotationCalloutElbow : d3CalloutElbow,\n annotationCalloutCircle : d3CalloutCircle,\n annotationCalloutRect : d3CalloutRect,\n annotationXYThreshold : d3XYThreshold,\n annotationBadge : d3Badge,\n annotationCustomType : customType\n}"],"names":["Annotation","x","y","dy","dx","data","type","subject","connector","note","disable","id","className","_dx","_dy","_x","_y","_className","setPosition","selectAll","nodes","length","redrawSubject","setOffset","redrawConnector","redrawNote","setClassName","updatePosition","updateOffset","json","Object","keys","AnnotationCollection","annotations","accessors","accessorsInverse","newSettings","forEach","undefined","d","setPositionWithAccessors","editMode","a","updateEditMode","remove","textWrap","updateTextWrap","notePadding","map","k","getNoteBBoxOffset","positionX","positionY","pointHandle","cx","cy","move","circleHandles","r1","r2","padding","h","Math","sqrt","addHandles","group","handles","r","enter","append","attr","call","drag","container","select","node","on","start","end","exit","leftRightDynamic","align","topBottomDynamic","bbox","orientation","offset","height","width","lineBuilder","curve","curveLinear","canvasContext","lineGen","line","builder","context","pathMethods","attrs","arcBuilder","arcShape","arc","innerRadius","outerRadius","radius","startAngle","endAngle","PI","components","lineSetup","subjectType","annotation","position","x1","x2","y1","y2","subjectData","angle","asin","radiusPadding","abs","cos","sin","connectorData","diffY","diffX","xe","ye","opposite","acos","points","createPoints","curveCatmullRom","cHandles","c","i","index","updatePoint","event","mapHandles","bind","anchors","diff","p","push","size","angleOffset","atan","dot","transform","updateRadius","rect","updateWidth","updateHeight","rHandles","circlebg","circle","pointer","dragBadge","bHandles","text","Type","dispatcher","indexOf","noteContent","handler","addHandlers","component","name","offsetCornerX","offsetCornerY","init","mapX","mapY","builders","Array","isArray","filter","b","el","attrKeys","bboxWithoutHandles","split","parseFloat","offsetX","offsetY","subjectParams","subjectCircle","subjectRect","subjectThreshold","subjectBadge","concat","dragSubject","connectorParams","typeSettings","connectorCurve","connectorElbow","connectorLine","endType","s","e","distance","pow","connectorArrow","connectorDot","noteData","noteParams","lineType","noteVertical","noteHorizontal","dragNote","noteAlignment","drawFunction","drawOnSVG","drawOnScreen","drawSubject","getNoteBBox","drawConnector","drawNoteContent","drawNote","sourceEvent","stopPropagation","classed","style","dragstarted","dragended","customType","initialType","settings","babelHelpers.get","assign","subjectContext","d3NoteText","params","drawText","titleBBox","label","wrapLength","wrap","title","getBBox","d3Label","d3Callout","d3CalloutElbow","d3CalloutCurve","d3Badge","d3CalloutCircle","d3CalloutRect","ThresholdMap","d3XYThreshold","newWithClass","merge","each","words","reverse","word","lineNumber","lineHeight","tspan","pop","join","getComputedTextLength","selection","selector","reduce","min","max","collection","ids","annotationDispatcher","dispatch","sel","translatedAnnotations","annotationG","draw","log","copy","JSON","stringify","update","updatedAccessors","_","arguments","updateDisable","updateNotePadding","value","apply"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACqBA;4BAES;sBADdC,CACc;QADdA,CACc,0BADZ,CACY;sBADTC,CACS;QADTA,CACS,0BADP,CACO;uBADJC,EACI;QADJA,EACI,2BADD,CACC;uBADEC,EACF;QADEA,EACF,2BADK,CACL;QADQC,IACR,QADQA,IACR;QADcC,IACd,QADcA,IACd;QADoBC,OACpB,QADoBA,OACpB;QAD6BC,SAC7B,QAD6BA,SAC7B;QADwCC,IACxC,QADwCA,IACxC;QAA1BC,OAA0B,QAA1BA,OAA0B;QAAjBC,EAAiB,QAAjBA,EAAiB;QAAbC,SAAa,QAAbA,SAAa;;;;SAErBC,GAAL,GAAWT,EAAX;SACKU,GAAL,GAAWX,EAAX;SACKY,EAAL,GAAUd,CAAV;SACKe,EAAL,GAAUd,CAAV;SACKS,EAAL,GAAUA,EAAV;SACKM,UAAL,GAAkBL,aAAa,EAA/B;;SAEKN,IAAL,GAAYA,QAAQ,EAApB;SACKD,IAAL,GAAYA,IAAZ;;SAEKI,IAAL,GAAYA,QAAQ,EAApB;SACKD,SAAL,GAAiBA,aAAa,EAA9B;SACKD,OAAL,GAAeA,WAAW,EAA1B;;SAEKG,OAAL,GAAeA,WAAW,EAA1B;;;;;qCAGc;UACV,KAAKJ,IAAL,CAAUY,WAAd,EAA2B;aACpBZ,IAAL,CAAUY,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c,cAAd,EACG2M,OADH,CACW,UADX,EACuBrL,QADvB;;;QAIEkO,UAAJ,EAAgB;iBACHlO,QAAX,CAAoBA,QAApB;oBACckO,WAAW1O,WAAzB;;WAEK6E,UAAP;GAbF;;aAgBW6J,UAAX,GAAwB,UAASc,CAAT,EAAY;QAC9B,CAACC,UAAUrQ,MAAf,EAAuB,OAAOsP,UAAP;iBACVc,CAAb;WACO3K,UAAP;GAHF;;aAMWlC,EAAX,GAAgB,YAAU;QAClBiN,QAAQhB,qBAAqBjM,EAArB,CAAwBkN,KAAxB,CAA8BjB,oBAA9B,EAAoDa,SAApD,CAAd;WACOG,UAAUhB,oBAAV,GAAiC/J,UAAjC,GAA8C+K,KAArD;GAFF;;SAKO/K,UAAP;;;ACxLF,YAAe;wBAAA;sBAEQmD,IAFR;mBAGKgF,OAHL;qBAIOC,SAJP;0BAKYE,cALZ;0BAMYD,cANZ;2BAOaG,eAPb;yBAQWC,aARX;yBASWE,aATX;mBAUKJ,OAVL;wBAWUnB;CAXzB;;"} \ No newline at end of file diff --git a/package.json b/package.json index 0170a94..17db296 100644 --- a/package.json +++ b/package.json @@ -3,12 +3,14 @@ "version": "1.5.0", "description": "", "main": "indexRollup.js", - "jsnext:main": "indexRollup.mjs", + "jsnext:main": "indexRollupNext.js", + "module": "indexRollupNext.js", "files": [ "index.js", "indexRollup.js", "indexRollup.js.map", - "indexRollup.mjs", + "indexRollupNext.js", + "indexRollupNext.js.map", "d3-annotation.*", "types/*" ], @@ -25,9 +27,9 @@ "marked": "0.3.6", "markedify": "0.0.2", "npm-watch": "0.1.6", - "rollup": "0.34.7", + "rollup": "0.41.4", "rollup-plugin-babel": "2.6.1", - "uglify-js": "^2.8.1" + "uglify-js": "2.8.1" }, "scripts": { "start": "npm run server & npm run watch", diff --git a/rollup.config.js b/rollup.config.js index d933821..031e414 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -2,25 +2,36 @@ import babel from 'rollup-plugin-babel'; import babelrc from 'babelrc-rollup'; let pkg = require('./package.json'); -let external = Object.keys(pkg.dependencies); export default { entry: 'index.js', plugins: [ babel(babelrc()) ], - external: external, targets: [ { dest: pkg['main'], format: 'umd', - moduleName: 'indexRollup', - sourceMap: true + moduleName: 'd3', + sourceMap: true, + globals: { + 'd3-selection': 'd3', + 'd3-dispatch': 'd3', + 'd3-shape': 'd3', + 'd3-drag': 'd3' + } }, { dest: pkg['jsnext:main'], format: 'es', - sourceMap: true + moduleName: 'd3', + sourceMap: true, + globals: { + 'd3-selection': 'd3', + 'd3-dispatch': 'd3', + 'd3-shape': 'd3', + 'd3-drag': 'd3' + } } ] }; diff --git a/src/Types-d3.js b/src/Types-d3.js index f0ec520..4e16a9c 100644 --- a/src/Types-d3.js +++ b/src/Types-d3.js @@ -1,6 +1,5 @@ import { select, event } from 'd3-selection' import { drag } from 'd3-drag' -import { Annotation } from './Annotation' import { addHandles } from './Handles' //Note options