#1110 Cleanup and removal of loggings

This commit is contained in:
Knut Sveidqvist
2019-12-04 18:04:56 +01:00
parent 0fb91d6bcc
commit 94e768dd01
4 changed files with 42 additions and 66 deletions

View File

@@ -12,33 +12,12 @@ parser.yy = stateDb;
// TODO Move conf object to main conf in mermaidAPI
let conf;
// {
// // Used
// padding: 5,
// // Font size factor, this is used to guess the width of the edges labels before rendering by dagre
// // layout. This might need updating if/when switching font
// fontSizeFactor: 5.02,
// labelHeight: 16,
// edgeLengthFactor: '20',
// compositTitleSize: 35
// };
const transformationLog = {};
export const setConf = function() {};
// Todo optimize
// const getGraphId = function(label) {
// const keys = idCache.keys();
// for (let i = 0; i < keys.length; i++) {
// if (idCache.get(keys[i]).label === label) {
// return keys[i];
// }
// }
// return undefined;
// };
/**
* Setup arrow head and define the marker. The result is appended to the svg.
@@ -68,11 +47,11 @@ export const draw = function(text, id) {
parser.parse(text);
logger.debug('Rendering diagram ' + text);
// /// / Fetch the default direction, use TD if none was found
// Fetch the default direction, use TD if none was found
const diagram = d3.select(`[id='${id}']`);
insertMarkers(diagram);
// // Layout graph, Create a new directed graph
// Layout graph, Create a new directed graph
const graph = new graphlib.Graph({
multigraph: false,
compound: true,
@@ -81,13 +60,13 @@ export const draw = function(text, id) {
// ranksep: '20'
});
// // Default to assigning a new object as a label for each new edge.
// Default to assigning a new object as a label for each new edge.
graph.setDefaultEdgeLabel(function() {
return {};
});
const rootDoc = stateDb.getRootDoc();
renderDoc(rootDoc, diagram);
renderDoc(rootDoc, diagram, undefined, false);
const padding = conf.padding;
const bounds = diagram.node().getBBox();
@@ -100,7 +79,7 @@ export const draw = function(text, id) {
// diagram.attr('height', height);
// Zoom in a bit
diagram.attr('width', width * 2);
diagram.attr('width', width * 1.75);
// diagram.attr('height', bounds.height * 3 + conf.padding * 2);
diagram.attr(
'viewBox',
@@ -128,7 +107,7 @@ const getRows = s => {
return str.split('#br#');
};
const renderDoc = (doc, diagram, parentId) => {
const renderDoc = (doc, diagram, parentId, altBkg) => {
// // Layout graph, Create a new directed graph
const graph = new graphlib.Graph({
compound: true
@@ -142,7 +121,7 @@ const renderDoc = (doc, diagram, parentId) => {
break;
}
}
console.warn('doc', doc, edgeFreeDoc);
// Set an object for the graph label
if (parentId)
graph.setGraph({
@@ -198,11 +177,11 @@ const renderDoc = (doc, diagram, parentId) => {
.append('g')
.attr('id', stateDef.id)
.attr('class', 'stateGroup');
node = renderDoc(stateDef.doc, sub, stateDef.id);
node = renderDoc(stateDef.doc, sub, stateDef.id, !altBkg);
if (first) {
// first = false;
sub = addTitleAndBox(sub, stateDef);
sub = addTitleAndBox(sub, stateDef, altBkg);
let boxBounds = sub.node().getBBox();
node.width = boxBounds.width;
node.height = boxBounds.height + conf.padding / 2;