From 248554f7499e4096ddb8a53e417cb18b90dccf0c Mon Sep 17 00:00:00 2001 From: humphreylee <66808535+humphreylee@users.noreply.github.com> Date: Fri, 11 Oct 2024 10:59:00 +0800 Subject: [PATCH 01/14] Added dz! macro into dataframe The main objective of macro dz! is to transpose mixed data type vectors, aka columns or dimensions into ECharts dataframe format. --- charming/src/datatype/dataframe.rs | 66 ++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/charming/src/datatype/dataframe.rs b/charming/src/datatype/dataframe.rs index 640f2e4..52ecac3 100644 --- a/charming/src/datatype/dataframe.rs +++ b/charming/src/datatype/dataframe.rs @@ -69,3 +69,69 @@ macro_rules! df { ] }; } + +/// Code below is modified from ChatGPT generated code. +/// The main objective of macro dz! is to transpose mixed data type vectors, +/// aka columns or dimensions into ECharts dataframe format. + +#[macro_export] +macro_rules! dz { + /* + Handle named vectors + let d1 = vec![44056, 13334]; + let d2 = vec![81.8, 76.9]; + let d3 = vec![23968973, 1376048943]; + let d4 = vec!["Australia", "China"]; + let d5 = vec![2015, 2015]; + let df = dz!(d1, d2, d3, d4, d5); + >>df = [Value(Array([Number(Integer(44056)), Number(Float(81.8)), + Number(Integer(23968973)), String("Australia"), Number(Integer(2015))])), + Value(Array([Number(Integer(13334)), Number(Float(76.9)), + Number(Integer(1376048943)), String("China"), Number(Integer(2015))]))] + */ + ($($v:expr),* $(,)?) => {{ + let mut df = Vec::new(); + let mut iterators: Vec>> = vec![ + $(Box::new($v.into_iter().map(|x| $crate::datatype::CompositeValue::from(x))),)* + ]; + + let len = iterators.first().map(|v| v.size_hint().0).unwrap_or(0); + + for _ in 0..len { + let mut row = Vec::new(); + for iter in iterators.iter_mut() { + if let Some(value) = iter.next() { + row.push(value); + } + } + let z = $crate::datatype::DataPoint::from(row); + df.push(z); + } + df + }}; + + /* + Handle direct input of vectors + let df = dz!([44056, 13334], [81.8, 76.9], [23968973, 1376048943], ["Australia", "China"], [2015, 2015]); + >>df = [Value(Array([Number(Integer(44056)), Number(Float(81.8)), + Number(Integer(23968973)), String("Australia"), Number(Integer(2015))])), + Value(Array([Number(Integer(13334)), Number(Float(76.9)), + Number(Integer(1376048943)), String("China"), Number(Integer(2015))]))] + */ + ($([$($v:expr),*]),* $(,)?) => {{ + let mut df = Vec::new(); + let mut iterators: Vec<_> = vec![$(vec![$($v.into()),*].into_iter()),*]; + + let len = iterators.first().map(|v| v.len()).unwrap_or(0); + for _ in 0..len { + let mut row = Vec::new(); + for iter in &mut iterators { + if let Some($crate::datatype::CompositeValue) = iter.next() { + row.push($crate::datatype::CompositeValue); + } + } + df.push(row); + } + df + }}; +} From a834615e38d2d4cab751502951e64e10080ef1b3 Mon Sep 17 00:00:00 2001 From: humphreylee <66808535+humphreylee@users.noreply.github.com> Date: Fri, 11 Oct 2024 15:51:24 +0800 Subject: [PATCH 02/14] Attempt to fix fmt error From 3fff21f1411ef93147719915c2c9a8005a0d2841 Mon Sep 17 00:00:00 2001 From: humphreylee <66808535+humphreylee@users.noreply.github.com> Date: Fri, 11 Oct 2024 15:56:33 +0800 Subject: [PATCH 03/14] Attempt to fix fmt error 2 --- charming/src/datatype/dataframe.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/charming/src/datatype/dataframe.rs b/charming/src/datatype/dataframe.rs index 52ecac3..c34cbf6 100644 --- a/charming/src/datatype/dataframe.rs +++ b/charming/src/datatype/dataframe.rs @@ -71,8 +71,8 @@ macro_rules! df { } /// Code below is modified from ChatGPT generated code. -/// The main objective of macro dz! is to transpose mixed data type vectors, -/// aka columns or dimensions into ECharts dataframe format. +/// The main objective of macro dz! is to transpose mixed data type vectors, +/// aka columns or dimensions into ECharts dataframe format. #[macro_export] macro_rules! dz { @@ -84,9 +84,9 @@ macro_rules! dz { let d4 = vec!["Australia", "China"]; let d5 = vec![2015, 2015]; let df = dz!(d1, d2, d3, d4, d5); - >>df = [Value(Array([Number(Integer(44056)), Number(Float(81.8)), - Number(Integer(23968973)), String("Australia"), Number(Integer(2015))])), - Value(Array([Number(Integer(13334)), Number(Float(76.9)), + >>df = [Value(Array([Number(Integer(44056)), Number(Float(81.8)), + Number(Integer(23968973)), String("Australia"), Number(Integer(2015))])), + Value(Array([Number(Integer(13334)), Number(Float(76.9)), Number(Integer(1376048943)), String("China"), Number(Integer(2015))]))] */ ($($v:expr),* $(,)?) => {{ @@ -94,7 +94,7 @@ macro_rules! dz { let mut iterators: Vec>> = vec![ $(Box::new($v.into_iter().map(|x| $crate::datatype::CompositeValue::from(x))),)* ]; - + let len = iterators.first().map(|v| v.size_hint().0).unwrap_or(0); for _ in 0..len { @@ -109,13 +109,13 @@ macro_rules! dz { } df }}; - + /* Handle direct input of vectors let df = dz!([44056, 13334], [81.8, 76.9], [23968973, 1376048943], ["Australia", "China"], [2015, 2015]); - >>df = [Value(Array([Number(Integer(44056)), Number(Float(81.8)), - Number(Integer(23968973)), String("Australia"), Number(Integer(2015))])), - Value(Array([Number(Integer(13334)), Number(Float(76.9)), + >>df = [Value(Array([Number(Integer(44056)), Number(Float(81.8)), + Number(Integer(23968973)), String("Australia"), Number(Integer(2015))])), + Value(Array([Number(Integer(13334)), Number(Float(76.9)), Number(Integer(1376048943)), String("China"), Number(Integer(2015))]))] */ ($([$($v:expr),*]),* $(,)?) => {{ From 1542720a300c144e204ebac02cf9d376d95b3e96 Mon Sep 17 00:00:00 2001 From: humphreylee <66808535+humphreylee@users.noreply.github.com> Date: Thu, 24 Oct 2024 08:47:23 +0800 Subject: [PATCH 04/14] Added dz! macro usage example This example was built from existing example "bubble_chart.ts". --- gallery/src/scatter/bubble_chart2.rs.rs | 174 ++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 gallery/src/scatter/bubble_chart2.rs.rs diff --git a/gallery/src/scatter/bubble_chart2.rs.rs b/gallery/src/scatter/bubble_chart2.rs.rs new file mode 100644 index 0000000..9cf136c --- /dev/null +++ b/gallery/src/scatter/bubble_chart2.rs.rs @@ -0,0 +1,174 @@ +use charming::{ + component::{Axis, Grid, Legend, Title}, + df, dz, + element::{ + Color, ColorStop, Emphasis, EmphasisFocus, Formatter, ItemStyle, Label, LabelPosition, + LineStyle, LineStyleType, SplitLine, + }, + series::Scatter, + Chart, + HtmlRenderer, +}; + +fn main() { + let chartx = chart(); + let mut renderer = HtmlRenderer::new("My Chart", 1000, 800); + renderer.save(&chartx, "./chart.html").unwrap(); + +} + +pub fn chart() -> Chart { + /* + let data0 = df![ + [28604, 77, 17096869, "Australia", 1990], + [31163, 77.4, 27662440, "Canada", 1990], + [1516, 68, 1154605773, "China", 1990], + [13670, 74.7, 10582082, "Cuba", 1990], + [28599, 75, 4986705, "Finland", 1990], + [29476, 77.1, 56943299, "France", 1990], + [31476, 75.4, 78958237, "Germany", 1990], + [28666, 78.1, 254830, "Iceland", 1990], + [1777, 57.7, 870601776, "India", 1990], + [29550, 79.1, 122249285, "Japan", 1990], + [2076, 67.9, 20194354, "North Korea", 1990], + [12087, 72, 42972254, "South Korea", 1990], + [24021, 75.4, 3397534, "New Zealand", 1990], + [43296, 76.8, 4240375, "Norway", 1990], + [10088, 70.8, 38195258, "Poland", 1990], + [19349, 69.6, 147568552, "Russia", 1990], + [10670, 67.3, 53994605, "Turkey", 1990], + [26424, 75.7, 57110117, "United Kingdom", 1990], + [37062, 75.4, 252847810, "United States", 1990] + ]; + let data1 = df![ + [44056, 81.8, 23968973, "Australia", 2015], + [43294, 81.7, 35939927, "Canada", 2015], + [13334, 76.9, 1376048943, "China", 2015], + [21291, 78.5, 11389562, "Cuba", 2015], + [38923, 80.8, 5503457, "Finland", 2015], + [37599, 81.9, 64395345, "France", 2015], + [44053, 81.1, 80688545, "Germany", 2015], + [42182, 82.8, 329425, "Iceland", 2015], + [5903, 66.8, 1311050527, "India", 2015], + [36162, 83.5, 126573481, "Japan", 2015], + [1390, 71.4, 25155317, "North Korea", 2015], + [34644, 80.7, 50293439, "South Korea", 2015], + [34186, 80.6, 4528526, "New Zealand", 2015], + [64304, 81.6, 5210967, "Norway", 2015], + [24787, 77.3, 38611794, "Poland", 2015], + [23038, 73.13, 143456918, "Russia", 2015], + [19360, 76.5, 78665830, "Turkey", 2015], + [38225, 81.4, 64715810, "United Kingdom", 2015], + [53354, 79.1, 321773631, "United States", 2015] + ]; + */ + let data0_gdp = vec![28604, 31163, 1516, 13670, 28599, 29476, 31476, 28666, 1777, 29550, 2076, 12087, 24021, 43296, 10088, 19349, 10670, 26424, 37062]; + let data0_expectancy = vec![77.0, 77.4, 68.0, 74.7, 75.0, 77.1, 75.4, 78.1, 57.7, 79.1, 67.9, 72.0, 75.4, 76.8, 70.8, 69.6, 67.3, 75.7, 75.4]; + let data0_population = vec![17096869, 27662440, 1154605773, 10582082, 4986705, 56943299, 78958237, 254830, 870601776, 122249285, 20194354, 42972254, 3397534, 4240375, 38195258, 147568552, 53994605, 57110117, 252847810]; + let data0_country = vec!["Australia", "Canada", "China", "Cuba", "Finland", "France", "Germany", "Iceland", "India", "Japan", "North Korea", "South Korea", "New Zealand", "Norway", "Poland", "Russia", "Turkey", "United Kingdom", "United States"]; + let data0_year = vec![1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990]; + + let data1_gdp = vec![44056, 43294, 13334, 21291, 38923, 37599, 44053, 42182, 5903, 36162, 1390, 34644, 34186, 64304, 24787, 23038, 19360, 38225, 53354]; + let data1_expectancy = vec![81.8, 81.7, 76.9, 78.5, 80.8, 81.9, 81.1, 82.8, 66.8, 83.5, 71.4, 80.7, 80.6, 81.6, 77.3, 73.13, 76.5, 81.4, 79.1]; + let data1_population = vec![23968973, 35939927, 1376048943, 11389562, 5503457, 64395345, 80688545, 329425, 1311050527, 126573481, 25155317, 50293439, 4528526, 5210967, 38611794, 143456918, 78665830, 64715810, 321773631]; + let data1_country = vec!["Australia", "Canada", "China", "Cuba", "Finland", "France", "Germany", "Iceland", "India", "Japan", "North Korea", "South Korea", "New Zealand", "Norway", "Poland", "Russia", "Turkey", "United Kingdom", "United States"]; + let data1_year = vec![2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015]; + + let data0 = dz!(data0_gdp, data0_expectancy, data0_population, data0_country, data0_year); + let data1 = dz!(data1_gdp, data1_expectancy, data1_population, data1_country, data1_year); + + Chart::new() + .title( + Title::new() + .text("Life Expectancy and GDP by Country") + .left("5%") + .top("3%"), + ) + .legend( + Legend::new() + .right("10%") + .top("3%") + .data(vec!["1990", "2015"]), + ) + .grid(Grid::new().left("8%").top("10%")) + .background_color(Color::RadialGradient { + x: 0.3, + y: 0.3, + r: 0.8, + color_stops: vec![ColorStop::new(0, "#f7f8fa"), ColorStop::new(1, "#cdd0d5")], + }) + .x_axis( + Axis::new().split_line( + SplitLine::new().line_style(LineStyle::new().type_(LineStyleType::Dashed)), + ), + ) + .y_axis( + Axis::new() + .split_line( + SplitLine::new().line_style(LineStyle::new().type_(LineStyleType::Dashed)), + ) + .scale(true), + ) + .series( + Scatter::new() + .name("1990") + .data(data0) + .symbol_size("function (data) { return Math.sqrt(data[2]) / 5e2; }") + .emphasis( + Emphasis::new().focus(EmphasisFocus::Series).label( + Label::new() + .show(true) + .formatter(Formatter::Function( + "function (param) { return param.data[3]; }".into(), + )) + .position(LabelPosition::Top), + ), + ) + .item_style( + ItemStyle::new() + .shadow_blur(10) + .shadow_color("rgba(120, 36, 50, 0.5)") + .shadow_offset_y(5) + .color(Color::RadialGradient { + x: 0.4, + y: 0.3, + r: 1., + color_stops: vec![ + ColorStop::new(0, "rgb(251, 118, 123)"), + ColorStop::new(1, "rgb(204, 46, 72)"), + ], + }), + ), + ) + .series( + Scatter::new() + .name("2015") + .data(data1) + .symbol_size("function (data) { return Math.sqrt(data[2]) / 5e2; }") + .emphasis( + Emphasis::new().focus(EmphasisFocus::Series).label( + Label::new() + .show(true) + .formatter(Formatter::Function( + "function (param) { return param.data[3]; }".into(), + )) + .position(LabelPosition::Top), + ), + ) + .item_style( + ItemStyle::new() + .shadow_blur(10) + .shadow_color("rgba(25, 100, 150, 0.5)") + .shadow_offset_y(5) + .color(Color::RadialGradient { + x: 0.4, + y: 0.3, + r: 1., + color_stops: vec![ + ColorStop::new(0, "rgb(129, 227, 238)"), + ColorStop::new(1, "rgb(25, 183, 207)"), + ], + }), + ), + ) +} \ No newline at end of file From 4a54d87dcfcd869852ac75f0daf9eafd76bc8d74 Mon Sep 17 00:00:00 2001 From: humphreylee <66808535+humphreylee@users.noreply.github.com> Date: Thu, 24 Oct 2024 10:37:25 +0800 Subject: [PATCH 05/14] dz macro test --- charming/tests/dz_test.rs | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 charming/tests/dz_test.rs diff --git a/charming/tests/dz_test.rs b/charming/tests/dz_test.rs new file mode 100644 index 0000000..898780c --- /dev/null +++ b/charming/tests/dz_test.rs @@ -0,0 +1,44 @@ +/* +use charming::datatype::DataFrame; +use charming::dz; + +use charming::component::Type::Value; +use charming::datatype::DataPoint::Value; +use charming::element::AxisType::Value; +use charming::element::Color::Value; +use charming::datatype::CompositeValue::Array; +use serde_json::Value::Array; +use charming::datatype::CompositeValue::String; +use charming::element::Formatter::String; +use serde_json::Value::String; +use charming::datatype::NumericValue::Integer; +use charming::datatype::CompositeValue::Number; +use charming::datatype::DimensionType::Number; +use charming::element::SymbolSize::Number; +use serde_json::Value::Number; +use charming::datatype::NumericValue::Integer; +use charming::datatype::DimensionType::Float; +use charming::datatype::NumericValue::Float; +*/ + +#[cfg(test)] +mod tests { + + fn dz_macro_case_1() { + // Set up test data + let d1 = vec![44056, 13334]; + let d2 = vec![81.8, 76.9]; + let d3 = vec![23968973, 1376048943]; + let d4 = vec!["Australia", "China"]; + let d5 = vec![2015, 2015]; + + // expected output + let expected_output: DataFrame = [Value(Array([Number(Integer(44056)), Number(Float(81.8)), Number(Integer(23968973)), String("Australia"), Number(Integer(2015))])), Value(Array([Number(Integer(13334)), Number(Float(76.9)), Number(Integer(1376048943)), String("China"), Number(Integer(2015))]))]; + + // Call the macro + let df = dz!(d1, d2, d3, d4, d5); + + // Assert expected output + assert_eq!(df, expected_output); + } +} \ No newline at end of file From 413e836bf30bf11bbf4883040a557236500a30cc Mon Sep 17 00:00:00 2001 From: humphreylee <66808535+humphreylee@users.noreply.github.com> Date: Thu, 24 Oct 2024 11:35:00 +0800 Subject: [PATCH 06/14] Added dz! test --- charming/tests/dz_test.rs | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/charming/tests/dz_test.rs b/charming/tests/dz_test.rs index 898780c..25f8dbe 100644 --- a/charming/tests/dz_test.rs +++ b/charming/tests/dz_test.rs @@ -1,30 +1,9 @@ -/* -use charming::datatype::DataFrame; -use charming::dz; - -use charming::component::Type::Value; -use charming::datatype::DataPoint::Value; -use charming::element::AxisType::Value; -use charming::element::Color::Value; -use charming::datatype::CompositeValue::Array; -use serde_json::Value::Array; -use charming::datatype::CompositeValue::String; -use charming::element::Formatter::String; -use serde_json::Value::String; -use charming::datatype::NumericValue::Integer; -use charming::datatype::CompositeValue::Number; -use charming::datatype::DimensionType::Number; -use charming::element::SymbolSize::Number; -use serde_json::Value::Number; -use charming::datatype::NumericValue::Integer; -use charming::datatype::DimensionType::Float; -use charming::datatype::NumericValue::Float; -*/ - #[cfg(test)] mod tests { - fn dz_macro_case_1() { + use charming::{dz, df}; + #[test] + fn dz_test1() { // Set up test data let d1 = vec![44056, 13334]; let d2 = vec![81.8, 76.9]; @@ -33,12 +12,15 @@ mod tests { let d5 = vec![2015, 2015]; // expected output - let expected_output: DataFrame = [Value(Array([Number(Integer(44056)), Number(Float(81.8)), Number(Integer(23968973)), String("Australia"), Number(Integer(2015))])), Value(Array([Number(Integer(13334)), Number(Float(76.9)), Number(Integer(1376048943)), String("China"), Number(Integer(2015))]))]; + let df_out = df![ + [44056, 81.8, 23968973, "Australia", 2015], + [13334, 76.9, 1376048943, "China", 2015] + ]; // Call the macro - let df = dz!(d1, d2, d3, d4, d5); + let dz_out = dz!(d1, d2, d3, d4, d5); // Assert expected output - assert_eq!(df, expected_output); + assert_eq!(dz_out, df_out); } } \ No newline at end of file From b46a613f8c504789aeb4b98b931942d5a42929f8 Mon Sep 17 00:00:00 2001 From: humphreylee <66808535+humphreylee@users.noreply.github.com> Date: Thu, 24 Oct 2024 11:41:16 +0800 Subject: [PATCH 07/14] Fix fmt warning. --- charming/tests/dz_test.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/charming/tests/dz_test.rs b/charming/tests/dz_test.rs index 25f8dbe..a289c72 100644 --- a/charming/tests/dz_test.rs +++ b/charming/tests/dz_test.rs @@ -1,7 +1,8 @@ #[cfg(test)] mod tests { - use charming::{dz, df}; + use charming::{df, dz}; + #[test] fn dz_test1() { // Set up test data @@ -23,4 +24,4 @@ mod tests { // Assert expected output assert_eq!(dz_out, df_out); } -} \ No newline at end of file +} From b2440d0d6bafef2f5c1938c4680d776b097ec6af Mon Sep 17 00:00:00 2001 From: humphreylee <66808535+humphreylee@users.noreply.github.com> Date: Thu, 24 Oct 2024 11:42:32 +0800 Subject: [PATCH 08/14] Fix fmt warning 2. --- charming/tests/dz_test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charming/tests/dz_test.rs b/charming/tests/dz_test.rs index a289c72..7802a8b 100644 --- a/charming/tests/dz_test.rs +++ b/charming/tests/dz_test.rs @@ -2,7 +2,7 @@ mod tests { use charming::{df, dz}; - + #[test] fn dz_test1() { // Set up test data From 177863aa7ffb3445abb116c721ad7946278aee50 Mon Sep 17 00:00:00 2001 From: humphreylee <66808535+humphreylee@users.noreply.github.com> Date: Thu, 24 Oct 2024 13:22:48 +0800 Subject: [PATCH 09/14] Added dz_test2 into dz_test.rs --- charming/tests/dz_test.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/charming/tests/dz_test.rs b/charming/tests/dz_test.rs index 7802a8b..f624e39 100644 --- a/charming/tests/dz_test.rs +++ b/charming/tests/dz_test.rs @@ -24,4 +24,19 @@ mod tests { // Assert expected output assert_eq!(dz_out, df_out); } + + #[test] + fn dz_test2() { + // expected output + let df_out = df![ + [44056, 81.8, 23968973, "Australia", 2015], + [13334, 76.9, 1376048943, "China", 2015] + ]; + + // Call the macro + let dz_out = dz!([44056, 13334], [81.8, 76.9], [23968973, 1376048943], ["Australia", "China"], [2015, 2015]);; + + // Assert expected output + assert_eq!(dz_out, df_out); + } } From 6a5ab3d792758907dea342df0721f806cee81fd7 Mon Sep 17 00:00:00 2001 From: humphreylee <66808535+humphreylee@users.noreply.github.com> Date: Thu, 24 Oct 2024 13:27:23 +0800 Subject: [PATCH 10/14] Fix fmt warning --- charming/tests/dz_test.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/charming/tests/dz_test.rs b/charming/tests/dz_test.rs index f624e39..f3bae32 100644 --- a/charming/tests/dz_test.rs +++ b/charming/tests/dz_test.rs @@ -34,7 +34,13 @@ mod tests { ]; // Call the macro - let dz_out = dz!([44056, 13334], [81.8, 76.9], [23968973, 1376048943], ["Australia", "China"], [2015, 2015]);; + let dz_out = dz!( + [44056, 13334], + [81.8, 76.9], + [23968973, 1376048943], + ["Australia", "China"], + [2015, 2015] + ); // Assert expected output assert_eq!(dz_out, df_out); From b8f70bb03d9419f85152f52070ca72ce05978fe1 Mon Sep 17 00:00:00 2001 From: humphreylee <66808535+humphreylee@users.noreply.github.com> Date: Thu, 24 Oct 2024 13:29:29 +0800 Subject: [PATCH 11/14] Fix fmt warning --- charming/tests/dz_test.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/charming/tests/dz_test.rs b/charming/tests/dz_test.rs index f3bae32..493da3a 100644 --- a/charming/tests/dz_test.rs +++ b/charming/tests/dz_test.rs @@ -35,10 +35,10 @@ mod tests { // Call the macro let dz_out = dz!( - [44056, 13334], - [81.8, 76.9], - [23968973, 1376048943], - ["Australia", "China"], + [44056, 13334], + [81.8, 76.9], + [23968973, 1376048943], + ["Australia", "China"], [2015, 2015] ); From b5cb735ea9e441714c295ead34e78700aae0f47f Mon Sep 17 00:00:00 2001 From: humphreylee <66808535+humphreylee@users.noreply.github.com> Date: Thu, 24 Oct 2024 13:58:46 +0800 Subject: [PATCH 12/14] Added some documentation into dz_test.rs --- charming/tests/dz_test.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/charming/tests/dz_test.rs b/charming/tests/dz_test.rs index 493da3a..f45ef5d 100644 --- a/charming/tests/dz_test.rs +++ b/charming/tests/dz_test.rs @@ -3,6 +3,11 @@ mod tests { use charming::{df, dz}; + /// Testing using snippt of data from https://github.com/yuankunzhang/charming/blob/main/gallery/src/scatter/bubble_chart.rs. + /// dz_test1 is testing input as named_variable of various data type vectors. + /// dz_test2 is testing input as direct input of various data type vectors. + /// The result of dz! are checked againt df!'s result - which should be equal. + #[test] fn dz_test1() { // Set up test data From 9551f09087e921e7cf5bb5fe10205a9b63fddc4c Mon Sep 17 00:00:00 2001 From: humphreylee <66808535+humphreylee@users.noreply.github.com> Date: Thu, 24 Oct 2024 14:00:07 +0800 Subject: [PATCH 13/14] Fix fmt warning --- charming/tests/dz_test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charming/tests/dz_test.rs b/charming/tests/dz_test.rs index f45ef5d..d46453b 100644 --- a/charming/tests/dz_test.rs +++ b/charming/tests/dz_test.rs @@ -7,7 +7,7 @@ mod tests { /// dz_test1 is testing input as named_variable of various data type vectors. /// dz_test2 is testing input as direct input of various data type vectors. /// The result of dz! are checked againt df!'s result - which should be equal. - + #[test] fn dz_test1() { // Set up test data From fd86e46130b02fee3c277eb4896f4fff0c5aaf88 Mon Sep 17 00:00:00 2001 From: humphreylee <66808535+humphreylee@users.noreply.github.com> Date: Fri, 25 Oct 2024 07:39:00 +0800 Subject: [PATCH 14/14] Added minor documentation to dz! --- charming/src/datatype/dataframe.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charming/src/datatype/dataframe.rs b/charming/src/datatype/dataframe.rs index c34cbf6..39a4a8a 100644 --- a/charming/src/datatype/dataframe.rs +++ b/charming/src/datatype/dataframe.rs @@ -70,7 +70,7 @@ macro_rules! df { }; } -/// Code below is modified from ChatGPT generated code. +/// Code below is modified (using df! as reference) from ChatGPT generated code. /// The main objective of macro dz! is to transpose mixed data type vectors, /// aka columns or dimensions into ECharts dataframe format.