1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! Chart definitions.
use serde::{Deserialize, Serialize};
/// The chart shapes visi can read and write.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum ChartType {
/// Vertical bars.
Column,
/// Horizontal bars.
Bar,
/// Points joined by lines.
Line,
/// A pie, from a single series.
Pie,
/// X/Y points, taking the first column as the x values.
Scatter,
/// A line chart with the area beneath it filled.
Area,
}
/// A chart over a range of cells.
///
/// Workbook-level rather than sheet-scoped: `WorkbookManager::charts` owns
/// these, and which worksheet a chart is drawn on comes from `data_range`'s
/// sheet prefix.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct Chart {
/// Workbook-unique identifier, stable across renames.
pub id: u64,
/// Display name.
pub name: String,
/// What shape to draw.
pub chart_type: ChartType,
/// The source cells, in A1 notation with a sheet prefix
/// (`"table_1!A1:B10"`). The prefix also decides which worksheet the
/// chart is anchored to.
pub data_range: String,
/// Chart title, if it has one.
pub title: Option<String>,
/// X-axis label, if it has one.
pub xlabel: Option<String>,
/// Y-axis label, if it has one.
pub ylabel: Option<String>,
/// Whether to draw a legend.
pub show_legend: bool,
/// 0-based row/col of the cell the chart's top-left corner is anchored
/// to on its worksheet (which worksheet that is comes from
/// `data_range`'s sheet/table prefix, same as today).
#[serde(default)]
pub anchor_row: usize,
/// Column half of that anchor; see [`Chart::anchor_row`].
#[serde(default)]
pub anchor_col: usize,
}