-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add label for pie charts, fix slice hover and fix gradient color
- Loading branch information
Ralf Grubenmann
committed
Nov 7, 2023
1 parent
76219f8
commit fe276df
Showing
4 changed files
with
73 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use num_traits::ToPrimitive; | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq)] | ||
pub struct Point<T> { | ||
pub value: T, | ||
pub label: String, | ||
} | ||
|
||
impl<T> From<(T, String)> for Point<T> | ||
where | ||
T: ToPrimitive + Clone + PartialOrd + 'static, | ||
{ | ||
fn from(point: (T, String)) -> Point<T> { | ||
Point { | ||
value: point.0, | ||
label: point.1, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq)] | ||
pub struct Series<T>(Vec<Point<T>>); | ||
|
||
impl<T> From<Vec<(T, String)>> for Series<T> | ||
where | ||
T: ToPrimitive + Clone + PartialOrd + 'static, | ||
{ | ||
fn from(values: Vec<(T, String)>) -> Series<T> { | ||
Series(values.into_iter().map(|p| p.into()).collect()) | ||
} | ||
} | ||
|
||
impl<T> IntoIterator for Series<T> { | ||
type Item = Point<T>; | ||
type IntoIter = std::vec::IntoIter<Self::Item>; | ||
|
||
fn into_iter(self) -> Self::IntoIter { | ||
self.0.into_iter() | ||
} | ||
} |