mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 06:19:24 +02:00
resolved PR comments
This commit is contained in:
@@ -40,7 +40,7 @@ Drawing a pie chart is really simple in mermaid.
|
||||
**Note:**
|
||||
|
||||
> Pie chart values must be **positive numbers greater than zero**.\
|
||||
> **Zero and negative values are not allowed** and will result in an error.
|
||||
> **Negative values are not allowed** and will result in an error.
|
||||
|
||||
\[pie] \[showData] (OPTIONAL)
|
||||
\[title] \[titlevalue] (OPTIONAL)
|
||||
|
@@ -140,16 +140,16 @@ describe('pie', () => {
|
||||
});
|
||||
|
||||
it('should handle simple pie with zero slice value', async () => {
|
||||
await expect(async () => {
|
||||
await parser.parse(`pie title Default text position: Animal adoption
|
||||
await parser.parse(`pie title Default text position: Animal adoption
|
||||
accTitle: simple pie char demo
|
||||
accDescr: pie chart with 3 sections: dogs, cats, rats. Most are dogs.
|
||||
"dogs" : 0
|
||||
"rats" : 40.12
|
||||
`);
|
||||
}).rejects.toThrowError(
|
||||
'"dogs" has invalid value: 0. Zero and negative values are not allowed in pie charts. All slice values must be > 0'
|
||||
);
|
||||
`);
|
||||
|
||||
const sections = db.getSections();
|
||||
expect(sections.get('dogs')).toBe(0);
|
||||
expect(sections.get('rats')).toBe(40.12);
|
||||
});
|
||||
|
||||
it('should handle simple pie with negative slice value', async () => {
|
||||
@@ -161,7 +161,7 @@ describe('pie', () => {
|
||||
"rats" : 40.12
|
||||
`);
|
||||
}).rejects.toThrowError(
|
||||
'"dogs" has invalid value: -60.67. Zero and negative values are not allowed in pie charts. All slice values must be > 0'
|
||||
'"dogs" has invalid value: -60.67.Negative values are not allowed in pie charts. All slice values must be > 0'
|
||||
);
|
||||
});
|
||||
|
||||
|
@@ -34,9 +34,9 @@ const clear = (): void => {
|
||||
};
|
||||
|
||||
const addSection = ({ label, value }: D3Section): void => {
|
||||
if (value <= 0) {
|
||||
if (value < 0) {
|
||||
throw new Error(
|
||||
`"${label}" has invalid value: ${value}. Zero and negative values are not allowed in pie charts. All slice values must be > 0.`
|
||||
`"${label}" has invalid value: ${value}.Negative values are not allowed in pie charts. All slice values must be > 0.`
|
||||
);
|
||||
}
|
||||
if (!sections.has(label)) {
|
||||
|
@@ -27,7 +27,7 @@ Drawing a pie chart is really simple in mermaid.
|
||||
**Note:**
|
||||
|
||||
> Pie chart values must be **positive numbers greater than zero**.
|
||||
> **Zero and negative values are not allowed** and will result in an error.
|
||||
> **Negative values are not allowed** and will result in an error.
|
||||
|
||||
[pie] [showData] (OPTIONAL)
|
||||
[title] [titlevalue] (OPTIONAL)
|
||||
|
Reference in New Issue
Block a user