mirror of
				https://github.com/mermaid-js/mermaid.git
				synced 2025-10-31 02:44:17 +01:00 
			
		
		
		
	Fix code style issues
This commit is contained in:
		
							
								
								
									
										38
									
								
								lib/cli.js
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								lib/cli.js
									
									
									
									
									
								
							| @@ -1,21 +1,21 @@ | |||||||
| var fs = require('fs'), | var fs = require('fs') | ||||||
|   exec = require('child_process').exec, | var exec = require('child_process').exec | ||||||
|   chalk = require('chalk'), | var chalk = require('chalk') | ||||||
|   which = require('which'), | var which = require('which') | ||||||
|   parseArgs = require('minimist'), | var parseArgs = require('minimist') | ||||||
|   semver = require('semver'), | var semver = require('semver') | ||||||
|   path = require('path') | var path = require('path') | ||||||
|  |  | ||||||
| var PHANTOM_VERSION = '^2.1.0' | var PHANTOM_VERSION = '^2.1.0' | ||||||
|  |  | ||||||
| var info = chalk.blue.bold, | var info = chalk.blue.bold | ||||||
|   note = chalk.green.bold | // var note = chalk.green.bold | ||||||
|  |  | ||||||
| module.exports = (function () { | module.exports = (function () { | ||||||
|   return new cli() |   return new Cli() | ||||||
| }()) | }()) | ||||||
|  |  | ||||||
| function cli (options) { | function Cli (options) { | ||||||
|   this.options = { |   this.options = { | ||||||
|     alias: { |     alias: { | ||||||
|       help: 'h', |       help: 'h', | ||||||
| @@ -37,7 +37,7 @@ function cli (options) { | |||||||
|   this.errors = [] |   this.errors = [] | ||||||
|   this.message = null |   this.message = null | ||||||
|  |  | ||||||
|   this.helpMessage = [, |   this.helpMessage = [ | ||||||
|     info('Usage: mermaid [options] <file>...'), |     info('Usage: mermaid [options] <file>...'), | ||||||
|     '', |     '', | ||||||
|     'file    The mermaid description file to be rendered', |     'file    The mermaid description file to be rendered', | ||||||
| @@ -60,10 +60,10 @@ function cli (options) { | |||||||
|   return this |   return this | ||||||
| } | } | ||||||
|  |  | ||||||
| cli.prototype.parse = function (argv, next) { | Cli.prototype.parse = function (argv, next) { | ||||||
|   this.errors = [] // clear errors |   this.errors = [] // clear errors | ||||||
|   var options = parseArgs(argv, this.options), |   var options = parseArgs(argv, this.options) | ||||||
|     phantom |   // var phantom | ||||||
|  |  | ||||||
|   if (options.version) { |   if (options.version) { | ||||||
|     var pkg = require('../package.json') |     var pkg = require('../package.json') | ||||||
| @@ -147,12 +147,12 @@ cli.prototype.parse = function (argv, next) { | |||||||
| } | } | ||||||
|  |  | ||||||
| function createCheckPhantom (_phantomPath) { | function createCheckPhantom (_phantomPath) { | ||||||
|   var phantomPath = _phantomPath, |   var phantomPath = _phantomPath | ||||||
|     phantomVersion |   // var phantomVersion | ||||||
|  |  | ||||||
|   return function checkPhantom (_next) { |   return function checkPhantom (_next) { | ||||||
|     var next = _next || function () {}, |     var next = _next || function () { } | ||||||
|       err |     var err | ||||||
|  |  | ||||||
|     if (typeof phantomPath === 'undefined') { |     if (typeof phantomPath === 'undefined') { | ||||||
|       try { |       try { | ||||||
|   | |||||||
							
								
								
									
										20
									
								
								lib/index.js
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								lib/index.js
									
									
									
									
									
								
							| @@ -1,7 +1,7 @@ | |||||||
| var os = require('os'), | // var os = require('os') | ||||||
|   fs = require('fs'), | // var fs = require('fs') | ||||||
|   path = require('path'), | var path = require('path') | ||||||
|   spawn = require('child_process').spawn | var spawn = require('child_process').spawn | ||||||
|  |  | ||||||
| var mkdirp = require('mkdirp') | var mkdirp = require('mkdirp') | ||||||
|  |  | ||||||
| @@ -10,11 +10,11 @@ var phantomscript = path.join(__dirname, 'phantomscript.js') | |||||||
| module.exports = { process: processMermaid } | module.exports = { process: processMermaid } | ||||||
|  |  | ||||||
| function processMermaid (files, _options, _next) { | function processMermaid (files, _options, _next) { | ||||||
|   var options = _options || {}, |   var options = _options || {} | ||||||
|     outputDir = options.outputDir || process.cwd(), |   var outputDir = options.outputDir || process.cwd() | ||||||
|     outputSuffix = options.outputSuffix || '', |   var outputSuffix = options.outputSuffix || '' | ||||||
|     next = _next || function () {}, |   var next = _next || function () { } | ||||||
|     phantomArgs = [ |   var phantomArgs = [ | ||||||
|     phantomscript, |     phantomscript, | ||||||
|     outputDir, |     outputDir, | ||||||
|     options.png, |     options.png, | ||||||
| @@ -35,7 +35,7 @@ function processMermaid (files, _options, _next) { | |||||||
|     if (err) { |     if (err) { | ||||||
|       throw err |       throw err | ||||||
|     } |     } | ||||||
|     phantom = spawn(options.phantomPath, phantomArgs) |     var phantom = spawn(options.phantomPath, phantomArgs) | ||||||
|  |  | ||||||
|     phantom.on('exit', next) |     phantom.on('exit', next) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|  *   https://github.com/filamentgroup/grunticon |  *   https://github.com/filamentgroup/grunticon | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| phantom.onError = function (msg, trace) { | window.phantom.onError = function (msg, trace) { | ||||||
|   var msgStack = ['PHANTOM ERROR: ' + msg] |   var msgStack = ['PHANTOM ERROR: ' + msg] | ||||||
|   if (trace && trace.length) { |   if (trace && trace.length) { | ||||||
|     msgStack.push('TRACE:') |     msgStack.push('TRACE:') | ||||||
| @@ -21,16 +21,16 @@ phantom.onError = function (msg, trace) { | |||||||
|     }) |     }) | ||||||
|   } |   } | ||||||
|   system.stderr.write(msgStack.join('\n')) |   system.stderr.write(msgStack.join('\n')) | ||||||
|   phantom.exit(1) |   window.phantom.exit(1) | ||||||
| } | } | ||||||
|  |  | ||||||
| var system = require('system'), | var system = require('system') | ||||||
|   fs = require('fs'), | var fs = require('fs') | ||||||
|   webpage = require('webpage') | var webpage = require('webpage') | ||||||
|  |  | ||||||
| var page = webpage.create(), | var page = webpage.create() | ||||||
|   files = system.args.slice(10, system.args.length), | var files = system.args.slice(10, system.args.length) | ||||||
|   width = system.args[8] | var width = system.args[8] | ||||||
|  |  | ||||||
| if (typeof width === 'undefined' || width === 'undefined') { | if (typeof width === 'undefined' || width === 'undefined') { | ||||||
|   width = 1200 |   width = 1200 | ||||||
| @@ -45,8 +45,8 @@ var options = { | |||||||
|   verbose: system.args[7] === 'true', |   verbose: system.args[7] === 'true', | ||||||
|   width: width, |   width: width, | ||||||
|   outputSuffix: system.args[9] |   outputSuffix: system.args[9] | ||||||
|   }, | } | ||||||
|   log = logger(options.verbose) | var log = logger(options.verbose) | ||||||
| options.sequenceConfig.useMaxWidth = false | options.sequenceConfig.useMaxWidth = false | ||||||
|  |  | ||||||
| page.content = [ | page.content = [ | ||||||
| @@ -69,12 +69,12 @@ page.onConsoleMessage = function (msg, lineNum, sourceId) { | |||||||
| console.log('Num files to execute : ' + files.length) | console.log('Num files to execute : ' + files.length) | ||||||
|  |  | ||||||
| files.forEach(function (file) { | files.forEach(function (file) { | ||||||
|   var contents = fs.read(file), |   var contents = fs.read(file) | ||||||
|     filename = file.split(fs.separator).slice(-1), |   var filename = file.split(fs.separator).slice(-1) | ||||||
|     oParser = new DOMParser(), |   var oParser = new window.DOMParser() | ||||||
|     oDOM, |   var oDOM | ||||||
|     svgContent, |   var svgContent | ||||||
|     allElements |   var allElements | ||||||
|  |  | ||||||
|   console.log('ready to execute png: ' + filename + '.png ') |   console.log('ready to execute png: ' + filename + '.png ') | ||||||
|  |  | ||||||
| @@ -112,7 +112,7 @@ files.forEach(function (file) { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   if (options.svg) { |   if (options.svg) { | ||||||
|     var serialize = new XMLSerializer() |     var serialize = new window.XMLSerializer() | ||||||
|     fs.write(outputPath + '.svg' |     fs.write(outputPath + '.svg' | ||||||
|       , serialize.serializeToString(oDOM) + '\n' |       , serialize.serializeToString(oDOM) + '\n' | ||||||
|       , 'w' |       , 'w' | ||||||
| @@ -121,15 +121,15 @@ files.forEach(function (file) { | |||||||
|   } |   } | ||||||
| }) | }) | ||||||
|  |  | ||||||
| phantom.exit() | window.phantom.exit() | ||||||
|  |  | ||||||
| function logger (_verbose) { | function logger (_verbose) { | ||||||
|   var verbose = _verbose |   var verbose = _verbose | ||||||
|  |  | ||||||
|   return function (_message, _level) { |   return function (_message, _level) { | ||||||
|     var level = level, |     var level = _level | ||||||
|       message = _message, |     var message = _message | ||||||
|       log |     var log | ||||||
|  |  | ||||||
|     log = level === 'error' ? system.stderr : system.stdout |     log = level === 'error' ? system.stderr : system.stdout | ||||||
|  |  | ||||||
| @@ -149,7 +149,7 @@ function traverse (obj) { | |||||||
|     if (node && node.hasChildNodes()) { |     if (node && node.hasChildNodes()) { | ||||||
|       var child = node.firstChild |       var child = node.firstChild | ||||||
|       while (child) { |       while (child) { | ||||||
|         if (child.nodeType === 1 && child.nodeName != 'SCRIPT') { |         if (child.nodeType === 1 && child.nodeName !== 'SCRIPT') { | ||||||
|           tree.push(child) |           tree.push(child) | ||||||
|           visit(child) |           visit(child) | ||||||
|         } |         } | ||||||
| @@ -166,10 +166,10 @@ function resolveSVGElement (element) { | |||||||
|     xmlns: 'http://www.w3.org/2000/xmlns/', |     xmlns: 'http://www.w3.org/2000/xmlns/', | ||||||
|     xlink: 'http://www.w3.org/1999/xlink', |     xlink: 'http://www.w3.org/1999/xlink', | ||||||
|     svg: 'http://www.w3.org/2000/svg' |     svg: 'http://www.w3.org/2000/svg' | ||||||
|     }, |   } | ||||||
|     doctype = '<!DOCTYPE svg:svg PUBLIC' + |   // var doctype = '<!DOCTYPE svg:svg PUBLIC' + | ||||||
|         ' "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"' + |   //   ' "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"' + | ||||||
|         ' "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">' |   //   ' "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">' | ||||||
|  |  | ||||||
|   element.setAttribute('version', '1.1') |   element.setAttribute('version', '1.1') | ||||||
|   // removing attributes so they aren't doubled up |   // removing attributes so they aren't doubled up | ||||||
| @@ -187,48 +187,48 @@ function resolveSVGElement (element) { | |||||||
| function setSVGStyle (svg, css) { | function setSVGStyle (svg, css) { | ||||||
|   if (!css || !svg) { return } |   if (!css || !svg) { return } | ||||||
|   var styles = svg.getElementsByTagName('style') |   var styles = svg.getElementsByTagName('style') | ||||||
|   if (!styles || styles.length == 0) { return } |   if (!styles || styles.length === 0) { return } | ||||||
|   styles[0].textContent = css |   styles[0].textContent = css | ||||||
| } | } | ||||||
|  |  | ||||||
| function resolveForeignObjects (element) { | function resolveForeignObjects (element) { | ||||||
|   return |   // return | ||||||
|   var children, |   // var children | ||||||
|     textElement, |   // var textElement | ||||||
|     textSpan |   // var textSpan | ||||||
|  |  | ||||||
|   if (element.tagName === 'foreignObject') { |   // if (element.tagName === 'foreignObject') { | ||||||
|     textElement = document.createElement('text') |   //   textElement = document.createElement('text') | ||||||
|     textSpan = document.createElement('tspan') |   //   textSpan = document.createElement('tspan') | ||||||
|     textSpan.setAttribute( |   //   textSpan.setAttribute( | ||||||
|         'style' |   //     'style' | ||||||
|       , 'font-size: 11.5pt; font-family: "sans-serif";' |   //     , 'font-size: 11.5pt; font-family: "sans-serif";' | ||||||
|     ) |   //   ) | ||||||
|     textSpan.setAttribute('x', 0) |   //   textSpan.setAttribute('x', 0) | ||||||
|     textSpan.setAttribute('y', 14.5) |   //   textSpan.setAttribute('y', 14.5) | ||||||
|     textSpan.textContent = element.textContent |   //   textSpan.textContent = element.textContent | ||||||
|  |  | ||||||
|     textElement.appendChild(textSpan) |   //   textElement.appendChild(textSpan) | ||||||
|     element.parentElement.appendChild(textElement) |   //   element.parentElement.appendChild(textElement) | ||||||
|     element.parentElement.removeChild(element) |   //   element.parentElement.removeChild(element) | ||||||
|   } |   // } | ||||||
| } | } | ||||||
|  |  | ||||||
| // The sandboxed function that's executed in-page by phantom | // The sandboxed function that's executed in-page by phantom | ||||||
| function executeInPage (data) { | function executeInPage (data) { | ||||||
|   var xmlSerializer = new XMLSerializer(), |   var xmlSerializer = new window.XMLSerializer() | ||||||
|     contents = data.contents, |   var contents = data.contents | ||||||
|     sequenceConfig = JSON.stringify(data.sequenceConfig), |   var sequenceConfig = JSON.stringify(data.sequenceConfig) | ||||||
|     ganttConfig = JSON.stringify(data.ganttConfig).replace(/"(function.*})"/, '$1'), |   var ganttConfig = JSON.stringify(data.ganttConfig).replace(/"(function.*})"/, '$1') | ||||||
|     toRemove, |   // var toRemove | ||||||
|     el, |   // var el | ||||||
|     elContent, |   // var elContent | ||||||
|     svg, |   var svg | ||||||
|     svgValue, |   var svgValue | ||||||
|     boundingBox, |   var boundingBox | ||||||
|     width, |   var width | ||||||
|     height, |   var height | ||||||
|     confWidth = data.confWidth |   var confWidth = data.confWidth | ||||||
|  |  | ||||||
|   var toRemove = document.getElementsByClassName('mermaid') |   var toRemove = document.getElementsByClassName('mermaid') | ||||||
|   if (toRemove && toRemove.length) { |   if (toRemove && toRemove.length) { | ||||||
| @@ -244,17 +244,17 @@ function executeInPage (data) { | |||||||
|  |  | ||||||
|   var config = { |   var config = { | ||||||
|     sequenceDiagram: JSON.parse(sequenceConfig), |     sequenceDiagram: JSON.parse(sequenceConfig), | ||||||
|     flowchart: {useMaxWidth: false}, |     flowchart: { useMaxWidth: false }, | ||||||
|     logLevel: 1 |     logLevel: 1 | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   mermaid.initialize(config) |   window.mermaid.initialize(config) | ||||||
|  |  | ||||||
|   var sc = document.createElement('script') |   var sc = document.createElement('script') | ||||||
|   sc.appendChild(document.createTextNode('mermaid.ganttConfig = ' + ganttConfig + ';')) |   sc.appendChild(document.createTextNode('mermaid.ganttConfig = ' + ganttConfig + ';')) | ||||||
|   document.body.appendChild(sc) |   document.body.appendChild(sc) | ||||||
|  |  | ||||||
|   mermaid.init() |   window.mermaid.init() | ||||||
|  |  | ||||||
|   svg = document.querySelector('svg') |   svg = document.querySelector('svg') | ||||||
|  |  | ||||||
|   | |||||||
| @@ -4,12 +4,12 @@ var log = Logger.Log | |||||||
| var relations = [] | var relations = [] | ||||||
|  |  | ||||||
| var classes | var classes | ||||||
| var idCache | // var idCache | ||||||
| classes = { | classes = { | ||||||
| } | } | ||||||
|  |  | ||||||
| // Functions to be run after graph rendering | // Functions to be run after graph rendering | ||||||
| var funs = [] | // var funs = [] | ||||||
| /** | /** | ||||||
|  * Function called by parser when a node definition has been found. |  * Function called by parser when a node definition has been found. | ||||||
|  * @param id |  * @param id | ||||||
|   | |||||||
| @@ -367,9 +367,9 @@ module.exports.draw = function (text, id) { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   var relations = cDDb.getRelations() |   var relations = cDDb.getRelations() | ||||||
|   var i = 0 |   // var i = 0 | ||||||
|   relations.forEach(function (relation) { |   relations.forEach(function (relation) { | ||||||
|     i = i + 1 |     // i = i + 1 | ||||||
|     log.info('tjoho' + getGraphId(relation.id1) + getGraphId(relation.id2) + JSON.stringify(relation)) |     log.info('tjoho' + getGraphId(relation.id1) + getGraphId(relation.id2) + JSON.stringify(relation)) | ||||||
|     g.setEdge(getGraphId(relation.id1), getGraphId(relation.id2), {relation: relation}) |     g.setEdge(getGraphId(relation.id1), getGraphId(relation.id2), {relation: relation}) | ||||||
|   }) |   }) | ||||||
|   | |||||||
| @@ -17,12 +17,12 @@ | |||||||
| // var classRenderer = proxyquire('./classRenderer', { '../../d3': d3 }); | // var classRenderer = proxyquire('./classRenderer', { '../../d3': d3 }); | ||||||
| // var testDom = require('testdom')('<html><body><div id="tst"></div></body></html>'); | // var testDom = require('testdom')('<html><body><div id="tst"></div></body></html>'); | ||||||
|  |  | ||||||
| var classRenderer = require('./classRenderer') | // var classRenderer = require('./classRenderer') | ||||||
| var parser = require('./parser/classDiagram').parser | // var parser = require('./parser/classDiagram').parser | ||||||
|  |  | ||||||
| describe('class diagram, ', function () { | describe('class diagram, ', function () { | ||||||
|   describe('when rendering a classDiagram', function () { |   describe('when rendering a classDiagram', function () { | ||||||
|     var conf |     // var conf | ||||||
|     beforeEach(function () { |     beforeEach(function () { | ||||||
|             /// /parser.yy = require('./classDb'); |             /// /parser.yy = require('./classDb'); | ||||||
|             /// /parser.yy.clear(); |             /// /parser.yy.clear(); | ||||||
| @@ -101,8 +101,8 @@ describe('class diagram, ', function () { | |||||||
|       }) |       }) | ||||||
|     }) |     }) | ||||||
|     it('it should handle one actor', function () { |     it('it should handle one actor', function () { | ||||||
|       var str = 'classDiagram\n' + |       // var str = 'classDiagram\n' + | ||||||
|             'Class01 --|> Class02' |       //       'Class01 --|> Class02' | ||||||
|  |  | ||||||
|             // classRenderer.draw(str,'tst'); |             // classRenderer.draw(str,'tst'); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -74,11 +74,11 @@ exports.addVertices = function (vert, g) { | |||||||
|     var labelTypeStr = '' |     var labelTypeStr = '' | ||||||
|     if (conf.htmlLabels) { |     if (conf.htmlLabels) { | ||||||
|       labelTypeStr = 'html' |       labelTypeStr = 'html' | ||||||
|       verticeText = verticeText.replace(/fa:fa[\w\-]+/g, function (s) { |       verticeText = verticeText.replace(/fa:fa[\w-]+/g, function (s) { | ||||||
|         return '<i class="fa ' + s.substring(3) + '"></i>' |         return '<i class="fa ' + s.substring(3) + '"></i>' | ||||||
|       }) |       }) | ||||||
|     } else { |     } else { | ||||||
|       var svg_label = document.createElementNS('http://www.w3.org/2000/svg', 'text') |       var svgLabel = document.createElementNS('http://www.w3.org/2000/svg', 'text') | ||||||
|  |  | ||||||
|       var rows = verticeText.split(/<br>/) |       var rows = verticeText.split(/<br>/) | ||||||
|  |  | ||||||
| @@ -89,11 +89,11 @@ exports.addVertices = function (vert, g) { | |||||||
|         tspan.setAttribute('dy', '1em') |         tspan.setAttribute('dy', '1em') | ||||||
|         tspan.setAttribute('x', '1') |         tspan.setAttribute('x', '1') | ||||||
|         tspan.textContent = rows[j] |         tspan.textContent = rows[j] | ||||||
|         svg_label.appendChild(tspan) |         svgLabel.appendChild(tspan) | ||||||
|       } |       } | ||||||
|  |  | ||||||
|       labelTypeStr = 'svg' |       labelTypeStr = 'svg' | ||||||
|       verticeText = svg_label |       verticeText = svgLabel | ||||||
|  |  | ||||||
|       // verticeText = verticeText.replace(/<br\/>/g, '\n'); |       // verticeText = verticeText.replace(/<br\/>/g, '\n'); | ||||||
|       // labelTypeStr = 'text'; |       // labelTypeStr = 'text'; | ||||||
| @@ -135,7 +135,7 @@ exports.addVertices = function (vert, g) { | |||||||
|         _shape = 'rect' |         _shape = 'rect' | ||||||
|     } |     } | ||||||
|     // Add the node |     // Add the node | ||||||
|     g.setNode(vertice.id, {labelType: labelTypeStr, shape: _shape, label: verticeText, rx: radious, ry: radious, 'class': classStr, style: style, id: vertice.id}) |     g.setNode(vertice.id, { labelType: labelTypeStr, shape: _shape, label: verticeText, rx: radious, ry: radious, 'class': classStr, style: style, id: vertice.id }) | ||||||
|   }) |   }) | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -241,7 +241,7 @@ exports.getClasses = function (text, isDot) { | |||||||
|  |  | ||||||
|   // Add default class if undefined |   // Add default class if undefined | ||||||
|   if (typeof (classes.default) === 'undefined') { |   if (typeof (classes.default) === 'undefined') { | ||||||
|     classes.default = {id: 'default'} |     classes.default = { id: 'default' } | ||||||
|     // classes.default.styles = ['fill:#ffa','stroke:#666','stroke-width:3px']; |     // classes.default.styles = ['fill:#ffa','stroke:#666','stroke-width:3px']; | ||||||
|     classes.default.styles = [] |     classes.default.styles = [] | ||||||
|     classes.default.clusterStyles = ['rx:4px', 'fill: rgb(255, 255, 222)', 'rx: 4px', 'stroke: rgb(170, 170, 51)', 'stroke-width: 1px'] |     classes.default.clusterStyles = ['rx:4px', 'fill: rgb(255, 255, 222)', 'rx: 4px', 'stroke: rgb(170, 170, 51)', 'stroke-width: 1px'] | ||||||
| @@ -326,18 +326,19 @@ exports.draw = function (text, id, isDot) { | |||||||
|   exports.addEdges(edges, g) |   exports.addEdges(edges, g) | ||||||
|  |  | ||||||
|   // Create the renderer |   // Create the renderer | ||||||
|   var render = new dagreD3.render() |   var Render = dagreD3.render | ||||||
|  |   var render = new Render() | ||||||
|  |  | ||||||
|   // Add custom shape for rhombus type of boc (decision) |   // Add custom shape for rhombus type of boc (decision) | ||||||
|   render.shapes().question = function (parent, bbox, node) { |   render.shapes().question = function (parent, bbox, node) { | ||||||
|     var w = bbox.width, |     var w = bbox.width | ||||||
|       h = bbox.height, |     var h = bbox.height | ||||||
|       s = (w + h) * 0.8, |     var s = (w + h) * 0.8 | ||||||
|       points = [ |     var points = [ | ||||||
|                 {x: s / 2, y: 0}, |       { x: s / 2, y: 0 }, | ||||||
|                 {x: s, y: -s / 2}, |       { x: s, y: -s / 2 }, | ||||||
|                 {x: s / 2, y: -s}, |       { x: s / 2, y: -s }, | ||||||
|                 {x: 0, y: -s / 2} |       { x: 0, y: -s / 2 } | ||||||
|     ] |     ] | ||||||
|     var shapeSvg = parent.insert('polygon', ':first-child') |     var shapeSvg = parent.insert('polygon', ':first-child') | ||||||
|       .attr('points', points.map(function (d) { |       .attr('points', points.map(function (d) { | ||||||
| @@ -354,14 +355,14 @@ exports.draw = function (text, id, isDot) { | |||||||
|  |  | ||||||
|   // Add custom shape for box with inverted arrow on left side |   // Add custom shape for box with inverted arrow on left side | ||||||
|   render.shapes().rect_left_inv_arrow = function (parent, bbox, node) { |   render.shapes().rect_left_inv_arrow = function (parent, bbox, node) { | ||||||
|     var w = bbox.width, |     var w = bbox.width | ||||||
|       h = bbox.height, |     var h = bbox.height | ||||||
|       points = [ |     var points = [ | ||||||
|                 {x: -h / 2, y: 0}, |       { x: -h / 2, y: 0 }, | ||||||
|                 {x: w, y: 0}, |       { x: w, y: 0 }, | ||||||
|                 {x: w, y: -h}, |       { x: w, y: -h }, | ||||||
|                 {x: -h / 2, y: -h}, |       { x: -h / 2, y: -h }, | ||||||
|                 {x: 0, y: -h / 2} |       { x: 0, y: -h / 2 } | ||||||
|     ] |     ] | ||||||
|     var shapeSvg = parent.insert('polygon', ':first-child') |     var shapeSvg = parent.insert('polygon', ':first-child') | ||||||
|       .attr('points', points.map(function (d) { |       .attr('points', points.map(function (d) { | ||||||
| @@ -376,14 +377,14 @@ exports.draw = function (text, id, isDot) { | |||||||
|  |  | ||||||
|   // Add custom shape for box with inverted arrow on right side |   // Add custom shape for box with inverted arrow on right side | ||||||
|   render.shapes().rect_right_inv_arrow = function (parent, bbox, node) { |   render.shapes().rect_right_inv_arrow = function (parent, bbox, node) { | ||||||
|     var w = bbox.width, |     var w = bbox.width | ||||||
|       h = bbox.height, |     var h = bbox.height | ||||||
|       points = [ |     var points = [ | ||||||
|                 {x: 0, y: 0}, |       { x: 0, y: 0 }, | ||||||
|                 {x: w + h / 2, y: 0}, |       { x: w + h / 2, y: 0 }, | ||||||
|                 {x: w, y: -h / 2}, |       { x: w, y: -h / 2 }, | ||||||
|                 {x: w + h / 2, y: -h}, |       { x: w + h / 2, y: -h }, | ||||||
|                 {x: 0, y: -h} |       { x: 0, y: -h } | ||||||
|     ] |     ] | ||||||
|     var shapeSvg = parent.insert('polygon', ':first-child') |     var shapeSvg = parent.insert('polygon', ':first-child') | ||||||
|       .attr('points', points.map(function (d) { |       .attr('points', points.map(function (d) { | ||||||
| @@ -425,7 +426,7 @@ exports.draw = function (text, id, isDot) { | |||||||
|       .attr('markerHeight', 6) |       .attr('markerHeight', 6) | ||||||
|       .attr('orient', 'auto') |       .attr('orient', 'auto') | ||||||
|  |  | ||||||
|     var path = marker.append('path') |     marker.append('path') | ||||||
|       .attr('d', 'M 0 0 L 10 5 L 0 10 z') |       .attr('d', 'M 0 0 L 10 5 L 0 10 z') | ||||||
|       .attr('class', 'arrowheadPath') |       .attr('class', 'arrowheadPath') | ||||||
|       .style('stroke-width', 1) |       .style('stroke-width', 1) | ||||||
| @@ -446,7 +447,7 @@ exports.draw = function (text, id, isDot) { | |||||||
|       return graph.getTooltip(this.id) |       return graph.getTooltip(this.id) | ||||||
|     }) |     }) | ||||||
|  |  | ||||||
| /* |   /* | ||||||
|    var xPos = document.querySelectorAll('.clusters rect')[0].x.baseVal.value; |    var xPos = document.querySelectorAll('.clusters rect')[0].x.baseVal.value; | ||||||
|    var width = document.querySelectorAll('.clusters rect')[0].width.baseVal.value; |    var width = document.querySelectorAll('.clusters rect')[0].width.baseVal.value; | ||||||
|       var cluster = d3.selectAll('.cluster'); |       var cluster = d3.selectAll('.cluster'); | ||||||
| @@ -457,7 +458,7 @@ exports.draw = function (text, id, isDot) { | |||||||
|       te.attr('id', 'apa12'); |       te.attr('id', 'apa12'); | ||||||
|       te.style('text-anchor', 'middle'); |       te.style('text-anchor', 'middle'); | ||||||
|       te.text('Title for cluster'); |       te.text('Title for cluster'); | ||||||
| */ |   */ | ||||||
|   if (conf.useMaxWidth) { |   if (conf.useMaxWidth) { | ||||||
|     // Center the graph |     // Center the graph | ||||||
|     svg.attr('height', '100%') |     svg.attr('height', '100%') | ||||||
| @@ -512,8 +513,8 @@ exports.draw = function (text, id, isDot) { | |||||||
|   // Add label rects for non html labels |   // Add label rects for non html labels | ||||||
|   if (!conf.htmlLabels) { |   if (!conf.htmlLabels) { | ||||||
|     var labels = document.querySelectorAll('#' + id + ' .edgeLabel .label') |     var labels = document.querySelectorAll('#' + id + ' .edgeLabel .label') | ||||||
|     var i |     var k | ||||||
|     for (i = 0; i < labels.length; i++) { |     for (k = 0; k < labels.length; k++) { | ||||||
|       var label = labels[i] |       var label = labels[i] | ||||||
|  |  | ||||||
|       // Get dimensions of label |       // Get dimensions of label | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Tyler Long
					Tyler Long