Spaces:
Running
Running
thibaud frere
commited on
Commit
·
31b7760
1
Parent(s):
597c2dc
fix pie chart rendering
Browse files
app/src/content/embeds/d3-pie.html
CHANGED
|
@@ -93,7 +93,7 @@
|
|
| 93 |
const CAPTION_GAP = 24; // espace entre titre et donut
|
| 94 |
const GAP_X = 20; // espace entre colonnes
|
| 95 |
const GAP_Y = 12; // espace entre lignes
|
| 96 |
-
const LEGEND_HEIGHT =
|
| 97 |
const TOP_OFFSET = 4; // décalage vertical supplémentaire pour aérer le haut
|
| 98 |
const updateSize = () => {
|
| 99 |
width = container.clientWidth || 800;
|
|
@@ -102,9 +102,9 @@
|
|
| 102 |
return { innerWidth: width - margin.left - margin.right };
|
| 103 |
};
|
| 104 |
|
| 105 |
-
function renderLegend(categories, colorOf,
|
| 106 |
const legendHeight = LEGEND_HEIGHT;
|
| 107 |
-
gLegend.attr('x',
|
| 108 |
const root = gLegend.selectAll('div').data([0]).join('xhtml:div');
|
| 109 |
root
|
| 110 |
.style('height', legendHeight + 'px')
|
|
@@ -170,11 +170,9 @@
|
|
| 170 |
const arc = d3.arc().innerRadius(innerR).outerRadius(radius).cornerRadius(3);
|
| 171 |
const arcLabel = d3.arc().innerRadius((innerR + radius) / 2).outerRadius((innerR + radius) / 2);
|
| 172 |
|
| 173 |
-
// Positionner la légende sous les graphiques
|
| 174 |
const legendY = TOP_OFFSET + plotsHeight + 4;
|
| 175 |
-
|
| 176 |
-
gLegend.attr('x', 0).attr('width', innerWidth);
|
| 177 |
-
renderLegend(categories, colorOf, innerWidth, legendY);
|
| 178 |
|
| 179 |
const captions = new Map(METRICS.map(m => [m.key, `${m.title}`]));
|
| 180 |
|
|
|
|
| 93 |
const CAPTION_GAP = 24; // espace entre titre et donut
|
| 94 |
const GAP_X = 20; // espace entre colonnes
|
| 95 |
const GAP_Y = 12; // espace entre lignes
|
| 96 |
+
const LEGEND_HEIGHT = 62; // hauteur de la légende
|
| 97 |
const TOP_OFFSET = 4; // décalage vertical supplémentaire pour aérer le haut
|
| 98 |
const updateSize = () => {
|
| 99 |
width = container.clientWidth || 800;
|
|
|
|
| 102 |
return { innerWidth: width - margin.left - margin.right };
|
| 103 |
};
|
| 104 |
|
| 105 |
+
function renderLegend(categories, colorOf, width, x, legendY){
|
| 106 |
const legendHeight = LEGEND_HEIGHT;
|
| 107 |
+
gLegend.attr('x', x).attr('y', legendY).attr('width', width).attr('height', legendHeight);
|
| 108 |
const root = gLegend.selectAll('div').data([0]).join('xhtml:div');
|
| 109 |
root
|
| 110 |
.style('height', legendHeight + 'px')
|
|
|
|
| 170 |
const arc = d3.arc().innerRadius(innerR).outerRadius(radius).cornerRadius(3);
|
| 171 |
const arcLabel = d3.arc().innerRadius((innerR + radius) / 2).outerRadius((innerR + radius) / 2);
|
| 172 |
|
| 173 |
+
// Positionner la légende sous les graphiques, calée sur la grille centrée
|
| 174 |
const legendY = TOP_OFFSET + plotsHeight + 4;
|
| 175 |
+
renderLegend(categories, colorOf, gridWidth, xOffset, legendY);
|
|
|
|
|
|
|
| 176 |
|
| 177 |
const captions = new Map(METRICS.map(m => [m.key, `${m.title}`]));
|
| 178 |
|