mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-19 16:26:43 +02:00
fix(pie): align slices and legend orders
This commit is contained in:
@@ -12,14 +12,16 @@ import { selectSvgElement } from '../../rendering-util/selectSvgElement.js';
|
|||||||
|
|
||||||
const createPieArcs = (sections: Sections): d3.PieArcDatum<D3Sections>[] => {
|
const createPieArcs = (sections: Sections): d3.PieArcDatum<D3Sections>[] => {
|
||||||
// Compute the position of each group on the pie:
|
// Compute the position of each group on the pie:
|
||||||
const pieData: D3Sections[] = Object.entries(sections).map(
|
const pieData: D3Sections[] = Object.entries(sections)
|
||||||
(element: [string, number]): D3Sections => {
|
.map((element: [string, number]): D3Sections => {
|
||||||
return {
|
return {
|
||||||
label: element[0],
|
label: element[0],
|
||||||
value: element[1],
|
value: element[1],
|
||||||
};
|
};
|
||||||
}
|
})
|
||||||
);
|
.sort((a: D3Sections, b: D3Sections): number => {
|
||||||
|
return b.value - a.value;
|
||||||
|
});
|
||||||
const pie: d3.Pie<unknown, D3Sections> = d3pie<D3Sections>().value(
|
const pie: d3.Pie<unknown, D3Sections> = d3pie<D3Sections>().value(
|
||||||
(d3Section: D3Sections): number => d3Section.value
|
(d3Section: D3Sections): number => d3Section.value
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user