Remove d3-textwrap

This commit is contained in:
Tyler Long
2018-03-08 21:33:23 +08:00
parent ebbf3bfa77
commit 6a9bd22904
4 changed files with 3 additions and 33 deletions

View File

@@ -38,7 +38,6 @@
}, },
"dependencies": { "dependencies": {
"d3": "^4.13.0", "d3": "^4.13.0",
"d3-textwrap": "^2.0.2",
"dagre-d3-renderer": "^0.5.1", "dagre-d3-renderer": "^0.5.1",
"dagre-layout": "^0.8.6", "dagre-layout": "^0.8.6",
"graphlibrary": "^2.2.0", "graphlibrary": "^2.2.0",

View File

@@ -33,14 +33,6 @@ export const drawText = function (elem, textData, width) {
span.attr('x', textData.x + textData.textMargin * 2) span.attr('x', textData.x + textData.textMargin * 2)
span.attr('fill', textData.fill) span.attr('fill', textData.fill)
span.text(nText) span.text(nText)
if (typeof textElem.textwrap !== 'undefined') {
textElem.textwrap({
x: textData.x, // bounding box is 300 pixels from the left
y: textData.y, // bounding box is 400 pixels from the top
width: width, // bounding box is 500 pixels across
height: 1800 // bounding box is 600 pixels tall
}, textData.textMargin)
}
return textElem return textElem
} }
@@ -61,6 +53,7 @@ export const drawLabel = function (elem, txtObject) {
txtObject.x = txtObject.x + 0.5 * txtObject.labelMargin txtObject.x = txtObject.x + 0.5 * txtObject.labelMargin
drawText(elem, txtObject) drawText(elem, txtObject)
} }
let actorCnt = -1 let actorCnt = -1
/** /**
* Draws an actor in the diagram with the attaced line * Draws an actor in the diagram with the attaced line
@@ -265,22 +258,8 @@ const _drawTextCandidateFunc = (function () {
.style('text-anchor', 'middle') .style('text-anchor', 'middle')
text.append('tspan') text.append('tspan')
.attr('x', x + width / 2).attr('dy', '0') .attr('x', x + width / 2).attr('dy', '0')
.text(content) .text(content) // todo: fix position y
if (typeof (text.textwrap) !== 'undefined') {
text.textwrap({ // d3textwrap
x: x + width / 2, y: y, width: width, height: height
}, 0)
// vertical aligment after d3textwrap expans tspan to multiple tspans
let tspans = text.selectAll('tspan')
if (tspans.length > 0 && tspans[0].length > 0) {
tspans = tspans[0]
// set y of <text> to the mid y of the first line
text.attr('y', y + (height / 2.0 - text[0][0].getBBox().height * (1 - 1.0 / tspans.length) / 2.0))
.attr('dominant-baseline', 'central')
.attr('alignment-baseline', 'central')
}
}
_setTextAttrs(text, textAttrs) _setTextAttrs(text, textAttrs)
} }

View File

@@ -7,8 +7,6 @@
- Setup code coverage - Setup code coverage
- Create a desktop client - Create a desktop client
- Fix sequence diagram node label position issue - Fix sequence diagram node label position issue
- caused by d3-textwrap?
- remove textwrap feature?
- Fix flowchart interpolate/curve issue - Fix flowchart interpolate/curve issue
- not a common feature so dist/index.html cannot reproduce this issue - not a common feature so dist/index.html cannot reproduce this issue
- Support customization of gantt diagram xAxis format - Support customization of gantt diagram xAxis format

View File

@@ -2411,7 +2411,7 @@ d3-scale@1.0.7:
d3-time "1" d3-time "1"
d3-time-format "2" d3-time-format "2"
d3-selection@1, d3-selection@1.3.0, d3-selection@^1.0.2, d3-selection@^1.1.0: d3-selection@1, d3-selection@1.3.0, d3-selection@^1.1.0:
version "1.3.0" version "1.3.0"
resolved "https://registry.yarnpkg.com/d3-selection/-/d3-selection-1.3.0.tgz#d53772382d3dc4f7507bfb28bcd2d6aed2a0ad6d" resolved "https://registry.yarnpkg.com/d3-selection/-/d3-selection-1.3.0.tgz#d53772382d3dc4f7507bfb28bcd2d6aed2a0ad6d"
@@ -2421,12 +2421,6 @@ d3-shape@1.2.0:
dependencies: dependencies:
d3-path "1" d3-path "1"
d3-textwrap@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/d3-textwrap/-/d3-textwrap-2.0.2.tgz#7026dad5fd109bb280bfa3b5af2a8f6981290034"
dependencies:
d3-selection "^1.0.2"
d3-time-format@2, d3-time-format@2.1.1: d3-time-format@2, d3-time-format@2.1.1:
version "2.1.1" version "2.1.1"
resolved "https://registry.yarnpkg.com/d3-time-format/-/d3-time-format-2.1.1.tgz#85b7cdfbc9ffca187f14d3c456ffda268081bb31" resolved "https://registry.yarnpkg.com/d3-time-format/-/d3-time-format-2.1.1.tgz#85b7cdfbc9ffca187f14d3c456ffda268081bb31"