.push(values);
}
for (categoricals, group) in &grouped_data {
- let mut color = Color::BLACK;
- if let Some(style_color) = element.style.color {
- color = style_color;
- }
- if let Some(color_index) = color_index {
- let index = categoricals[color_index]
- .as_number()
- .unwrap_or_default()
- .unwrap_or_default();
- let index = <usize as NumCast>::from(index).unwrap_or_default();
- color = PALETTE[index % PALETTE.len()];
- }
+ let mut style = element.style.clone().into_owned();
if let Some((index, style_cycle)) = styling {
let index = categoricals[index]
.as_number()
.unwrap_or_default()
.unwrap_or_default();
let index = <usize as NumCast>::from(index).unwrap_or_default();
- let style = style_cycle.get_style(index);
- if let Some(style_color) = style.color {
- color = style_color;
+ for s in style_cycle.get_style_components(index) {
+ style = style.overridden_with(s);
}
}
-
- let mut color2 = Color::BLACK;
- if let Some(style_color) = element.style.color2 {
- color2 = style_color;
- }
- if let Some(color2_index) = color2_index {
- let index = categoricals[color2_index]
+ if let Some(color_index) = color_index {
+ let index = categoricals[color_index]
.as_number()
.unwrap_or_default()
.unwrap_or_default();
let index = <usize as NumCast>::from(index).unwrap_or_default();
- color2 = PALETTE[index % PALETTE.len()];
+ style.color = Some(PALETTE[index % PALETTE.len()]);
}
- if let Some((index, style_cycle)) = styling {
- let index = categoricals[index]
+ if let Some(color2_index) = color2_index {
+ let index = categoricals[color2_index]
.as_number()
.unwrap_or_default()
.unwrap_or_default();
let index = <usize as NumCast>::from(index).unwrap_or_default();
- let style = style_cycle.get_style(index);
- if let Some(style_color) = style.color2 {
- color2 = style_color;
- }
+ style.color2 = Some(PALETTE[index % PALETTE.len()]);
}
+ let color = style.color.unwrap_or(Color::BLACK);
+ let color2 = style.color2.unwrap_or(Color::BLACK);
+
fn points(
rect: &Rect,
group: &[Vec<&SeriesValue>],
match element.graphic {
Graphic::Interval => {
// Size defaults to 33%.
+ let fraction = match style.symbol_size {
+ Some(LocationLength::Percent(percent)) => percent,
+ _ => 33.0,
+ } / 100.0
+ / 2.0;
for (x, y0) in ranges(&rect, group, &axis_domains) {
+ let width = x.end - x.start;
+ let midpoint = x.start.midpoint(x.end);
+ let x =
+ midpoint - width * fraction..midpoint + width * fraction;
let y1 = rect.0[Axis2::Y].1;
element_svg.append(
Rectangle::new()
Percent
</text>
<g id="element_bar_1">
-<rect fill="#d3ce97" height="92.56696428571429" stroke="#000000" width="274.25" x="70.25" y="126.93303571428571"/>
-<rect fill="#d3ce97" height="204.2857142857143" stroke="#000000" width="274.25" x="344.5" y="15.214285714285701"/>
+<rect fill="#d3ce97" height="92.56696428571429" stroke="#000000" width="205.6875" x="104.53125" y="126.93303571428571"/>
+<rect fill="#d3ce97" height="204.2857142857143" stroke="#000000" width="205.6875" x="378.78125" y="15.214285714285701"/>
</g>
<g id="element_bar_1">
-<rect fill="#d3ce97" height="121.29464285714289" stroke="#000000" width="274.25" x="70.25" y="317.7053571428571"/>
-<rect fill="#d3ce97" height="127.67857142857144" stroke="#000000" width="274.25" x="344.5" y="311.32142857142856"/>
+<rect fill="#d3ce97" height="121.29464285714289" stroke="#000000" width="205.6875" x="104.53125" y="317.7053571428571"/>
+<rect fill="#d3ce97" height="127.67857142857144" stroke="#000000" width="205.6875" x="378.78125" y="311.32142857142856"/>
</g>
</g>
</svg>