Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

standardized pie definitions #4501

Merged
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
a3901f6
add `@types/d3-scale` and @types/d3-shape` to mermaid dev deps
Yokozuna59 Jun 16, 2023
4e7dbf7
add SVG type in `configureSvgSize` function
Yokozuna59 Jun 16, 2023
afea3e8
clean up demos/pie.html
Yokozuna59 Jun 16, 2023
ea3fbbd
initial converting pie files
Yokozuna59 Jun 16, 2023
bdb967e
fix renderer import in pieDiagram
Yokozuna59 Jun 16, 2023
231a963
do deep cloning on section field in pie clear
Yokozuna59 Jun 16, 2023
c17b723
convert pie.spec.js to ts, remove cy.get and useless comment, add sho…
Yokozuna59 Jun 16, 2023
bd67950
return pieRender back to original and update it partially
Yokozuna59 Jun 16, 2023
5aba2fe
remove cy.get of info diagram
Yokozuna59 Jun 16, 2023
f2338f5
remove vanilla-extract from dev dependencies
Yokozuna59 Jun 16, 2023
8794fa0
clean up pieRenderer.ts
Yokozuna59 Jun 17, 2023
23a5832
add null safety in pieRenderer
Yokozuna59 Jun 17, 2023
452e543
Merge branch 'develop' into standardized-pie-definitions
Yokozuna59 Jun 17, 2023
32d3001
Merge branch 'develop' into standardized-pie-definitions
Yokozuna59 Jun 17, 2023
6941814
update pnpm-lock.yaml
Yokozuna59 Jun 17, 2023
9145a9e
Merge branch 'mermaid-js:develop' into standardized-pie-definitions
Yokozuna59 Jun 17, 2023
95e01b4
move `PieDiagramConfig` into pieTypes
Yokozuna59 Jun 17, 2023
f6dc089
add D3Sections type with variable renaming
Yokozuna59 Jun 18, 2023
1d0aa76
document pie useWidth and update other pie config attributes
Yokozuna59 Jun 18, 2023
906d909
Merge branch develop into standardized-pie-definitions
Yokozuna59 Jun 19, 2023
34a4770
update pnpm-lock.yaml
Yokozuna59 Jun 19, 2023
a92571d
add type-fest to mermaid dev deps
Yokozuna59 Jun 19, 2023
c894c1f
add `Required` and `RequiredDeep` to pieDb, add config functions
Yokozuna59 Jun 19, 2023
35c6b67
add config unit test cases for pie chart
Yokozuna59 Jun 19, 2023
cecf759
add showData unit test case
Yokozuna59 Jun 19, 2023
3a22d4a
shorten vitest pie.spec.ts by removing one time use variables
Yokozuna59 Jun 19, 2023
9c2b95f
add config functions to DiagramDB interface
Yokozuna59 Jun 19, 2023
67d287f
use local config instead of glolal one in pieRenderer
Yokozuna59 Jun 19, 2023
ae8860e
add `undefined` to getConfig return type until handle other diagrams
Yokozuna59 Jun 19, 2023
ce9d0e2
use global useMaxWidth until making setConfig updates pie setConfig
Yokozuna59 Jun 19, 2023
09c4a26
rename PieDb interface and more types with null sefety
Yokozuna59 Jun 20, 2023
796a761
remove unnecessary types in pieRenderer
Yokozuna59 Jun 20, 2023
41c5152
Merge branch 'mermaid-js:develop' into standardized-pie-definitions
Yokozuna59 Jun 21, 2023
7605483
Merge branch 'develop' into standardized-pie-definitions
Yokozuna59 Jun 26, 2023
e333403
add type-fest to mermaid dev deps
Yokozuna59 Aug 2, 2023
74fa995
run pnpm lint:fix
Yokozuna59 Aug 2, 2023
7d69ad2
Merge remote-tracking branch upstream/develop into standardized-pie-d…
Yokozuna59 Aug 2, 2023
aecf451
update pnpm-lock.yaml
Yokozuna59 Aug 2, 2023
bdfd897
change default `useWidth` in pie to 984
Yokozuna59 Aug 3, 2023
de37efe
add `type` for `PieStyleOptions`
Yokozuna59 Aug 3, 2023
c954e0e
rename `styles.ts` into `pieStyles.ts`
Yokozuna59 Aug 3, 2023
f4671e4
Merge branch 'mermaid-js:develop' into standardized-pie-definitions
Yokozuna59 Aug 3, 2023
23b6d53
Merge branch 'standardized-pie-definitions' of https://github.com/Yok…
Yokozuna59 Aug 3, 2023
71205f5
Merge branch 'mermaid-js:develop' into standardized-pie-definitions
Yokozuna59 Aug 5, 2023
e6a18ee
Merge remote-tracking branch upstream/develop into standardized-pie-d…
Yokozuna59 Aug 6, 2023
9563b22
refactor `pieRenderer`
Yokozuna59 Aug 6, 2023
9638060
Merge remote-tracking branch 'upstream/develop' into standardized-pie…
Yokozuna59 Aug 8, 2023
5485517
remove SVG import logs in `setupGraphViewbox`
Yokozuna59 Aug 8, 2023
ca1cdb1
remove unused `HTML` import in pieRenderer
Yokozuna59 Aug 8, 2023
820cc48
Merge remote-tracking branch 'upstream/develop' into standardized-pie…
Yokozuna59 Aug 9, 2023
a69a97f
remove unnecessary lines in pie files
Yokozuna59 Aug 9, 2023
453c67e
remove `PieDiagramConfig` and import generated one
Yokozuna59 Aug 9, 2023
38dc17f
use `structedClone` in `pieDb`
Yokozuna59 Aug 9, 2023
545d361
rename `reset` to `resetConfig`
Yokozuna59 Aug 10, 2023
a9681d1
add `resetConfig` to `clear` in pieDb
Yokozuna59 Aug 10, 2023
fb49f25
add more types to pieRenderer
Yokozuna59 Aug 10, 2023
c411354
Merge remote-tracking branch 'upstream/develop' into standardized-pie…
Yokozuna59 Aug 10, 2023
be106be
create `structuredCleanClone` helper function
Yokozuna59 Aug 10, 2023
3f5da06
move db assignment from `beforeEach` to `beforeAll`
Yokozuna59 Aug 10, 2023
cc70d37
chore: Rename utils.spec.ts
sidharthv96 Aug 10, 2023
396bda8
feat: Add cleanAndMerge and tests
sidharthv96 Aug 10, 2023
dfeb251
remove cleanClone
sidharthv96 Aug 10, 2023
a5a3ffc
Merge pull request #2 from mermaid-js/sidv/cleanMerge
Yokozuna59 Aug 10, 2023
120bdab
Merge branch 'develop' into standardized-pie-definitions
Yokozuna59 Aug 10, 2023
1721282
Merge branch 'develop' into standardized-pie-definitions
Yokozuna59 Aug 10, 2023
8a8e062
cleanAndMerge pieConfig
Yokozuna59 Aug 11, 2023
f9d9788
Merge branch 'develop' into standardized-pie-definitions
Yokozuna59 Aug 11, 2023
f01ad64
Merge remote-tracking branch 'upstream/develop' into standardized-pie…
Yokozuna59 Aug 11, 2023
cb5f70c
add `structuredClone` in pie `getConfig`
Yokozuna59 Aug 12, 2023
3f3a734
remove `setConfig` and `resetConfig` in pie
Yokozuna59 Aug 12, 2023
0d179c5
Merge branch 'develop' into standardized-pie-definitions
Yokozuna59 Aug 15, 2023
c1b9c54
use `DiagramStylesProvider` in `pieStyles.ts`
Yokozuna59 Aug 15, 2023
744cc79
Merge branch 'develop' into standardized-pie-definitions
Yokozuna59 Aug 15, 2023
defe406
change `defaultConfig` type to `RequiredDeep` and use it in `pieDb`
Yokozuna59 Aug 16, 2023
6214208
Update docs
Yokozuna59 Aug 16, 2023
77d8e15
remove `chart` from `pie.spec.ts` description
Yokozuna59 Aug 16, 2023
02daf54
Merge branch 'standardized-pie-definitions' of https://github.com/Yok…
Yokozuna59 Aug 16, 2023
e7ee3eb
Merge branch 'develop' into standardized-pie-definitions
Yokozuna59 Aug 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions __mocks__/pieRenderer.js

This file was deleted.

8 changes: 8 additions & 0 deletions __mocks__/pieRenderer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Mocked pie (picChart) diagram renderer
*/
import { vi } from 'vitest';

const draw = vi.fn().mockImplementation(() => '');

export const renderer = { draw };
Original file line number Diff line number Diff line change
@@ -1,89 +1,85 @@
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';

describe('Pie Chart', () => {
describe('pie chart', () => {
Yokozuna59 marked this conversation as resolved.
Show resolved Hide resolved
it('should render a simple pie diagram', () => {
imgSnapshotTest(
`pie title Sports in Sweden
"Bandy": 40
"Ice-Hockey": 80
"Football": 90
`
pie title Sports in Sweden
"Bandy" : 40
"Ice-Hockey" : 80
"Football" : 90
`,
{}
);
cy.get('svg');
});

it('should render a simple pie diagram with long labels', () => {
imgSnapshotTest(
`pie title NETFLIX
"Time spent looking for movie": 90
"Time spent watching it": 10
`
pie title NETFLIX
"Time spent looking for movie" : 90
"Time spent watching it" : 10
`,
{}
);
cy.get('svg');
});

it('should render a simple pie diagram with capital letters for labels', () => {
imgSnapshotTest(
`pie title What Voldemort doesn't have?
"FRIENDS": 2
"FAMILY": 3
"NOSE": 45
`
pie title What Voldemort doesn't have?
"FRIENDS" : 2
"FAMILY" : 3
"NOSE" : 45
`,
{}
Yokozuna59 marked this conversation as resolved.
Show resolved Hide resolved
);
cy.get('svg');
});

it('should render a pie diagram when useMaxWidth is true (default)', () => {
renderGraph(
`
pie title Sports in Sweden
"Bandy" : 40
"Ice-Hockey" : 80
"Football" : 90
`pie title Sports in Sweden
"Bandy": 40
"Ice-Hockey": 80
"Football": 90
`,
{ pie: { useMaxWidth: true } }
);
cy.get('svg').should((svg) => {
expect(svg).to.have.attr('width', '100%');
// expect(svg).to.have.attr('height');
// const height = parseFloat(svg.attr('height'));
// expect(height).to.eq(450);
const style = svg.attr('style');
expect(style).to.match(/^max-width: [\d.]+px;$/);
const maxWidthValue = parseFloat(style.match(/[\d.]+/g).join(''));
expect(maxWidthValue).to.eq(984);
});
});

it('should render a pie diagram when useMaxWidth is false', () => {
renderGraph(
`
pie title Sports in Sweden
"Bandy" : 40
"Ice-Hockey" : 80
"Football" : 90
`pie title Sports in Sweden
"Bandy": 40
"Ice-Hockey": 80
"Football": 90
`,
{ pie: { useMaxWidth: false } }
);
cy.get('svg').should((svg) => {
// const height = parseFloat(svg.attr('height'));
const width = parseFloat(svg.attr('width'));
// expect(height).to.eq(450);
expect(width).to.eq(984);
expect(svg).to.not.have.attr('style');
});
});
it('should render a pie diagram when textPosition is set', () => {

it('should render a pie diagram when textPosition is setted', () => {
imgSnapshotTest(
`
pie
"Dogs": 50
"Cats": 25
`,
`pie
"Dogs": 50
"Cats": 25
`,
{ logLevel: 1, pie: { textPosition: 0.9 } }
);
cy.get('svg');
});

it('should render a pie diagram with showData', () => {
imgSnapshotTest(
`pie showData
"Dogs": 50
"Cats": 25
`
);
});
});
32 changes: 13 additions & 19 deletions demos/pie.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=" />
<style>
div.mermaid {
/* font-family: 'trebuchet ms', verdana, arial; */
font-family: 'Courier New', Courier, monospace !important;
}
</style>
Expand All @@ -17,37 +16,32 @@
<h1>Pie chart demos</h1>
<pre class="mermaid">
pie title Pets adopted by volunteers
accTitle: simple pie char demo
accDescr: pie chart with 3 sections: dogs, cats, rats. Most are dogs.
"Dogs" : 386
"Cats" : 85
"Rats" : 15
accTitle: simple pie char demo
accDescr: pie chart with 3 sections: dogs, cats, rats. Most are dogs.
"Dogs": 386
"Cats": 85
"Rats": 15
</pre>

<hr />
<pre class="mermaid">
%%{init: {"pie": {"textPosition": 0.9}, "themeVariables": {"pieOuterStrokeWidth": "5px"}} }%%
pie
title Key elements in Product X
%%{init: {"pie": {"textPosition": 0.9}, "themeVariables": {"pieOuterStrokeWidth": "5px"}}}%%
pie
title Key elements in Product X
accTitle: Key elements in Product X
accDescr: This is a pie chart showing the key elements in Product X.
"Calcium" : 42.96
"Potassium" : 50.05
"Magnesium" : 10.01
"Iron" : 5
accDescr: This is a pie chart showing the key elements in Product X.
"Calcium": 42.96
"Potassium": 50.05
"Magnesium": 10.01
"Iron": 5
</pre>

<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
theme: 'forest',
// themeCSS: '.node rect { fill: red; }',
logLevel: 3,
securityLevel: 'loose',
// flowchart: { curve: 'basis' },
// gantt: { axisFormat: '%m/%d/%Y' },
sequence: { actorMargin: 50 },
// sequenceDiagram: { actorMargin: 300 } // deprecated
});
</script>
</body>
Expand Down
2 changes: 2 additions & 0 deletions packages/mermaid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@
"devDependencies": {
"@types/cytoscape": "^3.19.9",
"@types/d3": "^7.4.0",
"@types/d3-scale": "^4.0.3",
"@types/d3-selection": "^3.0.5",
"@types/d3-shape": "^3.1.1",
"@types/dompurify": "^3.0.2",
"@types/jsdom": "^21.1.1",
"@types/lodash-es": "^4.17.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagram-api/diagram-orchestration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import er from '../diagrams/er/erDetector.js';
import git from '../diagrams/git/gitGraphDetector.js';
import gantt from '../diagrams/gantt/ganttDetector.js';
import { info } from '../diagrams/info/infoDetector.js';
import pie from '../diagrams/pie/pieDetector.js';
import { pie } from '../diagrams/pie/pieDetector.js';
import quadrantChart from '../diagrams/quadrant-chart/quadrantDetector.js';
import requirement from '../diagrams/requirement/requirementDetector.js';
import sequence from '../diagrams/sequence/sequenceDetector.js';
Expand Down
10 changes: 0 additions & 10 deletions packages/mermaid/src/diagrams/pie/amonts.csv

This file was deleted.

132 changes: 0 additions & 132 deletions packages/mermaid/src/diagrams/pie/parser/pie.spec.js

This file was deleted.

Loading