Stated sankey backbone
This commit is contained in:
parent
116453d2a7
commit
c2417de5f1
|
@ -18,6 +18,7 @@ import errorDiagram from '../diagrams/error/errorDiagram.js';
|
|||
import flowchartElk from '../diagrams/flowchart/elk/detector.js';
|
||||
import timeline from '../diagrams/timeline/detector.js';
|
||||
import mindmap from '../diagrams/mindmap/detector.js';
|
||||
import sankey from '../diagrams/sankey/detector.js';
|
||||
import { registerLazyLoadedDiagrams } from './detectType.js';
|
||||
import { registerDiagram } from './diagramAPI.js';
|
||||
|
||||
|
@ -79,6 +80,7 @@ export const addDiagrams = () => {
|
|||
stateV2,
|
||||
state,
|
||||
journey,
|
||||
quadrantChart
|
||||
quadrantChart,
|
||||
sankey,
|
||||
);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
import { log } from '../../logger.js';
|
||||
import mermaidAPI from '../../mermaidAPI.js';
|
||||
import * as configApi from '../../config.js';
|
||||
import common from '../common/common.js';
|
||||
import {
|
||||
setAccTitle,
|
||||
getAccTitle,
|
||||
setDiagramTitle,
|
||||
getDiagramTitle,
|
||||
getAccDescription,
|
||||
setAccDescription,
|
||||
clear as commonClear,
|
||||
} from '../../commonDb.js';
|
||||
|
||||
let sections = {};
|
||||
let showData = false;
|
||||
|
||||
export const parseDirective = function (statement, context, type) {
|
||||
mermaidAPI.parseDirective(this, statement, context, type);
|
||||
};
|
||||
|
||||
const addSection = function (id, value) {
|
||||
id = common.sanitizeText(id, configApi.getConfig());
|
||||
if (sections[id] === undefined) {
|
||||
sections[id] = value;
|
||||
log.debug('Added new section :', id);
|
||||
}
|
||||
};
|
||||
const getSections = () => sections;
|
||||
|
||||
const setShowData = function (toggle) {
|
||||
showData = toggle;
|
||||
};
|
||||
|
||||
const getShowData = function () {
|
||||
return showData;
|
||||
};
|
||||
|
||||
const cleanupValue = function (value) {
|
||||
if (value.substring(0, 1) === ':') {
|
||||
value = value.substring(1).trim();
|
||||
return Number(value.trim());
|
||||
} else {
|
||||
return Number(value.trim());
|
||||
}
|
||||
};
|
||||
|
||||
const clear = function () {
|
||||
sections = {};
|
||||
showData = false;
|
||||
commonClear();
|
||||
};
|
||||
|
||||
export default {
|
||||
parseDirective,
|
||||
getConfig: () => configApi.getConfig().pie,
|
||||
addSection,
|
||||
getSections,
|
||||
cleanupValue,
|
||||
clear,
|
||||
setAccTitle,
|
||||
getAccTitle,
|
||||
setDiagramTitle,
|
||||
getDiagramTitle,
|
||||
setShowData,
|
||||
getShowData,
|
||||
getAccDescription,
|
||||
setAccDescription,
|
||||
};
|
|
@ -0,0 +1,20 @@
|
|||
import type { DiagramDetector, ExternalDiagramDefinition } from '../../diagram-api/types.js';
|
||||
|
||||
const id = 'sankey';
|
||||
|
||||
const detector: DiagramDetector = (txt) => {
|
||||
return txt.match(/^\s*sankey/) !== null;
|
||||
};
|
||||
|
||||
const loader = async () => {
|
||||
const { diagram } = await import('./sankeyDiagram.js');
|
||||
return { id, diagram };
|
||||
};
|
||||
|
||||
const plugin: ExternalDiagramDefinition = {
|
||||
id,
|
||||
detector,
|
||||
loader,
|
||||
};
|
||||
|
||||
export default plugin;
|
|
@ -67,7 +67,15 @@ Graph is a list of flows (or links).
|
|||
Flow is a sequence `node -> value -> node -> value...`
|
||||
```
|
||||
a -> 30 -> b
|
||||
a -> 40 -> c
|
||||
a -> 40 -> b
|
||||
```
|
||||
|
||||
2 separate streams between 2 nodes they can be grouped as well:
|
||||
```
|
||||
a -> {
|
||||
30
|
||||
40
|
||||
} -> b
|
||||
```
|
||||
|
||||
All outflows from the node can be grouped:
|
||||
|
@ -86,13 +94,15 @@ All inflows to the node can be grouped too:
|
|||
} -> c
|
||||
```
|
||||
|
||||
2 separate streams between 2 nodes they can be grouped as well:
|
||||
|
||||
Chaining example:
|
||||
```
|
||||
a -> {
|
||||
30
|
||||
40
|
||||
} -> b
|
||||
} -> b -> {
|
||||
20 -> d
|
||||
50 -> e
|
||||
}
|
||||
```
|
||||
|
||||
**Probably ambiguous!**
|
|
@ -0,0 +1,13 @@
|
|||
%lex
|
||||
%options case-insensitive
|
||||
|
||||
%%
|
||||
|
||||
/lex
|
||||
|
||||
%start graph
|
||||
|
||||
%%
|
||||
|
||||
graph
|
||||
: node ->
|
|
@ -0,0 +1,27 @@
|
|||
// import { select, scaleOrdinal, pie as d3pie, arc } from 'd3';
|
||||
|
||||
// import { select, selectAll } from 'd3';
|
||||
// import { log } from '../../logger.js';
|
||||
// import common from '../common/common.js';
|
||||
// import * as svgDrawCommon from '../common/svgDrawCommon';
|
||||
import * as configApi from '../../config.js';
|
||||
// import assignWithDepth from '../../assignWithDepth.js';
|
||||
// import utils from '../../utils.js';
|
||||
// import { configureSvgSize } from '../../setupGraphViewbox.js';
|
||||
import { Diagram } from '../../Diagram.js';
|
||||
|
||||
// import { parseFontSize } from '../../utils.js';
|
||||
|
||||
const conf = configApi.getConfig();
|
||||
|
||||
/**
|
||||
* Draws a Sankey Diagram with the data given in text.
|
||||
*
|
||||
* @param text
|
||||
* @param id
|
||||
*/
|
||||
export const draw = function (_text: string, id: string, _version: string, _diagObj: Diagram) {}
|
||||
|
||||
export default {
|
||||
draw,
|
||||
};
|
|
@ -0,0 +1,13 @@
|
|||
import { DiagramDefinition } from '../../diagram-api/types.js';
|
||||
// @ts-ignore: TODO Fix ts errors
|
||||
import parser from './parser/sankey.jison';
|
||||
import db from './db.js';
|
||||
import styles from './styles.js';
|
||||
import renderer from './renderer.js';
|
||||
|
||||
export const diagram: DiagramDefinition = {
|
||||
parser,
|
||||
db,
|
||||
renderer,
|
||||
styles,
|
||||
};
|
|
@ -0,0 +1,5 @@
|
|||
const getStyles = (options) =>
|
||||
`
|
||||
`;
|
||||
|
||||
export default getStyles;
|
Loading…
Reference in New Issue