Skip to main content

Chart

Struct Chart 

Source
pub struct Chart {
    pub chart_type: ChartType,
    pub data: ChartData,
    pub rid: String,
    pub external_data_rid: Option<String>,
}
Expand description

一个完整的图表,引用 chart part。

Fields§

§chart_type: ChartType

图表类型。

§data: ChartData

图表数据。

§rid: String

关系 id(指向 /ppt/charts/chartN.xml)。

Presentation::to_opc_package 在写出 chart part 时自动分配。 高阶 API 创建时通常为空字符串,由 presentation 层填充。

§external_data_rid: Option<String>

嵌入式 Excel 工作簿的关系 id(TODO-004 Excel 嵌入)。

指向 /ppt/embeddings/Microsoft_Excel_WorksheetN.xlsx,写出时在 </c:chart> 之后、</c:chartSpace> 之前生成 <c:externalData r:id="..."><c:autoUpdate val="0"/></c:externalData>

  • None:不写出 <c:externalData>(图表数据仅靠 numCache/strCache)。
  • Some(rid):写出 <c:externalData r:id="{rid}"/>,PowerPoint 打开 图表时会从 xlsx part 读取数据源(“编辑数据” 启动 Excel)。

Presentation::to_opc_package 在写出 xlsx part 时自动分配; 高阶 API 创建时通常为 None,由 presentation 层填充。

Implementations§

Source§

impl Chart

Source

pub fn new(chart_type: ChartType, data: ChartData) -> Self

新建一个图表。rid 默认为空字符串,由 presentation 层在写出时填充。

Source

pub fn parse_from_xml(xml: &str) -> Result<Chart>

<c:chartSpace> XML 字符串解析为强类型 Chart

详见模块级独立函数 parse_from_xml(本关联函数是其委托)。

§参数
  • xml:完整 chartN.xml 内容。
§错误
  • Error::Xml:XML 解析失败。
Source§

impl Chart

Source

pub fn to_xml(&self) -> String

写出 <c:chartSpace> 完整 XML(chartN.xml 内容)。

§元素结构(最小可用集)
<c:chartSpace xmlns:c=... xmlns:a=... xmlns:r=...>
  <c:chart>
    <c:title>...?         ← 可选
    <c:plotArea>
      <c:layout/>         ← 自动布局
      <c:barChart|c:lineChart|c:pieChart>
        <c:barDir>...     ← 仅 barChart
        <c:grouping val="clustered"/>
        <c:ser>           ← 一个或多个系列
          <c:idx val="0"/>
          <c:order val="0"/>
          <c:tx><c:strRef><c:f>Sheet1!$B$1</c:f><c:strCache>...</c:strCache></c:strRef></c:tx>
          <c:cat><c:strRef>...类别标签...</c:strRef></c:cat>
          <c:val><c:numRef><c:numCache>...数值...</c:numCache></c:numRef></c:val>
        </c:ser>
        <c:axId val="..."/>  ← 1~2 个 axId
      </c:barChart>
      <c:catAx>...</c:catAx>     ← 类别轴(饼图无)
      <c:valAx>...</c:valAx>     ← 数值轴(饼图无)
    </c:plotArea>
  </c:chart>
</c:chartSpace>

Trait Implementations§

Source§

impl Clone for Chart

Source§

fn clone(&self) -> Chart

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Chart

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Chart

Source§

fn default() -> Self

默认图表:ChartType::Column + 空 ChartData + 空 rid。

Auto Trait Implementations§

§

impl Freeze for Chart

§

impl RefUnwindSafe for Chart

§

impl Send for Chart

§

impl Sync for Chart

§

impl Unpin for Chart

§

impl UnsafeUnpin for Chart

§

impl UnwindSafe for Chart

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V