mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-08 10:06:40 +02:00
Renamed sankey to sankey-beta
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
||||||
|
|
||||||
describe('Sankey Diagram', () => {
|
describe('Sankey Diagram', () => {
|
||||||
it('should render a simple sankey diagram', () => {
|
it('should render a simple example', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
sankey
|
sankey-beta
|
||||||
|
|
||||||
a,b,10
|
a,b,10
|
||||||
`,
|
`,
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
<h1>Sankey diagram demos</h1>
|
<h1>Sankey diagram demos</h1>
|
||||||
<h2>Energy flow</h2>
|
<h2>Energy flow</h2>
|
||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
sankey
|
sankey-beta
|
||||||
|
|
||||||
Agricultural 'waste',Bio-conversion,124.729
|
Agricultural 'waste',Bio-conversion,124.729
|
||||||
Bio-conversion,Liquid,0.597
|
Bio-conversion,Liquid,0.597
|
||||||
|
@@ -24,7 +24,7 @@ NUM \d+(.\d+)?
|
|||||||
//--------------
|
//--------------
|
||||||
|
|
||||||
(<<EOF>>|[\n;])+ { return 'EOS'; } // end of statement is semicolon ; new line \n or end of file
|
(<<EOF>>|[\n;])+ { return 'EOS'; } // end of statement is semicolon ; new line \n or end of file
|
||||||
"sankey" { return 'SANKEY'; }
|
"sankey-beta" { return 'SANKEY'; }
|
||||||
<INITIAL>{TOKEN} { return 'NODE_ID'; }
|
<INITIAL>{TOKEN} { return 'NODE_ID'; }
|
||||||
<link_value>{NUM} { return 'AMOUNT'; }
|
<link_value>{NUM} { return 'AMOUNT'; }
|
||||||
"->" {
|
"->" {
|
||||||
|
@@ -3,7 +3,7 @@ import { parser } from './sankey-arrow.jison';
|
|||||||
import db from '../sankeyDB.js';
|
import db from '../sankeyDB.js';
|
||||||
// import { fail } from 'assert';
|
// import { fail } from 'assert';
|
||||||
|
|
||||||
describe('Sankey diagram', function () {
|
describe('sankey-beta diagram', function () {
|
||||||
// TODO - these examples should be put into ./parser/stateDiagram.spec.js
|
// TODO - these examples should be put into ./parser/stateDiagram.spec.js
|
||||||
describe('when parsing an info graph it', function () {
|
describe('when parsing an info graph it', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
@@ -13,14 +13,14 @@ describe('Sankey diagram', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('recognizes its type', () => {
|
it('recognizes its type', () => {
|
||||||
const str = `sankey`;
|
const str = `sankey-beta`;
|
||||||
|
|
||||||
parser.parse(str);
|
parser.parse(str);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('recognizes one flow', () => {
|
it('recognizes one flow', () => {
|
||||||
const str = `
|
const str = `
|
||||||
sankey
|
sankey-beta
|
||||||
node_a -> 30 -> node_b -> 20 -> node_c
|
node_a -> 30 -> node_b -> 20 -> node_c
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ describe('Sankey diagram', function () {
|
|||||||
|
|
||||||
it('recognizes multiple flows', () => {
|
it('recognizes multiple flows', () => {
|
||||||
const str = `
|
const str = `
|
||||||
sankey
|
sankey-beta
|
||||||
node_a -> 30 -> node_b -> 12 -> node_e
|
node_a -> 30 -> node_b -> 12 -> node_e
|
||||||
node_c -> 30 -> node_d -> 12 -> node_e
|
node_c -> 30 -> node_d -> 12 -> node_e
|
||||||
node_c -> 40 -> node_e -> 12 -> node_q
|
node_c -> 40 -> node_e -> 12 -> node_q
|
||||||
@@ -40,7 +40,7 @@ describe('Sankey diagram', function () {
|
|||||||
|
|
||||||
it('parses node as a string', () => {
|
it('parses node as a string', () => {
|
||||||
const str = `
|
const str = `
|
||||||
sankey
|
sankey-beta
|
||||||
"node a" -> 30 -> "node b" -> 12 -> "node e"
|
"node a" -> 30 -> "node b" -> 12 -> "node e"
|
||||||
"node c" -> 30 -> "node d" -> 12 -> "node e"
|
"node c" -> 30 -> "node d" -> 12 -> "node e"
|
||||||
"node c" -> 40 -> "node e" -> 12 -> "node q"
|
"node c" -> 40 -> "node e" -> 12 -> "node q"
|
||||||
@@ -52,7 +52,7 @@ describe('Sankey diagram', function () {
|
|||||||
describe('while attributes parsing', () => {
|
describe('while attributes parsing', () => {
|
||||||
it('recognized node and attribute ids starting with numbers', () => {
|
it('recognized node and attribute ids starting with numbers', () => {
|
||||||
const str = `
|
const str = `
|
||||||
sankey
|
sankey-beta
|
||||||
1st -> 200 -> 2nd -> 180 -> 3rd;
|
1st -> 200 -> 2nd -> 180 -> 3rd;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ describe('Sankey diagram', function () {
|
|||||||
|
|
||||||
it('parses different quotless variations', () => {
|
it('parses different quotless variations', () => {
|
||||||
const str = `
|
const str = `
|
||||||
sankey
|
sankey-beta
|
||||||
node[]
|
node[]
|
||||||
|
|
||||||
node[attr=1]
|
node[attr=1]
|
||||||
@@ -77,9 +77,9 @@ describe('Sankey diagram', function () {
|
|||||||
|
|
||||||
it('parses strings as values', () => {
|
it('parses strings as values', () => {
|
||||||
const str = `
|
const str = `
|
||||||
sankey
|
sankey-beta
|
||||||
node[title="hello, how are you?"]
|
node[title="hello, how are you?"]
|
||||||
node[title="hello, mister \\"sankey\\", backslash for you \\\\"]
|
node[title="hello, mister \\"sankey-beta\\", backslash for you \\\\"]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
parser.parse(str);
|
parser.parse(str);
|
||||||
@@ -87,7 +87,7 @@ describe('Sankey diagram', function () {
|
|||||||
|
|
||||||
it('parses real example', () => {
|
it('parses real example', () => {
|
||||||
const str = `
|
const str = `
|
||||||
sankey
|
sankey-beta
|
||||||
|
|
||||||
"Agricultural 'waste'" -> 124.729 -> "Bio-conversion"
|
"Agricultural 'waste'" -> 124.729 -> "Bio-conversion"
|
||||||
"Bio-conversion" -> 0.597 -> "Liquid"
|
"Bio-conversion" -> 0.597 -> "Liquid"
|
||||||
|
@@ -27,7 +27,7 @@ TEXTDATA [\u0020-\u0021\u0023-\u002B\u002D-\u007E]
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
<INITIAL>"sankey" { this.pushState('csv'); return 'SANKEY'; }
|
<INITIAL>"sankey-beta" { this.pushState('csv'); return 'SANKEY'; }
|
||||||
<INITIAL,csv><<EOF>> { return 'EOF' } // match end of file
|
<INITIAL,csv><<EOF>> { return 'EOF' } // match end of file
|
||||||
<INITIAL,csv>({CRLF}|{LF}) { return 'NEWLINE' }
|
<INITIAL,csv>({CRLF}|{LF}) { return 'NEWLINE' }
|
||||||
<INITIAL,csv>{COMMA} { return 'COMMA' }
|
<INITIAL,csv>{COMMA} { return 'COMMA' }
|
||||||
|
@@ -19,7 +19,7 @@ describe('Sankey diagram', function () {
|
|||||||
const path = await import('path');
|
const path = await import('path');
|
||||||
const csv = path.resolve(__dirname, './energy.csv');
|
const csv = path.resolve(__dirname, './energy.csv');
|
||||||
const data = fs.readFileSync(csv, 'utf8');
|
const data = fs.readFileSync(csv, 'utf8');
|
||||||
const graphDefinition = prepareTextForParsing(cleanupComments('sankey\n\n ' + data));
|
const graphDefinition = prepareTextForParsing(cleanupComments('sankey-beta\n\n ' + data));
|
||||||
|
|
||||||
parser.parse(graphDefinition);
|
parser.parse(graphDefinition);
|
||||||
});
|
});
|
||||||
|
@@ -3,7 +3,7 @@ import type { DiagramDetector, ExternalDiagramDefinition } from '../../diagram-a
|
|||||||
const id = 'sankey';
|
const id = 'sankey';
|
||||||
|
|
||||||
const detector: DiagramDetector = (txt) => {
|
const detector: DiagramDetector = (txt) => {
|
||||||
return txt.match(/^\s*sankey/) !== null;
|
return txt.match(/^\s*sankey-beta/) !== null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const loader = async () => {
|
const loader = async () => {
|
||||||
|
Reference in New Issue
Block a user