diff --git a/charming/src/element/mark_line.rs b/charming/src/element/mark_line.rs index 8ed0401..c655a61 100644 --- a/charming/src/element/mark_line.rs +++ b/charming/src/element/mark_line.rs @@ -168,6 +168,12 @@ pub struct MarkLine { #[serde(skip_serializing_if = "Vec::is_empty")] symbol: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + precision: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + silent: Option, + #[serde(skip_serializing_if = "Vec::is_empty")] data: Vec, } @@ -186,6 +192,8 @@ impl MarkLine { zlevel: None, z: None, symbol: vec![], + precision: None, + silent: None, data: vec![], } } @@ -215,6 +223,16 @@ impl MarkLine { self } + pub fn precision>(mut self, precision: F) -> Self { + self.precision = Some(precision.into()); + self + } + + pub fn silent(mut self, silent: bool) -> Self { + self.silent = Some(silent); + self + } + pub fn data>(mut self, data: Vec) -> Self { self.data = data.into_iter().map(|m| m.into()).collect(); self diff --git a/charming/src/series/bar.rs b/charming/src/series/bar.rs index a07d946..6910dea 100644 --- a/charming/src/series/bar.rs +++ b/charming/src/series/bar.rs @@ -4,7 +4,9 @@ use serde::Serialize; use crate::{ datatype::{DataFrame, DataPoint}, - element::{BackgroundStyle, ColorBy, CoordinateSystem, Emphasis, ItemStyle, Label, MarkLine}, + element::{ + BackgroundStyle, ColorBy, CoordinateSystem, Emphasis, ItemStyle, Label, MarkLine, Tooltip, + }, }; #[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)] @@ -67,6 +69,9 @@ pub struct Bar { #[serde(skip_serializing_if = "Option::is_none")] bar_width: Option, + #[serde(skip_serializing_if = "Option::is_none")] + tooltip: Option, + #[serde(skip_serializing_if = "Vec::is_empty")] data: DataFrame, } @@ -99,6 +104,7 @@ impl Bar { mark_line: None, stack: None, bar_width: None, + tooltip: None, data: vec![], } } @@ -193,6 +199,11 @@ impl Bar { self } + pub fn tooltip(mut self, tooltip: Tooltip) -> Self { + self.tooltip = Some(tooltip); + self + } + pub fn data>(mut self, data: Vec) -> Self { self.data = data.into_iter().map(|d| d.into()).collect(); self diff --git a/charming/src/series/boxplot.rs b/charming/src/series/boxplot.rs index ba47488..0ded95e 100644 --- a/charming/src/series/boxplot.rs +++ b/charming/src/series/boxplot.rs @@ -1,6 +1,6 @@ use serde::Serialize; -use crate::element::{ColorBy, CoordinateSystem}; +use crate::element::{ColorBy, CoordinateSystem, Tooltip}; #[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)] #[serde(rename_all = "camelCase")] @@ -28,6 +28,9 @@ pub struct Boxplot { #[serde(skip_serializing_if = "Option::is_none")] dataset_index: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + tooltip: Option, } impl Default for Boxplot { @@ -47,6 +50,7 @@ impl Boxplot { legend_hover_link: None, hover_animation: None, dataset_index: None, + tooltip: None, } } @@ -84,4 +88,9 @@ impl Boxplot { self.dataset_index = Some(dataset_index); self } + + pub fn tooltip(mut self, tooltip: Tooltip) -> Self { + self.tooltip = Some(tooltip); + self + } } diff --git a/charming/src/series/candlestick.rs b/charming/src/series/candlestick.rs index 500ef95..2ff1ef3 100644 --- a/charming/src/series/candlestick.rs +++ b/charming/src/series/candlestick.rs @@ -2,7 +2,7 @@ use serde::Serialize; use crate::{ datatype::{DataFrame, DataPoint}, - element::{ColorBy, CoordinateSystem}, + element::{ColorBy, CoordinateSystem, Tooltip}, }; #[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)] @@ -26,6 +26,9 @@ pub struct Candlestick { #[serde(skip_serializing_if = "Option::is_none")] legend_hover_link: Option, + #[serde(skip_serializing_if = "Option::is_none")] + tooltip: Option, + #[serde(skip_serializing_if = "Vec::is_empty")] data: DataFrame, } @@ -46,6 +49,7 @@ impl Candlestick { color_by: None, legend_hover_link: None, data: vec![], + tooltip: None, } } @@ -74,6 +78,11 @@ impl Candlestick { self } + pub fn tooltip(mut self, tooltip: Tooltip) -> Self { + self.tooltip = Some(tooltip); + self + } + pub fn data>(mut self, data: Vec) -> Self { self.data = data.into_iter().map(|d| d.into()).collect(); self diff --git a/charming/src/series/custom.rs b/charming/src/series/custom.rs index a82f17c..6ebf37b 100644 --- a/charming/src/series/custom.rs +++ b/charming/src/series/custom.rs @@ -4,6 +4,7 @@ use crate::{ datatype::{CompositeValue, DataFrame, DataPoint, Dimension}, element::{ ColorBy, CoordinateSystem, DimensionEncode, ItemStyle, LabelLayout, LabelLine, RawString, + Tooltip, }, }; @@ -63,6 +64,9 @@ pub struct Custom { #[serde(skip_serializing_if = "Option::is_none")] encode: Option, + #[serde(skip_serializing_if = "Option::is_none")] + tooltip: Option, + #[serde(skip_serializing_if = "Vec::is_empty")] data: DataFrame, } @@ -94,6 +98,7 @@ impl Custom { selected_mode: None, dimensions: vec![], encode: None, + tooltip: None, data: vec![], } } @@ -183,6 +188,11 @@ impl Custom { self } + pub fn tooltip(mut self, tooltip: Tooltip) -> Self { + self.tooltip = Some(tooltip); + self + } + pub fn data>(mut self, data: Vec) -> Self { self.data = data.into_iter().map(|d| d.into()).collect(); self diff --git a/charming/src/series/effect_scatter.rs b/charming/src/series/effect_scatter.rs index 83e09fe..04de8e4 100644 --- a/charming/src/series/effect_scatter.rs +++ b/charming/src/series/effect_scatter.rs @@ -4,7 +4,7 @@ use crate::{ datatype::{DataFrame, DataPoint}, element::{ Color, ColorBy, CoordinateSystem, Emphasis, ItemStyle, Label, LabelLayout, LabelLine, - Symbol, + Symbol, Tooltip, }, }; @@ -162,6 +162,9 @@ pub struct EffectScatter { #[serde(skip_serializing_if = "Option::is_none")] emphasis: Option, + #[serde(skip_serializing_if = "Option::is_none")] + tooltip: Option, + #[serde(skip_serializing_if = "Vec::is_empty")] data: DataFrame, } @@ -198,6 +201,7 @@ impl EffectScatter { label_layout: None, item_style: None, emphasis: None, + tooltip: None, data: vec![], } } @@ -312,6 +316,11 @@ impl EffectScatter { self } + pub fn tooltip(mut self, tooltip: Tooltip) -> Self { + self.tooltip = Some(tooltip); + self + } + pub fn data>(mut self, data: Vec) -> Self { self.data = data.into_iter().map(|d| d.into()).collect(); self diff --git a/charming/src/series/funnel.rs b/charming/src/series/funnel.rs index ded015c..7fcd8bb 100644 --- a/charming/src/series/funnel.rs +++ b/charming/src/series/funnel.rs @@ -2,7 +2,7 @@ use serde::Serialize; use crate::{ datatype::{CompositeValue, DataFrame, DataPoint}, - element::{ColorBy, Emphasis, ItemStyle, Label, LabelLine, Orient, Sort}, + element::{ColorBy, Emphasis, ItemStyle, Label, LabelLine, Orient, Sort, Tooltip}, }; #[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)] @@ -85,6 +85,9 @@ pub struct Funnel { #[serde(skip_serializing_if = "Option::is_none")] emphasis: Option, + #[serde(skip_serializing_if = "Option::is_none")] + tooltip: Option, + #[serde(skip_serializing_if = "Vec::is_empty")] data: DataFrame, } @@ -121,6 +124,7 @@ impl Funnel { label_line: None, item_style: None, emphasis: None, + tooltip: None, data: vec![], } } @@ -235,6 +239,11 @@ impl Funnel { self } + pub fn tooltip(mut self, tooltip: Tooltip) -> Self { + self.tooltip = Some(tooltip); + self + } + pub fn data>(mut self, data: Vec) -> Self { self.data = data.into_iter().map(|d| d.into()).collect(); self diff --git a/charming/src/series/gauge.rs b/charming/src/series/gauge.rs index 747c016..c0c68b7 100644 --- a/charming/src/series/gauge.rs +++ b/charming/src/series/gauge.rs @@ -4,7 +4,7 @@ use crate::{ datatype::{DataFrame, DataPoint}, element::{ Anchor, AxisLabel, AxisLine, AxisTick, Color, ColorBy, Formatter, ItemStyle, Pointer, - SplitLine, + SplitLine, Tooltip, }, }; @@ -287,6 +287,9 @@ pub struct Gauge { #[serde(skip_serializing_if = "Option::is_none")] title: Option, + #[serde(skip_serializing_if = "Option::is_none")] + tooltip: Option, + #[serde(skip_serializing_if = "Vec::is_empty")] data: DataFrame, } @@ -324,6 +327,7 @@ impl Gauge { anchor: None, detail: None, title: None, + tooltip: None, data: vec![], } } @@ -443,6 +447,11 @@ impl Gauge { self } + pub fn tooltip(mut self, tooltip: Tooltip) -> Self { + self.tooltip = Some(tooltip); + self + } + pub fn data>(mut self, data: Vec) -> Self { self.data = data.into_iter().map(|d| d.into()).collect(); self diff --git a/charming/src/series/graph.rs b/charming/src/series/graph.rs index 47b840a..7e5aac1 100644 --- a/charming/src/series/graph.rs +++ b/charming/src/series/graph.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; -use crate::element::{CoordinateSystem, Label, LabelLayout, LineStyle, ScaleLimit}; +use crate::element::{CoordinateSystem, Label, LabelLayout, LineStyle, ScaleLimit, Tooltip}; #[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)] #[serde(rename_all = "camelCase")] @@ -275,6 +275,9 @@ pub struct Graph { #[serde(skip_serializing_if = "Option::is_none")] edge_symbol: Option<(String, String)>, + + #[serde(skip_serializing_if = "Option::is_none")] + tooltip: Option, } impl Default for Graph { @@ -308,6 +311,7 @@ impl Graph { links: vec![], data: vec![], edge_symbol: None, + tooltip: None, } } @@ -407,4 +411,9 @@ impl Graph { self.edge_symbol = edge_symbol; self } + + pub fn tooltip(mut self, tooltip: Tooltip) -> Self { + self.tooltip = Some(tooltip); + self + } } diff --git a/charming/src/series/heatmap.rs b/charming/src/series/heatmap.rs index 12d4a7d..18dc2f2 100644 --- a/charming/src/series/heatmap.rs +++ b/charming/src/series/heatmap.rs @@ -2,7 +2,7 @@ use serde::Serialize; use crate::{ datatype::DataFrame, - element::{CoordinateSystem, Emphasis, ItemStyle, Label}, + element::{CoordinateSystem, Emphasis, ItemStyle, Label, Tooltip}, }; #[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)] @@ -59,6 +59,9 @@ pub struct Heatmap { #[serde(skip_serializing_if = "Option::is_none")] emphasis: Option, + #[serde(skip_serializing_if = "Option::is_none")] + tooltip: Option, + #[serde(skip_serializing_if = "Vec::is_empty")] data: Vec, } @@ -89,6 +92,7 @@ impl Heatmap { label: None, item_style: None, emphasis: None, + tooltip: None, data: vec![], } } @@ -173,6 +177,11 @@ impl Heatmap { self } + pub fn tooltip(mut self, tooltip: Tooltip) -> Self { + self.tooltip = Some(tooltip); + self + } + pub fn data>(mut self, data: Vec) -> Self { self.data = data.into_iter().map(|d| d.into()).collect(); self diff --git a/charming/src/series/line.rs b/charming/src/series/line.rs index 81d74fb..97131ec 100644 --- a/charming/src/series/line.rs +++ b/charming/src/series/line.rs @@ -4,7 +4,7 @@ use crate::{ datatype::{DataFrame, DataPoint}, element::{ smoothness::Smoothness, AreaStyle, CoordinateSystem, DimensionEncode, Emphasis, ItemStyle, - Label, LineStyle, MarkArea, MarkLine, MarkPoint, Symbol, SymbolSize, + Label, LineStyle, MarkArea, MarkLine, MarkPoint, Symbol, SymbolSize, Tooltip, }, }; @@ -77,6 +77,9 @@ pub struct Line { #[serde(skip_serializing_if = "Option::is_none")] y_axis_index: Option, + #[serde(skip_serializing_if = "Option::is_none")] + tooltip: Option, + #[serde(skip_serializing_if = "Vec::is_empty")] data: DataFrame, } @@ -112,6 +115,7 @@ impl Line { encode: None, x_axis_index: None, y_axis_index: None, + tooltip: None, data: vec![], } } @@ -223,6 +227,11 @@ impl Line { self } + pub fn tooltip(mut self, tooltip: Tooltip) -> Self { + self.tooltip = Some(tooltip); + self + } + pub fn data>(mut self, data: Vec) -> Self { self.data = data.into_iter().map(|d| d.into()).collect(); self diff --git a/charming/src/series/lines.rs b/charming/src/series/lines.rs index 84eee6a..4fc4ff8 100644 --- a/charming/src/series/lines.rs +++ b/charming/src/series/lines.rs @@ -2,7 +2,9 @@ use serde::Serialize; -use crate::element::{ColorBy, CoordinateSystem, Emphasis, Label, LabelLayout, LineStyle, Symbol}; +use crate::element::{ + ColorBy, CoordinateSystem, Emphasis, Label, LabelLayout, LineStyle, Symbol, Tooltip, +}; #[derive(Serialize)] #[serde(rename_all = "camelCase")] @@ -57,4 +59,7 @@ pub struct Lines { #[serde(skip_serializing_if = "Option::is_none")] emphasis: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + tooltip: Option, } diff --git a/charming/src/series/pie.rs b/charming/src/series/pie.rs index 607282c..cbaf088 100644 --- a/charming/src/series/pie.rs +++ b/charming/src/series/pie.rs @@ -2,7 +2,7 @@ use serde::Serialize; use crate::{ datatype::{CompositeValue, DataFrame, DataPoint}, - element::{ColorBy, CoordinateSystem, Emphasis, ItemStyle, Label, LabelLine}, + element::{ColorBy, CoordinateSystem, Emphasis, ItemStyle, Label, LabelLine, Tooltip}, }; #[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)] @@ -75,6 +75,9 @@ pub struct Pie { #[serde(skip_serializing_if = "Option::is_none")] radius: Option, + #[serde(skip_serializing_if = "Option::is_none")] + tooltip: Option, + #[serde(skip_serializing_if = "Vec::is_empty")] data: DataFrame, } @@ -108,6 +111,7 @@ impl Pie { emphasis: None, center: None, radius: None, + tooltip: None, data: vec![], } } @@ -207,6 +211,11 @@ impl Pie { self } + pub fn tooltip(mut self, tooltip: Tooltip) -> Self { + self.tooltip = Some(tooltip); + self + } + pub fn data>(mut self, data: Vec) -> Self { self.data = data.into_iter().map(|d| d.into()).collect(); self diff --git a/charming/src/series/sankey.rs b/charming/src/series/sankey.rs index 69db444..84c88e1 100644 --- a/charming/src/series/sankey.rs +++ b/charming/src/series/sankey.rs @@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize}; use crate::{ datatype::CompositeValue, - element::{Emphasis, ItemStyle, Label, LineStyle, Orient}, + element::{Emphasis, ItemStyle, Label, LineStyle, Orient, Tooltip}, }; #[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)] @@ -149,6 +149,9 @@ pub struct Sankey { #[serde(skip_serializing_if = "Vec::is_empty")] links: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + tooltip: Option, + #[serde(skip_serializing_if = "Vec::is_empty")] data: Vec, } @@ -180,6 +183,7 @@ impl Sankey { node_align: None, line_style: None, links: vec![], + tooltip: None, data: vec![], } } @@ -264,6 +268,11 @@ impl Sankey { self } + pub fn tooltip(mut self, tooltip: Tooltip) -> Self { + self.tooltip = Some(tooltip); + self + } + pub fn data>(mut self, data: Vec) -> Self { self.data = data.into_iter().map(|s| s.into()).collect(); self diff --git a/charming/src/series/sunburst.rs b/charming/src/series/sunburst.rs index 2b8b53a..ff30dde 100644 --- a/charming/src/series/sunburst.rs +++ b/charming/src/series/sunburst.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; -use crate::element::{Emphasis, ItemStyle, Label, Sort}; +use crate::element::{Emphasis, ItemStyle, Label, Sort, Tooltip}; #[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)] #[serde(rename_all = "camelCase")] @@ -150,6 +150,9 @@ pub struct Sunburst { #[serde(skip_serializing_if = "Vec::is_empty")] levels: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + tooltip: Option, + #[serde(skip_serializing_if = "Vec::is_empty")] data: Vec, } @@ -173,6 +176,7 @@ impl Sunburst { emphasis: None, sort: None, levels: vec![], + tooltip: None, data: vec![], } } @@ -222,6 +226,11 @@ impl Sunburst { self } + pub fn tooltip(mut self, tooltip: Tooltip) -> Self { + self.tooltip = Some(tooltip); + self + } + pub fn data(mut self, data: Vec) -> Self { self.data = data; self diff --git a/charming/src/series/theme_river.rs b/charming/src/series/theme_river.rs index bf843e5..edfcc79 100644 --- a/charming/src/series/theme_river.rs +++ b/charming/src/series/theme_river.rs @@ -2,7 +2,7 @@ use serde::{ser::SerializeSeq, Serialize}; use crate::{ datatype::CompositeValue, - element::{BoundaryGap, ColorBy, CoordinateSystem, Label}, + element::{BoundaryGap, ColorBy, CoordinateSystem, Label, Tooltip}, }; #[derive(Debug, PartialEq, PartialOrd, Clone)] @@ -90,6 +90,9 @@ pub struct ThemeRiver { #[serde(skip_serializing_if = "Option::is_none")] label: Option