mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-15 05:19:58 +02:00
add more types to pieRenderer
This commit is contained in:
@@ -57,10 +57,10 @@ export const draw: DrawDefinition = (text, id, _version, diagObj) => {
|
|||||||
group.attr('transform', 'translate(' + width / 2 + ',' + height / 2 + ')');
|
group.attr('transform', 'translate(' + width / 2 + ',' + height / 2 + ')');
|
||||||
|
|
||||||
const { themeVariables } = globalConfig;
|
const { themeVariables } = globalConfig;
|
||||||
const textPosition: number = pieConfig.textPosition;
|
|
||||||
let [outerStrokeWidth] = parseFontSize(themeVariables.pieOuterStrokeWidth);
|
let [outerStrokeWidth] = parseFontSize(themeVariables.pieOuterStrokeWidth);
|
||||||
outerStrokeWidth ??= 2;
|
outerStrokeWidth ??= 2;
|
||||||
|
|
||||||
|
const textPosition: number = pieConfig.textPosition;
|
||||||
const radius: number = Math.min(width, height) / 2 - MARGIN;
|
const radius: number = Math.min(width, height) / 2 - MARGIN;
|
||||||
// Shape helper to build arcs:
|
// Shape helper to build arcs:
|
||||||
const arcGenerator: d3.Arc<unknown, d3.PieArcDatum<D3Sections>> = arc<
|
const arcGenerator: d3.Arc<unknown, d3.PieArcDatum<D3Sections>> = arc<
|
||||||
@@ -108,7 +108,7 @@ export const draw: DrawDefinition = (text, id, _version, diagObj) => {
|
|||||||
.enter()
|
.enter()
|
||||||
.append('path')
|
.append('path')
|
||||||
.attr('d', arcGenerator)
|
.attr('d', arcGenerator)
|
||||||
.attr('fill', (datum) => {
|
.attr('fill', (datum: d3.PieArcDatum<D3Sections>) => {
|
||||||
return color(datum.data.label);
|
return color(datum.data.label);
|
||||||
})
|
})
|
||||||
.attr('class', 'pieCircle');
|
.attr('class', 'pieCircle');
|
||||||
@@ -124,7 +124,7 @@ export const draw: DrawDefinition = (text, id, _version, diagObj) => {
|
|||||||
.data(arcs)
|
.data(arcs)
|
||||||
.enter()
|
.enter()
|
||||||
.append('text')
|
.append('text')
|
||||||
.text((datum: { data: D3Sections }): string => {
|
.text((datum: d3.PieArcDatum<D3Sections>): string => {
|
||||||
return ((datum.data.value / sum) * 100).toFixed(0) + '%';
|
return ((datum.data.value / sum) * 100).toFixed(0) + '%';
|
||||||
})
|
})
|
||||||
.attr('transform', (datum: d3.PieArcDatum<D3Sections>): string => {
|
.attr('transform', (datum: d3.PieArcDatum<D3Sections>): string => {
|
||||||
|
Reference in New Issue
Block a user