pub struct DataLabels {
pub show_val: Option<bool>,
pub show_cat_name: Option<bool>,
pub show_ser_name: Option<bool>,
pub show_legend_key: Option<bool>,
pub show_percent: Option<bool>,
pub show_bubble_size: Option<bool>,
pub position: Option<LabelPosition>,
pub separator: Option<String>,
pub num_fmt: Option<String>,
}Expand description
数据标签配置(<c:dLbls>),对应 OOXML CT_DLbls。
控制数据点数值/类别/系列名等标签的显示。可挂在图表级(<c:barChart> 内)
或系列级(<c:ser> 内)——系列级会覆盖图表级。
§字段语义
所有 show_* 字段为 Option<bool>:
None:不写出该<c:showXxx>元素(继承上层或 PowerPoint 默认);Some(true):写出<c:showXxx val="1"/>;Some(false):写出<c:showXxx val="0"/>。
§与 python-pptx 的对应
- python-pptx
plot.data_labels←→ 图表级ChartData.data_labels; - python-pptx
series.data_labels←→ 系列级ChartSeries.data_labels。
Fields§
§show_val: Option<bool>显示数值(<c:showVal val="1"/>)。最常用的数据标签。
show_cat_name: Option<bool>显示类别名(<c:showCatName val="1"/>)。
show_ser_name: Option<bool>显示系列名(<c:showSerName val="1"/>)。
show_legend_key: Option<bool>显示图例键(<c:showLegendKey val="1"/>,图例色块前缀)。
show_percent: Option<bool>显示百分比(<c:showPercent val="1"/>,主要用于饼图)。
show_bubble_size: Option<bool>显示气泡尺寸(<c:showBubbleSize val="1"/>,仅气泡图)。
position: Option<LabelPosition>标签位置(<c:dLblPos val="..."/>)。
separator: Option<String>分隔符(<c:separator val="..."/>,如 ", " / "\n")。
num_fmt: Option<String>数字格式(<c:numFmt formatCode="..." sourceLinked="0"/>)。
Implementations§
Source§impl DataLabels
impl DataLabels
Sourcepub fn show_values() -> Self
pub fn show_values() -> Self
新建一个仅显示数值的数据标签配置(最常用场景)。
Sourcepub fn show_percent_pie() -> Self
pub fn show_percent_pie() -> Self
新建一个显示百分比的饼图数据标签配置。
Sourcepub fn write_xml(&self, w: &mut XmlWriter)
pub fn write_xml(&self, w: &mut XmlWriter)
写出 <c:dLbls> 元素到 XmlWriter。
OOXML 元素顺序约束(ECMA-376 21.2.2.40):
numFmt → spacing → position → separator → showLegendKey →
showVal → showCatName → showSerName → showPercent →
showBubbleSize → dLbl → dLblPos → …
实际 PowerPoint 实践中常用顺序:showVal → showCatName → … → dLblPos → separator → numFmt。
本实现采用 PowerPoint 实践顺序以保证兼容性。
Trait Implementations§
Source§impl Clone for DataLabels
impl Clone for DataLabels
Source§fn clone(&self) -> DataLabels
fn clone(&self) -> DataLabels
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more