syncfusion-flutter-pyramid-charts
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImplementing Pyramid Charts (SfPyramidChart)
实现金字塔图表(SfPyramidChart)
The Syncfusion Flutter widget renders high-performance pyramid charts natively in Dart. It visualizes proportional or hierarchical data as stacked triangular segments, making it ideal for sales funnels, population distribution, organizational hierarchy, and process stage analysis.
SfPyramidChartSyncfusion Flutter 组件使用Dart原生渲染高性能金字塔图表,它将比例或层级数据可视化为堆叠的三角分段,非常适合销售漏斗、人口分布、组织架构层级和流程阶段分析场景。
SfPyramidChartWhen to Use This Skill
何时使用本技能
- User wants to render a pyramid chart in a Flutter application
- User references ,
SfPyramidChart, orPyramidSeriessyncfusion_flutter_charts - User needs to customize pyramid segments (color, gap, explode, mode)
- User wants to add labels, legend, tooltip, or selection to a pyramid chart
- User needs to export a pyramid chart as PNG or PDF
- User asks about RTL support or accessibility in Syncfusion Flutter charts
- 用户需要在Flutter应用中渲染金字塔图表
- 用户提到 、
SfPyramidChart或PyramidSeriessyncfusion_flutter_charts - 用户需要自定义金字塔分段(颜色、间隙、炸开、模式)
- 用户需要为金字塔图表添加标签、图例、工具提示或选择功能
- 用户需要将金字塔图表导出为PNG或PDF格式
- 用户询问Syncfusion Flutter图表的RTL支持或无障碍适配相关问题
Documentation and Navigation Guide
文档与导航指南
Getting Started
入门指南
📄 Read: references/getting-started.md
- Package installation and pubspec.yaml setup
- Import statement and basic widget initialization
- Binding data source with xValueMapper / yValueMapper
- Adding title, data labels, legend, and tooltip
- Minimal runnable example
📄 阅读: references/getting-started.md
- 包安装与pubspec.yaml配置
- 导入语句与基础组件初始化
- 通过xValueMapper / yValueMapper绑定数据源
- 添加标题、数据标签、图例和工具提示
- 最小可运行示例
Pyramid Customization
金字塔自定义
📄 Read: references/pyramid-customization.md
- PyramidMode: linear (height-based) vs surface (area-based)
- Changing pyramid size with and
height(percentage strings)width - Gap between segments using (0 to 1)
gapRatio - Exploding segments: ,
explode,explodeIndexexplodeOffset - Palette colors, border color/width, opacity, pointColorMapper
📄 阅读: references/pyramid-customization.md
- PyramidMode:linear(基于高度)与surface(基于面积)两种模式
- 使用和
height(百分比字符串)修改金字塔尺寸width - 通过(取值0到1)设置分段之间的间隙
gapRatio - 分段炸开功能:、
explode、explodeIndexexplodeOffset - 配色方案、边框颜色/宽度、透明度、pointColorMapper配置
Series Customization
系列自定义
📄 Read: references/series-customization.md
- Animation: and
animationDurationanimationDelay - Handling null/empty data points with
EmptyPointSettings - Empty point modes: gap, zero, drop, average
- Color mapping per data point via
pointColorMapper
📄 阅读: references/series-customization.md
- 动画:和
animationDuration配置animationDelay - 使用处理空/无效数据点
EmptyPointSettings - 空数据点模式:gap、zero、drop、average
- 通过为每个数据点配置对应颜色
pointColorMapper
Data Labels
数据标签
📄 Read: references/data-labels.md
- Enabling data labels with
DataLabelSettings(isVisible: true) - Inside vs outside positioning ()
labelPosition - Connector line settings (type, color, length)
- Custom label templates via
builder - Smart labels and
labelIntersectAction - Overflow mode and hiding zero-value labels
📄 阅读: references/data-labels.md
- 通过 开启数据标签
DataLabelSettings(isVisible: true) - 内部/外部位置配置()
labelPosition - 连接线设置(类型、颜色、长度)
- 通过自定义标签模板
builder - 智能标签与配置
labelIntersectAction - 溢出模式与零值标签隐藏
Legend and Tooltip
图例与工具提示
📄 Read: references/legend-and-tooltip.md
- Enabling and positioning the legend
- Legend title, item templates, overflow behavior
- Toggle series visibility via legend tap
- Enabling tooltip with
TooltipBehavior - Tooltip formatting, custom templates, activation mode
📄 阅读: references/legend-and-tooltip.md
- 图例的开启与位置配置
- 图例标题、项模板、溢出行为配置
- 点击图例切换系列可见性
- 通过开启工具提示
TooltipBehavior - 工具提示格式、自定义模板、触发模式配置
Selection and Callbacks
选择与回调
📄 Read: references/selection-and-callbacks.md
- Enabling segment selection with
SelectionBehavior - Multi-selection, toggle selection, initial selection
- Programmatic selection via
selectDataPoints - Key callbacks: ,
onPointTap,onSelectionChangedonTooltipRender - for dynamic data updates via
onRendererCreatedPyramidSeriesController
📄 阅读: references/selection-and-callbacks.md
- 通过开启分段选择功能
SelectionBehavior - 多选、切换选择、初始选中配置
- 通过实现程序化选择
selectDataPoints - 核心回调:、
onPointTap、onSelectionChangedonTooltipRender - 通过配合
onRendererCreated实现动态数据更新PyramidSeriesController
Appearance, Export, and RTL
外观、导出与RTL
📄 Read: references/appearance-export-rtl.md
- Chart title customization ()
ChartTitle - Chart sizing, margin, background color/image
- Exporting chart as PNG image or PDF document
- RTL support using widget or locale
Directionality - Accessibility: contrast, font scaling, tap targets
- method for coordinate conversion
pixelToPoint
📄 阅读: references/appearance-export-rtl.md
- 图表标题自定义()
ChartTitle - 图表尺寸、边距、背景色/背景图配置
- 导出图表为PNG图片或PDF文档
- 通过组件或locale配置RTL支持
Directionality - 无障碍适配:对比度、字体缩放、点击区域
- 方法实现坐标转换
pixelToPoint
Quick Start Example
快速开始示例
dart
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
class PyramidChartExample extends StatelessWidget {
final List<ChartData> chartData = [
ChartData('Enterprise', 654),
ChartData('Mid-Market', 575),
ChartData('SMB', 446),
ChartData('Startup', 341),
ChartData('Individual', 160),
];
Widget build(BuildContext context) {
return Scaffold(
body: SfPyramidChart(
title: ChartTitle(text: 'Sales Pipeline'),
legend: Legend(isVisible: true),
series: PyramidSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
dataLabelSettings: DataLabelSettings(isVisible: true),
),
),
);
}
}
class ChartData {
ChartData(this.x, this.y);
final String x;
final double y;
}dart
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
class PyramidChartExample extends StatelessWidget {
final List<ChartData> chartData = [
ChartData('Enterprise', 654),
ChartData('Mid-Market', 575),
ChartData('SMB', 446),
ChartData('Startup', 341),
ChartData('Individual', 160),
];
Widget build(BuildContext context) {
return Scaffold(
body: SfPyramidChart(
title: ChartTitle(text: 'Sales Pipeline'),
legend: Legend(isVisible: true),
series: PyramidSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
dataLabelSettings: DataLabelSettings(isVisible: true),
),
),
);
}
}
class ChartData {
ChartData(this.x, this.y);
final String x;
final double y;
}Common Patterns
常用实现模式
Exploding a specific segment
炸开指定分段
dart
PyramidSeries<ChartData, String>(
explode: true,
explodeIndex: 0, // Index of segment to highlight
explodeOffset: '5%', // Distance the segment moves out
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
)dart
PyramidSeries<ChartData, String>(
explode: true,
explodeIndex: 0, // 需要高亮的分段索引
explodeOffset: '5%', // 分段向外偏移的距离
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
)Surface mode (area proportional)
面积比例模式(surface)
dart
PyramidSeries<ChartData, String>(
pyramidMode: PyramidMode.surface, // Area ∝ Y value (vs linear: height ∝ Y)
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
)dart
PyramidSeries<ChartData, String>(
pyramidMode: PyramidMode.surface, // 分段面积与Y值成正比(linear模式为高度与Y值成正比)
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
)Tooltip + selection together
同时开启工具提示和选择功能
dart
// In initState:
_tooltipBehavior = TooltipBehavior(enable: true);
_selectionBehavior = SelectionBehavior(enable: true);
// In widget:
SfPyramidChart(
tooltipBehavior: _tooltipBehavior,
series: PyramidSeries<ChartData, String>(
selectionBehavior: _selectionBehavior,
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
),
)dart
// 在initState中初始化:
_tooltipBehavior = TooltipBehavior(enable: true);
_selectionBehavior = SelectionBehavior(enable: true);
// 组件中配置:
SfPyramidChart(
tooltipBehavior: _tooltipBehavior,
series: PyramidSeries<ChartData, String>(
selectionBehavior: _selectionBehavior,
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
),
)Key Properties
核心属性
| Property | Type | Description |
|---|---|---|
| | The pyramid data series (one per chart) |
| | Chart title widget |
| | Legend configuration |
| | Tooltip enable/customize |
| | Allow selecting multiple segments |
| | Custom segment colors |
| | |
| | Gap between segments (0–1) |
| | Enable segment explode on tap |
| 属性 | 类型 | 描述 |
|---|---|---|
| | 金字塔数据系列(每个图表对应一个系列) |
| | 图表标题组件 |
| | 图例配置 |
| | 工具提示开启/自定义配置 |
| | 是否允许选择多个分段 |
| | 自定义分段配色 |
| | 尺寸计算模式: |
| | 分段之间的间隙(取值0-1) |
| | 是否开启点击分段炸开功能 |