Skip to content

Commit

Permalink
feat: support round rect for bar chart
Browse files Browse the repository at this point in the history
  • Loading branch information
vicanso committed May 1, 2024
1 parent c7872c1 commit 1ef2b62
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ readme = "./README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
charts-rs-derive = { path = "./charts-rs-derive", version = "0.2.0" }
charts-rs-derive = { path = "./charts-rs-derive", version = "0.2.1" }
fontdue = "0.8.0"
image = { version = "0.25.1", features = [
"webp",
Expand Down
56 changes: 28 additions & 28 deletions asset/bar_chart/basic_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/charts/bar_chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ pub struct BarChart {
pub series_symbol: Option<Symbol>,
pub series_smooth: bool,
pub series_fill: bool,

pub radius: Option<f32>,
}

impl BarChart {
Expand All @@ -95,6 +97,9 @@ impl BarChart {
if let Some(y_axis_hidden) = get_bool_from_value(&value, "y_axis_hidden") {
b.y_axis_hidden = y_axis_hidden;
}
if let Some(radius) = get_f32_from_value(&value, "radius") {
b.radius = Some(radius);
}
Ok(b)
}
/// Creates a bar chart with custom theme.
Expand Down Expand Up @@ -245,6 +250,7 @@ impl BarChart {
&y_axis_values_list,
max_height,
self.x_axis_data.len(),
self.radius,
);

let mut line_series_labels_list = self.render_line(
Expand Down Expand Up @@ -376,6 +382,7 @@ mod tests {
bottom: 10.0,
..Default::default()
});
bar_chart.radius = Some(5.0);
bar_chart.y_axis_configs[0].axis_formatter = Some("{c} ml".to_string());
bar_chart.series_list[0].label_show = true;
bar_chart.legend_category = LegendCategory::Circle;
Expand Down
2 changes: 1 addition & 1 deletion src/charts/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ pub(crate) fn get_axis_values(params: AxisValueParams) -> AxisValues {
unit = new_unit as f32;
}
}
let split_unit = unit as f32;
let split_unit = unit;

let mut data = vec![];
for i in 0..=split_number {
Expand Down

0 comments on commit 1ef2b62

Please sign in to comment.