mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-10 02:49:40 +02:00
#1029 Linting fixes
This commit is contained in:
@@ -276,7 +276,7 @@ export const getClasses = function(text) {
|
|||||||
* @param text
|
* @param text
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
export const draw = function (text, id) {
|
export const draw = function(text, id) {
|
||||||
logger.info('Drawing flowchart');
|
logger.info('Drawing flowchart');
|
||||||
flowDb.clear();
|
flowDb.clear();
|
||||||
const parser = flow.parser;
|
const parser = flow.parser;
|
||||||
@@ -308,7 +308,7 @@ export const draw = function (text, id) {
|
|||||||
marginx: 8,
|
marginx: 8,
|
||||||
marginy: 8
|
marginy: 8
|
||||||
})
|
})
|
||||||
.setDefaultEdgeLabel(function () {
|
.setDefaultEdgeLabel(function() {
|
||||||
return {};
|
return {};
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -321,7 +321,7 @@ export const draw = function (text, id) {
|
|||||||
marginx: 20,
|
marginx: 20,
|
||||||
marginy: 20
|
marginy: 20
|
||||||
})
|
})
|
||||||
.setDefaultEdgeLabel(function () {
|
.setDefaultEdgeLabel(function() {
|
||||||
return {};
|
return {};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -403,7 +403,7 @@ export const draw = function (text, id) {
|
|||||||
const element = d3.select('#' + id + ' g');
|
const element = d3.select('#' + id + ' g');
|
||||||
render(element, g);
|
render(element, g);
|
||||||
|
|
||||||
element.selectAll('g.node').attr('title', function () {
|
element.selectAll('g.node').attr('title', function() {
|
||||||
return flowDb.getTooltip(this.id);
|
return flowDb.getTooltip(this.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -414,37 +414,44 @@ export const draw = function (text, id) {
|
|||||||
const svgBounds = svg.node().getBBox();
|
const svgBounds = svg.node().getBBox();
|
||||||
const width = svgBounds.width + padding * 2;
|
const width = svgBounds.width + padding * 2;
|
||||||
const height = svgBounds.height + padding * 2;
|
const height = svgBounds.height + padding * 2;
|
||||||
logger.debug(`new ViewBox 0 0 ${width} ${height}`, `translate(${padding - g._label.marginx}, ${padding - g._label.marginy})`);
|
logger.debug(
|
||||||
|
`new ViewBox 0 0 ${width} ${height}`,
|
||||||
|
`translate(${padding - g._label.marginx}, ${padding - g._label.marginy})`
|
||||||
|
);
|
||||||
|
|
||||||
if (conf.useMaxWidth) {
|
if (conf.useMaxWidth) {
|
||||||
svg.attr('width', '100%');
|
svg.attr('width', '100%');
|
||||||
svg.attr('style', `max-width: ${width}px;`);
|
svg.attr('style', `max-width: ${width}px;`);
|
||||||
|
} else {
|
||||||
|
svg.attr('height', height);
|
||||||
|
svg.attr('width', width);
|
||||||
|
}
|
||||||
|
|
||||||
|
svg.attr('viewBox', `0 0 ${width} ${height}`);
|
||||||
|
svg
|
||||||
|
.select('g')
|
||||||
|
.attr('transform', `translate(${padding - g._label.marginx}, ${padding - svgBounds.y})`);
|
||||||
} else {
|
} else {
|
||||||
svg.attr('height', height);
|
const width = g.maxX - g.minX + padding * 2;
|
||||||
svg.attr('width', width);
|
const height = g.maxY - g.minY + padding * 2;
|
||||||
|
|
||||||
|
if (conf.useMaxWidth) {
|
||||||
|
svg.attr('width', '100%');
|
||||||
|
svg.attr('style', `max-width: ${width}px;`);
|
||||||
|
} else {
|
||||||
|
svg.attr('height', height);
|
||||||
|
svg.attr('width', width);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug(
|
||||||
|
`Org ViewBox 0 0 ${width} ${height}`,
|
||||||
|
`translate(${padding - g.minX}, ${padding - g.minY})\n${location.href}`
|
||||||
|
);
|
||||||
|
|
||||||
|
svg.attr('viewBox', `0 0 ${width} ${height}`);
|
||||||
|
svg.select('g').attr('transform', `translate(${padding - g.minX}, ${padding - g.minY})`);
|
||||||
|
// svg.select('g').attr('transform', `translate(${padding - minX}, ${padding - minY})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
svg.attr('viewBox', `0 0 ${width} ${height}`);
|
|
||||||
svg.select('g').attr('transform', `translate(${padding - g._label.marginx}, ${padding - svgBounds.y})`);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
const width = g.maxX - g.minX + padding * 2;
|
|
||||||
const height = g.maxY - g.minY + padding * 2;
|
|
||||||
|
|
||||||
if (conf.useMaxWidth) {
|
|
||||||
svg.attr('width', '100%');
|
|
||||||
svg.attr('style', `max-width: ${width}px;`);
|
|
||||||
} else {
|
|
||||||
svg.attr('height', height);
|
|
||||||
svg.attr('width', width);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug(`Org ViewBox 0 0 ${width} ${height}`, `translate(${padding - g.minX}, ${padding - g.minY})\n${location.href}`)
|
|
||||||
|
|
||||||
svg.attr('viewBox', `0 0 ${width} ${height}`);
|
|
||||||
svg.select('g').attr('transform', `translate(${padding - g.minX}, ${padding - g.minY})`);
|
|
||||||
// svg.select('g').attr('transform', `translate(${padding - minX}, ${padding - minY})`);
|
|
||||||
}
|
|
||||||
// Index nodes
|
// Index nodes
|
||||||
flowDb.indexNodes('subGraph' + i);
|
flowDb.indexNodes('subGraph' + i);
|
||||||
|
|
||||||
|
@@ -436,9 +436,9 @@ export const drawEdge = function(elem, path, relation) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rows.length > 1) {
|
if (rows.length > 1) {
|
||||||
const heightAdj = rows.length * titleHeight * 0.25;
|
const heightAdj = rows.length * titleHeight * 0.25;
|
||||||
|
|
||||||
titleRows.forEach((title, i) => title.attr('y', y + i * titleHeight - heightAdj));
|
titleRows.forEach((title, i) => title.attr('y', y + i * titleHeight - heightAdj));
|
||||||
}
|
}
|
||||||
|
|
||||||
const bounds = label.node().getBBox();
|
const bounds = label.node().getBBox();
|
||||||
|
Reference in New Issue
Block a user