read::graph::{
format::Formatter,
frames::{Component, Frames, Position},
- patterns::{ColoredPattern, Patterns},
+ patterns::Patterns,
style::{Style, StyleCycle},
},
},
let font_height = font_metrics.measure("0")[Axis2::Y];
let mut rect = graph_frame.rect().unwrap();
+ let cell_style = graph
+ .cell_style
+ .as_deref()
+ .and_then(|cell_style| styles.get(cell_style))
+ .cloned()
+ .unwrap_or_default();
+
let y_axis = axis_domains[Axis3::Y].ticks();
let y_axis_text_width = y_axis
.iter()
for (y_index, y_facet) in y_facets.clone().enumerate() {
let rect = rect.subrect(x_index, nx_facets, y_index, ny_facets);
+ if cell_style.color.is_some() {
+ graph_svg.append(
+ Rectangle::new()
+ .set("x", rect.0[Axis2::X].0)
+ .set("y", rect.0[Axis2::Y].0)
+ .set("width", rect.0[Axis2::X].length())
+ .set("height", rect.0[Axis2::Y].length())
+ .set("fill", cell_style.fill(&mut patterns))
+ .set(
+ "stroke",
+ cell_style
+ .color2
+ .unwrap_or(Color::BLACK)
+ .display_css()
+ .to_string(),
+ ),
+ );
+ }
+
for element in &elements {
let mut categoricals = IndexMap::new();
let mut color_index = None;
let color = style.color.unwrap_or(Color::BLACK);
let color2 = style.color2.unwrap_or(Color::BLACK);
- let pattern = patterns.insert(ColoredPattern {
- index: style.pattern.unwrap_or_default(),
- color,
- color2: style.color2.unwrap_or(Color::WHITE),
- });
+ let pattern = style.fill(&mut patterns);
fn points(
rect: &Rect,
#[serde(rename = "@id")]
id: Option<String>,
+ #[serde(rename = "@cellStyle")]
+ cell_style: Option<String>,
+
#[serde(rename = "$value")]
children: Vec<GraphChild>,
}
Length,
look::{Color, HorzAlign, VertAlign},
},
- spv::read::graph::{LocationLength, LocationLengthRange},
+ spv::read::graph::{
+ LocationLength, LocationLengthRange,
+ patterns::{ColoredPattern, Patterns},
+ },
};
#[derive(Clone, Deserialize, Debug)]
TextAlignment::Mixed => None,
}
}
+
+ pub fn fill(&self, patterns: &mut Patterns) -> String {
+ patterns.insert(ColoredPattern {
+ index: self.pattern.unwrap_or_default(),
+ color: self.color.unwrap_or(Color::BLACK),
+ color2: self.color2.unwrap_or(Color::WHITE),
+ })
+ }
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize)]
<text dominant-baseline="hanging" text-anchor="middle" transform="rotate(-90, 6.25, 245)" x="6.25" y="245">
Y Axis
</text>
+<rect fill="#f0f0f0" height="388" stroke="#000000" width="557.5" x="61.25" y="51"/>
<g id="element_simpleline_1">
<path d="M618.75,51 L590.875,51 L563,51 L563,69.47619 L535.125,69.47619 L535.125,87.95238 L507.25,87.95238 L479.375,87.95238 L479.375,106.42857 L451.5,106.42857 L423.625,106.42857 L395.75,106.42857 L367.875,106.42857 L340,106.42857 L312.125,106.42857 L312.125,124.90476 L284.25,124.90476 L284.25,143.38095 L256.375,143.38095 L228.5,143.38095 L200.625,143.38095 L200.625,161.85715 L200.625,180.33333 L200.625,198.80952 L172.75,198.80952 L172.75,217.28572 L172.75,235.7619 L172.75,254.2381 L172.75,272.7143 L172.75,291.1905 L144.875,291.1905 L144.875,309.66666 L117,309.66666 L89.125,309.66666 L89.125,328.14285 L89.125,346.61905 L89.125,365.09525 L89.125,383.57144 L89.125,402.0476 L89.125,420.5238 L89.125,439 L61.25,439" fill="none" stroke="#3e58ac"/>
</g>
<text dominant-baseline="hanging" text-anchor="middle" transform="rotate(-90, 6.25, 331.75)" x="6.25" y="331.75">
Percent
</text>
+<rect fill="#f0f0f0" height="214.5" stroke="#000000" width="548.5" x="70.25" y="5"/>
<g id="element_bar_1">
<rect fill="url(#pattern12_d3ce97_000000)" height="92.56696428571429" stroke="#000000" width="205.6875" x="104.53125" y="126.93303571428571"/>
<rect fill="url(#pattern12_d3ce97_000000)" height="204.2857142857143" stroke="#000000" width="205.6875" x="378.78125" y="15.214285714285701"/>
</g>
+<rect fill="#f0f0f0" height="214.5" stroke="#000000" width="548.5" x="70.25" y="224.5"/>
<g id="element_bar_1">
<rect fill="url(#pattern12_d3ce97_000000)" height="121.29464285714289" stroke="#000000" width="205.6875" x="104.53125" y="317.7053571428571"/>
<rect fill="url(#pattern12_d3ce97_000000)" height="127.67857142857144" stroke="#000000" width="205.6875" x="378.78125" y="311.32142857142856"/>
<text dominant-baseline="middle" text-anchor="end" x="28.25" y="NaN">
0.0
</text>
+<rect fill="rgb(0, 0, 0, 0.00)" height="226" stroke="rgb(0, 0, 0, 0.00)" width="430.5" x="38.25" y="5"/>
<g id="element_element_1">
<rect fill="#3e58ac" height="113" stroke="#000000" width="1" x="246.55645161290323" y="118"/>
</g>
<g id="element_element_1">
<rect fill="#2eb848" height="113" stroke="#000000" width="1" x="191.00806451612905" y="118"/>
</g>
+<rect fill="rgb(0, 0, 0, 0.00)" height="226" stroke="rgb(0, 0, 0, 0.00)" width="430.5" x="38.25" y="236"/>
<g id="element_element_1">
<rect fill="#2eb848" height="113" stroke="#000000" width="1" x="468.75" y="349"/>
</g>