You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: site/docs/charts/funnel.en.md
+68Lines changed: 68 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -279,6 +279,74 @@ chart.render();
279
279
- Consistent color coding for corresponding stages facilitates comparison
280
280
- You can clearly observe differences in conversion efficiency across channels at various stages
281
281
282
+
Example 4: **Intuitive and Visual Chart Form, Often Used to Display Hierarchical Structures or Distribution Proportions**
283
+
284
+
Company hierarchy pyramid structure, where employees are divided into multiple levels based on their rank, with significant differences in population proportions, responsibilities, and authority across levels, intuitively reflecting the hierarchical differentiation within the company.
285
+
286
+
```js | ob { inject: true }
287
+
import { Chart } from'@antv/g2';
288
+
289
+
constchart=newChart({
290
+
container:'container',
291
+
theme:'classic',
292
+
});
293
+
294
+
chart.options({
295
+
type:'interval',
296
+
coordinate: {
297
+
transform: [{ type:'transpose' }],
298
+
},
299
+
data: [
300
+
{ text:'Top Level', value:5 },
301
+
{ text:'Upper Middle', value:10 },
302
+
{ text:'Middle', value:20 },
303
+
{ text:'Lower Middle', value:25 },
304
+
{ text:'Bottom Level', value:40 },
305
+
],
306
+
transform: [
307
+
{
308
+
type:'symmetryY',
309
+
},
310
+
],
311
+
axis: {
312
+
x:false,
313
+
y:false,
314
+
},
315
+
style: {
316
+
reverse:true,
317
+
},
318
+
encode: {
319
+
x:'text',
320
+
y:'value',
321
+
color:'text',
322
+
shape:'pyramid',
323
+
},
324
+
scale: {
325
+
x: { paddingOuter:0, paddingInner:0 },
326
+
color: { type:'ordinal' },
327
+
},
328
+
labels: [
329
+
{
330
+
text: (d) =>d.text,
331
+
position:"inside"
332
+
},
333
+
{
334
+
text: (d) =>d.value+"%",
335
+
position:"inside",
336
+
style: { dy:15 }
337
+
},
338
+
]
339
+
})
340
+
341
+
chart.render();
342
+
```
343
+
344
+
**Explanation**:
345
+
- Uses `reverse: true` to change the narrowing position of the funnel chart
346
+
- Population proportions should decrease layer by layer, reflecting the "wide bottom, narrow top" structure
347
+
- Population percentages for each level are clearly labeled, facilitating comparison of quantities or proportions between different groups
348
+
- Pyramid shape intuitively displays hierarchical distribution and stratification characteristics
349
+
282
350
### Unsuitable Use Cases
283
351
284
352
Example 1: **Not Suitable for Unordered Data or Data Without Clear Hierarchy**
0 commit comments