Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dz! macro to construct (multiple dimensions) ECharts DataFrame from any number of data vectors/ columns #100

Merged
merged 15 commits into from
Oct 28, 2024

Conversation

humphreylee
Copy link
Contributor

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.
@humphreylee humphreylee changed the title Added dz! macro into dataframe Add dz! macro into dataframe Oct 11, 2024
@LukaOber LukaOber requested a review from yuankunzhang October 11, 2024 09:33
@humphreylee humphreylee changed the title Add dz! macro into dataframe Add dz! macro to construct (multiple dimensions) ECharts DataFrame from any number of data vectors/ columns Oct 23, 2024
@LukaOber
Copy link
Collaborator

Can you provide some examples of how to use this macro?

Some small unit test to check the correct functionality would also be great.

I am not super familiar with macros that's why I am hesitant to merge this. Especially because it was generated by a LLM.

This example was built from existing example "bubble_chart.ts".
@humphreylee
Copy link
Contributor Author

humphreylee commented Oct 24, 2024

The dz! macro was developed to address the challenges of constructing ECharts dataframes with dynamic and mixed data types. While reviewing examples, I found examples in the repository typically hardcode all data directly into the chart code. Although the dataframe format is preferred by ECharts, Rust’s type system does not permit mixed data types within a single vector. An example file bubble_scater2.rs has been added to demonstrate the usage of the dz! macro with an existing example.

@humphreylee
Copy link
Contributor Author

I believed the existing df! macro could accomplish my goals, but I couldn’t get it to work as intended. I might have overlooked some nuances. Therefore, I developed the dz! macro.

@humphreylee
Copy link
Contributor Author

Added a simple dz_test.rs unit test file.

@yuankunzhang
Copy link
Owner

Overall this looks good to me, is there any particular meaning of the macro name dz!?

@humphreylee
Copy link
Contributor Author

humphreylee commented Oct 25, 2024

Overall this looks good to me, is there any particular meaning of the macro name dz!?

The naming of dz! is based on three primary considerations:

  1. The dz! macro constructs a dataframe by interleaving vectors in a zig-zag pattern, iterating row by row across multiple columns/vectors;
  2. The syntax let df = df() is frequently encountered in data manipulation libraries such as Rust Polars, R, and Pandas. Personally, I find df notation can be ambiguous and potentially overused; &
  3. df! is already in use. But dz! is cool.

@LukaOber
Copy link
Collaborator

Thank you very much for the implementation and especially for providing the tests and examples. I am also a big fan of noting down that some of the code was generated using LLM.

@LukaOber LukaOber merged commit d890161 into yuankunzhang:main Oct 28, 2024
1 of 2 checks passed
@humphreylee humphreylee mentioned this pull request Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants