Skip to content

Commit

Permalink
Merge pull request #4774 from Yokozuna59/bug/4772_align-slices-and-le…
Browse files Browse the repository at this point in the history
…gend-orders

fix(pie): align slices and legend orders
  • Loading branch information
sidharthv96 authored Aug 25, 2023
2 parents ecf14cd + 2679357 commit 979dcb0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/mermaid/src/diagrams/pie/pieRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ import { selectSvgElement } from '../../rendering-util/selectSvgElement.js';

const createPieArcs = (sections: Sections): d3.PieArcDatum<D3Sections>[] => {
// Compute the position of each group on the pie:
const pieData: D3Sections[] = Object.entries(sections).map(
(element: [string, number]): D3Sections => {
const pieData: D3Sections[] = Object.entries(sections)
.map((element: [string, number]): D3Sections => {
return {
label: element[0],
value: element[1],
};
}
);
})
.sort((a: D3Sections, b: D3Sections): number => {
return b.value - a.value;
});
const pie: d3.Pie<unknown, D3Sections> = d3pie<D3Sections>().value(
(d3Section: D3Sections): number => d3Section.value
);
Expand Down

0 comments on commit 979dcb0

Please sign in to comment.