Remove unnecessary parsing stage from render and prepare text before parsing

This commit is contained in:
Nikolay Rozhkov 2023-06-22 18:28:02 +03:00
parent 104aece46e
commit 518da3236f
2 changed files with 4 additions and 9 deletions

View File

@ -4,6 +4,10 @@ import parser from './parser/sankey.jison';
import db from './sankeyDB.js';
import styles from './styles.js';
import renderer from './sankeyRenderer.js';
import { prepareTextForParsing } from './sankeyUtils.js';
const originalParse = parser.parse.bind(parser);
parser.parse = (text: string) => originalParse(prepareTextForParsing(text));
export const diagram: DiagramDefinition = {
parser,

View File

@ -17,7 +17,6 @@ import {
sankeyJustify as d3SankeyJustify,
} from 'd3-sankey';
import { configureSvgSize } from '../../setupGraphViewbox.js';
import { prepareTextForParsing } from './sankeyUtils.js';
/**
* Draws a sequenceDiagram in the tag with id: id based on the graph definition in text.
@ -28,14 +27,6 @@ import { prepareTextForParsing } from './sankeyUtils.js';
* @param diagObj - A standard diagram containing the db and the text and type etc of the diagram
*/
export const draw = function (text: string, id: string, _version: string, diagObj: Diagram): void {
// Clear DB before parsing
//
diagObj.db.clear?.();
// Launch parsing
const preparedText = prepareTextForParsing(text);
diagObj.parser.parse(preparedText);
// TODO: Figure out what is happening there
// The main thing is svg object that is a d3 wrapper for svg operations
//