d3-svg-annotation
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -491,3 +491,3 @@ (function (global, factory) { | ||
var leftRightDynamic = function leftRightDynamic(align, y) { | ||
if (align == "dynamic" || align == "left" || align == "right") { | ||
if (align === "dynamic" || align === "left" || align === "right") { | ||
if (y < 0) { | ||
@@ -503,3 +503,3 @@ align = "top"; | ||
var topBottomDynamic = function topBottomDynamic(align, x) { | ||
if (align == "dynamic" || align == "top" || align == "bottom") { | ||
if (align === "dynamic" || align === "top" || align === "bottom") { | ||
if (x < 0) { | ||
@@ -514,8 +514,14 @@ align = "right"; | ||
var orientationTopBottom = ["topBottom", "top", "bottom"]; | ||
var orientationLeftRight = ["leftRight", "left", "right"]; | ||
var noteAlignment = (function (_ref) { | ||
var padding = _ref.padding, | ||
bbox = _ref.bbox, | ||
var _ref$padding = _ref.padding, | ||
padding = _ref$padding === undefined ? 0 : _ref$padding, | ||
_ref$bbox = _ref.bbox, | ||
bbox = _ref$bbox === undefined ? { x: 0, y: 0, width: 0, height: 0 } : _ref$bbox, | ||
align = _ref.align, | ||
orientation = _ref.orientation, | ||
offset = _ref.offset; | ||
_ref$offset = _ref.offset, | ||
offset = _ref$offset === undefined ? { x: 0, y: 0 } : _ref$offset; | ||
@@ -525,5 +531,5 @@ var x = -bbox.x; | ||
if (orientation === "topBottom") { | ||
if (orientationTopBottom.indexOf(orientation) !== -1) { | ||
align = topBottomDynamic(align, offset.x); | ||
if (offset.y < 0) { | ||
if (offset.y < 0 && orientation === "topBotom" || orientation === "top") { | ||
y -= bbox.height + padding; | ||
@@ -539,5 +545,5 @@ } else { | ||
} | ||
} else if (orientation === "leftRight") { | ||
} else if (orientationLeftRight.indexOf(orientation) !== -1) { | ||
align = leftRightDynamic(align, offset.y); | ||
if (offset.x < 0) { | ||
if (offset.x < 0 && orientation === "leftRight" || orientation === "left") { | ||
x -= bbox.width + padding; | ||
@@ -619,10 +625,9 @@ } else { | ||
bbox = _ref.bbox, | ||
offset = _ref.offset, | ||
padding = _ref.padding; | ||
offset = _ref.offset; | ||
align = leftRightDynamic(align, offset.y); | ||
if (align == "top") { | ||
if (align === "top") { | ||
y -= bbox.height; | ||
} else if (align == "middle") { | ||
} else if (align === "middle") { | ||
y -= bbox.height / 2; | ||
@@ -642,10 +647,9 @@ } | ||
offset = _ref.offset, | ||
bbox = _ref.bbox, | ||
padding = _ref.padding; | ||
bbox = _ref.bbox; | ||
align = topBottomDynamic(align, offset.x); | ||
if (align == "right") { | ||
if (align === "right") { | ||
x -= bbox.width; | ||
} else if (align == "middle") { | ||
} else if (align === "middle") { | ||
x -= bbox.width / 2; | ||
@@ -672,3 +676,3 @@ } | ||
if (subjectType == "circle" && (subjectData.outerRadius || subjectData.radius)) { | ||
if (subjectType === "circle" && (subjectData.outerRadius || subjectData.radius)) { | ||
var h = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); | ||
@@ -682,3 +686,3 @@ var angle = Math.asin(-y2 / h); | ||
if (subjectType == "rect") { | ||
if (subjectType === "rect") { | ||
var width = subjectData.width, | ||
@@ -694,3 +698,3 @@ height = subjectData.height; | ||
} | ||
if (x1 == width / 2 && y1 == height / 2) { | ||
if (x1 === width / 2 && y1 === height / 2) { | ||
x1 = x2;y1 = y2; | ||
@@ -723,3 +727,3 @@ } | ||
if (subjectType == "rect") { | ||
if (subjectType === "rect") { | ||
var width = subjectData.width, | ||
@@ -735,3 +739,3 @@ height = subjectData.height; | ||
} | ||
if (x1 == width / 2 && y1 == height / 2) { | ||
if (x1 === width / 2 && y1 === height / 2) { | ||
x1 = x2;y1 = y2; | ||
@@ -757,3 +761,3 @@ } | ||
if (subjectType == "circle" && (subjectData.outerRadius || subjectData.radius)) { | ||
if (subjectType === "circle" && (subjectData.outerRadius || subjectData.radius)) { | ||
var r = (subjectData.outerRadius || subjectData.radius) + (subjectData.radiusPadding || 0); | ||
@@ -953,3 +957,3 @@ var length = r / Math.sqrt(2); | ||
var updateWidth = function updateWidth(attr) { | ||
var updateWidth = function updateWidth() { | ||
subjectData.width = d3Selection.event.x; | ||
@@ -1000,4 +1004,4 @@ type.redrawSubject(); | ||
var innerRadius = radius * .7; | ||
var x = subjectData.x == "left" ? -radius : radius; | ||
var y = subjectData.y == "top" ? -radius : radius; | ||
var x = subjectData.x === "left" ? -radius : radius; | ||
var y = subjectData.y === "top" ? -radius : radius; | ||
var transform = 'translate(' + x + ', ' + y + ')'; | ||
@@ -1249,3 +1253,3 @@ var circlebg = arcBuilder({ className: 'subject', data: { radius: radius } }); | ||
var note = {}; | ||
if (lineType == "vertical") note = noteVertical(noteParams);else if (lineType == "horizontal") note = noteHorizontal(noteParams); | ||
if (lineType === "vertical") note = noteVertical(noteParams);else if (lineType === "horizontal") note = noteHorizontal(noteParams); | ||
@@ -1272,5 +1276,4 @@ var _note = note, | ||
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"; | ||
@@ -1302,4 +1305,2 @@ var noteParams = { padding: padding, bbox: context.bbox, offset: this.annotation.offset, orientation: orientation, align: align }; | ||
value: function redrawConnector() { | ||
var bbox = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getNoteBBox(); | ||
this.connector && this.drawOnScreen(this.connector, this.drawConnector()); | ||
@@ -1410,3 +1411,3 @@ } | ||
_this3[d] = undefined; | ||
if (d == "note") { | ||
if (d === "note") { | ||
_this3.noteContent = undefined; | ||
@@ -1422,3 +1423,3 @@ } | ||
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) || ''); | ||
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) || ''); | ||
} | ||
@@ -1433,3 +1434,3 @@ }, { | ||
key: 'drawConnector', | ||
value: function drawConnector(context, subjectContext) { | ||
value: function drawConnector(context) { | ||
this.typeSettings.connector = Object.assign({}, typeSettings.connector, this.typeSettings.connector); | ||
@@ -1508,3 +1509,3 @@ return get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'drawConnector', this).call(this, _extends({}, context, typeSettings.connector, this.typeSettings.connector)); | ||
label.text(this.annotation.note.label).attr('dy', '1em'); | ||
label.text(this.annotation.note.label).attr('dy', '1em').attr('dx', '0'); | ||
label.call(wrap, wrapLength); | ||
@@ -1621,9 +1622,11 @@ | ||
words = text.text().split(/[ \t\r\n]+/).reverse(), | ||
word, | ||
// lineNumber = 0, | ||
lineHeight = .2, | ||
//ems | ||
// y = text.attr("y"), | ||
dy = parseFloat(text.attr("dy")) || 0; | ||
var word = void 0, | ||
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"); | ||
@@ -1711,3 +1714,2 @@ | ||
var a = d3Selection.select(this); | ||
var position = d.position; | ||
@@ -1737,3 +1739,3 @@ a.attr('class', 'annotation'); | ||
if (annotations && collection) { | ||
annotations = collection.annotations.map(function (a, i) { | ||
annotations = collection.annotations.map(function (a) { | ||
a.type.draw();return a; | ||
@@ -1740,0 +1742,0 @@ }); |
@@ -490,3 +490,3 @@ import { event, select } from 'd3-selection'; | ||
var leftRightDynamic = function leftRightDynamic(align, y) { | ||
if (align == "dynamic" || align == "left" || align == "right") { | ||
if (align === "dynamic" || align === "left" || align === "right") { | ||
if (y < 0) { | ||
@@ -502,3 +502,3 @@ align = "top"; | ||
var topBottomDynamic = function topBottomDynamic(align, x) { | ||
if (align == "dynamic" || align == "top" || align == "bottom") { | ||
if (align === "dynamic" || align === "top" || align === "bottom") { | ||
if (x < 0) { | ||
@@ -513,8 +513,14 @@ align = "right"; | ||
var orientationTopBottom = ["topBottom", "top", "bottom"]; | ||
var orientationLeftRight = ["leftRight", "left", "right"]; | ||
var noteAlignment = (function (_ref) { | ||
var padding = _ref.padding, | ||
bbox = _ref.bbox, | ||
var _ref$padding = _ref.padding, | ||
padding = _ref$padding === undefined ? 0 : _ref$padding, | ||
_ref$bbox = _ref.bbox, | ||
bbox = _ref$bbox === undefined ? { x: 0, y: 0, width: 0, height: 0 } : _ref$bbox, | ||
align = _ref.align, | ||
orientation = _ref.orientation, | ||
offset = _ref.offset; | ||
_ref$offset = _ref.offset, | ||
offset = _ref$offset === undefined ? { x: 0, y: 0 } : _ref$offset; | ||
@@ -524,5 +530,5 @@ var x = -bbox.x; | ||
if (orientation === "topBottom") { | ||
if (orientationTopBottom.indexOf(orientation) !== -1) { | ||
align = topBottomDynamic(align, offset.x); | ||
if (offset.y < 0) { | ||
if (offset.y < 0 && orientation === "topBotom" || orientation === "top") { | ||
y -= bbox.height + padding; | ||
@@ -538,5 +544,5 @@ } else { | ||
} | ||
} else if (orientation === "leftRight") { | ||
} else if (orientationLeftRight.indexOf(orientation) !== -1) { | ||
align = leftRightDynamic(align, offset.y); | ||
if (offset.x < 0) { | ||
if (offset.x < 0 && orientation === "leftRight" || orientation === "left") { | ||
x -= bbox.width + padding; | ||
@@ -618,10 +624,9 @@ } else { | ||
bbox = _ref.bbox, | ||
offset = _ref.offset, | ||
padding = _ref.padding; | ||
offset = _ref.offset; | ||
align = leftRightDynamic(align, offset.y); | ||
if (align == "top") { | ||
if (align === "top") { | ||
y -= bbox.height; | ||
} else if (align == "middle") { | ||
} else if (align === "middle") { | ||
y -= bbox.height / 2; | ||
@@ -641,10 +646,9 @@ } | ||
offset = _ref.offset, | ||
bbox = _ref.bbox, | ||
padding = _ref.padding; | ||
bbox = _ref.bbox; | ||
align = topBottomDynamic(align, offset.x); | ||
if (align == "right") { | ||
if (align === "right") { | ||
x -= bbox.width; | ||
} else if (align == "middle") { | ||
} else if (align === "middle") { | ||
x -= bbox.width / 2; | ||
@@ -671,3 +675,3 @@ } | ||
if (subjectType == "circle" && (subjectData.outerRadius || subjectData.radius)) { | ||
if (subjectType === "circle" && (subjectData.outerRadius || subjectData.radius)) { | ||
var h = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); | ||
@@ -681,3 +685,3 @@ var angle = Math.asin(-y2 / h); | ||
if (subjectType == "rect") { | ||
if (subjectType === "rect") { | ||
var width = subjectData.width, | ||
@@ -693,3 +697,3 @@ height = subjectData.height; | ||
} | ||
if (x1 == width / 2 && y1 == height / 2) { | ||
if (x1 === width / 2 && y1 === height / 2) { | ||
x1 = x2;y1 = y2; | ||
@@ -722,3 +726,3 @@ } | ||
if (subjectType == "rect") { | ||
if (subjectType === "rect") { | ||
var width = subjectData.width, | ||
@@ -734,3 +738,3 @@ height = subjectData.height; | ||
} | ||
if (x1 == width / 2 && y1 == height / 2) { | ||
if (x1 === width / 2 && y1 === height / 2) { | ||
x1 = x2;y1 = y2; | ||
@@ -756,3 +760,3 @@ } | ||
if (subjectType == "circle" && (subjectData.outerRadius || subjectData.radius)) { | ||
if (subjectType === "circle" && (subjectData.outerRadius || subjectData.radius)) { | ||
var r = (subjectData.outerRadius || subjectData.radius) + (subjectData.radiusPadding || 0); | ||
@@ -952,3 +956,3 @@ var length = r / Math.sqrt(2); | ||
var updateWidth = function updateWidth(attr) { | ||
var updateWidth = function updateWidth() { | ||
subjectData.width = event.x; | ||
@@ -999,4 +1003,4 @@ type.redrawSubject(); | ||
var innerRadius = radius * .7; | ||
var x = subjectData.x == "left" ? -radius : radius; | ||
var y = subjectData.y == "top" ? -radius : radius; | ||
var x = subjectData.x === "left" ? -radius : radius; | ||
var y = subjectData.y === "top" ? -radius : radius; | ||
var transform = 'translate(' + x + ', ' + y + ')'; | ||
@@ -1248,3 +1252,3 @@ var circlebg = arcBuilder({ className: 'subject', data: { radius: radius } }); | ||
var note = {}; | ||
if (lineType == "vertical") note = noteVertical(noteParams);else if (lineType == "horizontal") note = noteHorizontal(noteParams); | ||
if (lineType === "vertical") note = noteVertical(noteParams);else if (lineType === "horizontal") note = noteHorizontal(noteParams); | ||
@@ -1271,5 +1275,4 @@ var _note = note, | ||
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"; | ||
@@ -1301,4 +1304,2 @@ var noteParams = { padding: padding, bbox: context.bbox, offset: this.annotation.offset, orientation: orientation, align: align }; | ||
value: function redrawConnector() { | ||
var bbox = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getNoteBBox(); | ||
this.connector && this.drawOnScreen(this.connector, this.drawConnector()); | ||
@@ -1409,3 +1410,3 @@ } | ||
_this3[d] = undefined; | ||
if (d == "note") { | ||
if (d === "note") { | ||
_this3.noteContent = undefined; | ||
@@ -1421,3 +1422,3 @@ } | ||
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) || ''); | ||
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) || ''); | ||
} | ||
@@ -1432,3 +1433,3 @@ }, { | ||
key: 'drawConnector', | ||
value: function drawConnector(context, subjectContext) { | ||
value: function drawConnector(context) { | ||
this.typeSettings.connector = Object.assign({}, typeSettings.connector, this.typeSettings.connector); | ||
@@ -1507,3 +1508,3 @@ return get(customType.prototype.__proto__ || Object.getPrototypeOf(customType.prototype), 'drawConnector', this).call(this, _extends({}, context, typeSettings.connector, this.typeSettings.connector)); | ||
label.text(this.annotation.note.label).attr('dy', '1em'); | ||
label.text(this.annotation.note.label).attr('dy', '1em').attr('dx', '0'); | ||
label.call(wrap, wrapLength); | ||
@@ -1620,9 +1621,11 @@ | ||
words = text.text().split(/[ \t\r\n]+/).reverse(), | ||
word, | ||
// lineNumber = 0, | ||
lineHeight = .2, | ||
//ems | ||
// y = text.attr("y"), | ||
dy = parseFloat(text.attr("dy")) || 0; | ||
var word = void 0, | ||
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"); | ||
@@ -1710,3 +1713,2 @@ | ||
var a = select(this); | ||
var position = d.position; | ||
@@ -1736,3 +1738,3 @@ a.attr('class', 'annotation'); | ||
if (annotations && collection) { | ||
annotations = collection.annotations.map(function (a, i) { | ||
annotations = collection.annotations.map(function (a) { | ||
a.type.draw();return a; | ||
@@ -1739,0 +1741,0 @@ }); |
{ | ||
"name": "d3-svg-annotation", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "", | ||
@@ -20,2 +20,3 @@ "main": "indexRollup.js", | ||
"devDependencies": { | ||
"babel-eslint": "7.1.1", | ||
"babel-plugin-external-helpers": "6.18.0", | ||
@@ -27,6 +28,9 @@ "babel-plugin-transform-object-rest-spread": "6.20.2", | ||
"browserify": "13.1.1", | ||
"chai": "3.5.0", | ||
"http-server": "0.9.0", | ||
"marked": "0.3.6", | ||
"markedify": "0.0.2", | ||
"mocha": "3.2.0", | ||
"npm-watch": "0.1.6", | ||
"reify": "0.4.16", | ||
"rollup": "0.41.4", | ||
@@ -44,3 +48,4 @@ "rollup-plugin-babel": "2.6.1", | ||
"uglify": "uglifyjs d3-annotation.js -o d3-annotation.min.js -c -m", | ||
"prepublish": "npm run uglify & rollup -c" | ||
"prepublish": "npm test && npm run uglify && rollup -c", | ||
"test": "mocha --require reify" | ||
}, | ||
@@ -78,3 +83,4 @@ "watch": { | ||
"d3-transition": "1.0.3" | ||
} | ||
}, | ||
"homepage": "http://d3-annotation.susielu.com" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
542592
1
17
7999