Skip to content

Commit

Permalink
Remove corner radius
Browse files Browse the repository at this point in the history
Might do it at some point.
  • Loading branch information
aleics committed Sep 17, 2024
1 parent acb8fec commit 594898f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 27 deletions.
3 changes: 1 addition & 2 deletions bruc-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ mod tests {
"properties": {
"value": { "field": "y" },
"padAngle": 0.1,
"innerRadius": 50,
"cornerRadius": 50
"innerRadius": 50
}
}
]
Expand Down
22 changes: 4 additions & 18 deletions bruc-core/src/spec/shape/pie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub(crate) struct PiePropertiesBuilder {
value: DataSource,
pad_angle: Option<f32>,
inner_radius: Option<f32>,
corner_radius: Option<f32>,
}

impl PiePropertiesBuilder {
Expand All @@ -13,7 +12,6 @@ impl PiePropertiesBuilder {
value,
pad_angle: None,
inner_radius: None,
corner_radius: None,
}
}

Expand All @@ -27,17 +25,11 @@ impl PiePropertiesBuilder {
self
}

pub(crate) fn with_corner_radius(mut self, corner_radius: f32) -> Self {
self.corner_radius = Some(corner_radius);
self
}

pub(crate) fn build(self) -> PieProperties {
PieProperties {
value: self.value,
pad_angle: self.pad_angle.unwrap_or_default(),
inner_radius: self.inner_radius.unwrap_or_default(),
corner_radius: self.corner_radius.unwrap_or_default(),
inner_radius: self.inner_radius.unwrap_or_default()
}
}
}
Expand Down Expand Up @@ -66,9 +58,7 @@ pub(crate) struct PieProperties {
#[cfg_attr(feature = "serde", serde(default))]
pub(crate) pad_angle: f32,
#[cfg_attr(feature = "serde", serde(default))]
pub(crate) inner_radius: f32,
#[cfg_attr(feature = "serde", serde(default))]
pub(crate) corner_radius: f32,
pub(crate) inner_radius: f32
}

#[cfg(test)]
Expand Down Expand Up @@ -103,8 +93,7 @@ mod serde_tests {
"properties": {
"value": { "field": "y" },
"padAngle": 0.1,
"innerRadius": 50,
"cornerRadius": 50
"innerRadius": 50
}
}"#,
)
Expand All @@ -116,7 +105,6 @@ mod serde_tests {
PiePropertiesBuilder::new(DataSource::field("y", None))
.with_pad_angle(0.1)
.with_inner_radius(50.0)
.with_corner_radius(50.0)
.build()
)
)
Expand All @@ -140,8 +128,7 @@ mod serde_tests {
r#"{
"value": { "field": "y" },
"padAngle": 0.1,
"innerRadius": 50,
"cornerRadius": 50
"innerRadius": 50
}"#,
)
.unwrap();
Expand All @@ -150,7 +137,6 @@ mod serde_tests {
PiePropertiesBuilder::new(DataSource::field("y", None))
.with_pad_angle(0.1)
.with_inner_radius(50.0)
.with_corner_radius(50.0)
.build()
);
}
Expand Down
19 changes: 18 additions & 1 deletion bruc-web/examples/pie-chart/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
<!doctype html>
<html>
<head>
<style>
.wrapper {
display: grid;
grid-template-columns: 1fr 1fr;
}

.wrapper > div {
display: flex;
align-items: center;
justify-content: center;
}
</style>
</head>
<body>
<div id="first"></div>
<div class="wrapper">
<div id="pie"></div>
<div id="donut"></div>
</div>
<noscript
>This page contains webassembly and javascript content, please
enable javascript in your browser.</noscript
Expand Down
43 changes: 37 additions & 6 deletions bruc-web/examples/pie-chart/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
import { Bruc } from "bruc";

const spec = `{
const pie_spec = `{
"dimensions": {
"width": 500,
"height": 500
"width": 300,
"height": 300
},
"data": [
{
"name": "primary",
"values": [],
"transform": [
{ "type": "map", "fn": "y * 10", "output": "value" }
]
}
],
"visual": {
"shapes": [
{
"from": "primary",
"type": "pie",
"properties": {
"value": { "field": "value" },
"padAngle": 0.02
}
}
]
}
}`;

const donut_spec = `{
"dimensions": {
"width": 300,
"height": 300
},
"data": [
{
Expand All @@ -29,13 +57,16 @@ const spec = `{
}
}`;

const bruc = Bruc.build(spec);
const pie = Bruc.build(pie_spec);
await pie.renderAsSvg("#pie");

await bruc.renderAsSvg("#first");
const donut = Bruc.build(donut_spec);
await donut.renderAsSvg("#donut");

while (true) {
const data = randomData();
await bruc.setData("primary", data);
await pie.setData("primary", data);
await donut.setData("primary", data);

await delay(1000);
}
Expand Down

0 comments on commit 594898f

Please sign in to comment.