mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 06:49:47 +02:00
Better width calculations for task texts
This commit is contained in:
@@ -9,7 +9,8 @@ var conf = {
|
|||||||
topPadding: 50,
|
topPadding: 50,
|
||||||
sidePadding: 75,
|
sidePadding: 75,
|
||||||
gridLineStartPadding: 35,
|
gridLineStartPadding: 35,
|
||||||
fontSize: 11
|
fontSize: 11,
|
||||||
|
fontFamily: '"Open-Sans", "sans-serif"'
|
||||||
};
|
};
|
||||||
module.exports.setConf = function (cnf) {
|
module.exports.setConf = function (cnf) {
|
||||||
var keys = Object.keys(cnf);
|
var keys = Object.keys(cnf);
|
||||||
@@ -176,6 +177,8 @@ module.exports.draw = function (text, id) {
|
|||||||
.text(function (d) {
|
.text(function (d) {
|
||||||
return d.task;
|
return d.task;
|
||||||
})
|
})
|
||||||
|
.attr("font-size",conf.fontSize)
|
||||||
|
//.attr("font-family",conf.fontFamily)
|
||||||
.attr("x", function (d) {
|
.attr("x", function (d) {
|
||||||
var startX = timeScale(d.startTime),
|
var startX = timeScale(d.startTime),
|
||||||
endX = timeScale(d.endTime),
|
endX = timeScale(d.endTime),
|
||||||
@@ -183,10 +186,10 @@ module.exports.draw = function (text, id) {
|
|||||||
|
|
||||||
// Check id text width > width of rectangle
|
// Check id text width > width of rectangle
|
||||||
if (textWidth > (endX - startX)) {
|
if (textWidth > (endX - startX)) {
|
||||||
if (endX + textWidth > w) {
|
if (endX + textWidth + 1.5*conf.sidePadding> w) {
|
||||||
return startX + theSidePad;
|
return startX + theSidePad - 5;
|
||||||
} else {
|
} else {
|
||||||
return endX + theSidePad;
|
return endX + theSidePad + 5;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return (endX - startX) / 2 + startX + theSidePad;
|
return (endX - startX) / 2 + startX + theSidePad;
|
||||||
@@ -210,10 +213,10 @@ module.exports.draw = function (text, id) {
|
|||||||
|
|
||||||
// Check id text width > width of rectangle
|
// Check id text width > width of rectangle
|
||||||
if (textWidth > (endX - startX)) {
|
if (textWidth > (endX - startX)) {
|
||||||
if (endX + textWidth > w) {
|
if (endX + textWidth + 1.5*conf.sidePadding > w) {
|
||||||
return 'taskTextOutsideLeft taskTextOutside' + secNum;
|
return 'taskTextOutsideLeft taskTextOutside' + secNum;
|
||||||
} else {
|
} else {
|
||||||
return 'taskTextOutsideRight taskTextOutsideRight' + secNum;
|
return 'taskTextOutsideRight taskTextOutside' + secNum;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return 'taskText taskText' + secNum;
|
return 'taskText taskText' + secNum;
|
||||||
|
Reference in New Issue
Block a user