mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 06:19:24 +02:00
fixup! feat(pie): adding outer border, text position options
This commit is contained in:
@@ -91,4 +91,16 @@ describe('Pie Chart', () => {
|
|||||||
expect(strokeWidth).to.eq(5);
|
expect(strokeWidth).to.eq(5);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should render a pie diagram when text-position is set', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
pie
|
||||||
|
"Dogs": 50
|
||||||
|
"Cats": 25
|
||||||
|
`,
|
||||||
|
{ logLevel: 1, pie: { textPosition: 0.9 } }
|
||||||
|
);
|
||||||
|
cy.get('svg');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
|
%%{init: {"pie": {"textPosition": 0.8, "outerBorderWidth": 5}} }%%
|
||||||
pie
|
pie
|
||||||
title Key elements in Product X
|
title Key elements in Product X
|
||||||
accTitle: Key elements in Product X
|
accTitle: Key elements in Product X
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[defaultConfig.ts:2084](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/defaultConfig.ts#L2084)
|
[defaultConfig.ts:2102](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/defaultConfig.ts#L2102)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@@ -48,6 +48,7 @@ Drawing a pie chart is really simple in mermaid.
|
|||||||
## Example
|
## Example
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
|
%%{init: {"pie": {"textPosition": 0.8, "outerBorderWidth": 5}} }%%
|
||||||
pie showData
|
pie showData
|
||||||
title Key elements in Product X
|
title Key elements in Product X
|
||||||
"Calcium" : 42.96
|
"Calcium" : 42.96
|
||||||
@@ -57,6 +58,7 @@ pie showData
|
|||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
|
%%{init: {"pie": {"textPosition": 0.8, "outerBorderWidth": 5}} }%%
|
||||||
pie showData
|
pie showData
|
||||||
title Key elements in Product X
|
title Key elements in Product X
|
||||||
"Calcium" : 42.96
|
"Calcium" : 42.96
|
||||||
@@ -64,3 +66,12 @@ pie showData
|
|||||||
"Magnesium" : 10.01
|
"Magnesium" : 10.01
|
||||||
"Iron" : 5
|
"Iron" : 5
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
Possible pie diagram configuration parameters:
|
||||||
|
|
||||||
|
| Parameter | Description | Default value |
|
||||||
|
| ------------------ | ------------------------------------------------------------------------------------------------------------ | ------------- |
|
||||||
|
| `outerBorderWidth` | The border width of the pie diagram's outside circle | `2` |
|
||||||
|
| `textPosition` | The axial position of the pie slice labels, from 0.0 at the center to 1.0 at the outside edge of the circle. | `0.5` |
|
||||||
|
@@ -1247,6 +1247,24 @@ const config: Partial<MermaidConfig> = {
|
|||||||
* Default value: true
|
* Default value: true
|
||||||
*/
|
*/
|
||||||
useMaxWidth: true,
|
useMaxWidth: true,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* | Parameter | Description | Type | Required | Values |
|
||||||
|
* | ---------------- | ------------------------------------------ | ------- | -------- | ------------------ |
|
||||||
|
* | outerBorderWidth | Border width of the diagram's outer circle | Integer | Optional | Any Positive Value |
|
||||||
|
*
|
||||||
|
* **Notes:** Default value: 2
|
||||||
|
*/
|
||||||
|
outerBorderWidth: 2,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* | Parameter | Description | Type | Required | Values |
|
||||||
|
* | ------------ | -------------------------------------------------------------------------------- | ------- | -------- | ------------------- |
|
||||||
|
* | textPosition | Axial position of slice's label from zero at the center to 1 at the outside edge | Number | Optional | Decimal from 0 to 1 |
|
||||||
|
*
|
||||||
|
* **Notes:** Default value: 0.5
|
||||||
|
*/
|
||||||
|
textPosition: 0.5,
|
||||||
},
|
},
|
||||||
|
|
||||||
/** The object containing configurations specific for req diagrams */
|
/** The object containing configurations specific for req diagrams */
|
||||||
|
@@ -35,6 +35,7 @@ Drawing a pie chart is really simple in mermaid.
|
|||||||
## Example
|
## Example
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
|
%%{init: {"pie": {"textPosition": 0.8, "outerBorderWidth": 5}} }%%
|
||||||
pie showData
|
pie showData
|
||||||
title Key elements in Product X
|
title Key elements in Product X
|
||||||
"Calcium" : 42.96
|
"Calcium" : 42.96
|
||||||
@@ -42,3 +43,12 @@ pie showData
|
|||||||
"Magnesium" : 10.01
|
"Magnesium" : 10.01
|
||||||
"Iron" : 5
|
"Iron" : 5
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
Possible pie diagram configuration parameters:
|
||||||
|
|
||||||
|
| Parameter | Description | Default value |
|
||||||
|
| ------------------ | ------------------------------------------------------------------------------------------------------------ | ------------- |
|
||||||
|
| `outerBorderWidth` | The border width of the pie diagram's outside circle | `2` |
|
||||||
|
| `textPosition` | The axial position of the pie slice labels, from 0.0 at the center to 1.0 at the outside edge of the circle. | `0.5` |
|
||||||
|
Reference in New Issue
Block a user