Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Using class and + instead of .-chained builder for plot composition results in hard-to-use API #134

Closed
holgerbrandl opened this issue Sep 27, 2022 · 4 comments

Comments

@holgerbrandl
Copy link

Because of operator precedence, the used class approach for geoms (such as geomBar) fails to provide a convenient syntax when showing a plot. It's a confusing mix of ., +, as well as round and curly brackets:

Example

// letsplot
(df.letsPlot{ x = "status" } + geomBar ()).show()
            
// kravis for comparison
df.plot(x="status").geomBar().show()

By using a builder approach and using . for chaining (as we do in most other kotlin apis including kotlin-dataframe, a more user-friendly API experience would be possible.

@alshan
Copy link
Collaborator

alshan commented Sep 28, 2022

One solution could be to let Kravis user to replace the default Kravis charting engine with Lets-Plot at the run-time and this way to continue to to use dot-notation API if he/she wish so.

@holgerbrandl
Copy link
Author

The kravis code snippet was just meant for comparison to illustrate the differences in API readability. kravis serves a different imho very useful purpose (which is to provide a ggplot binding into kotlin), and I don't plan to change that.

@alshan
Copy link
Collaborator

alshan commented Oct 21, 2022

I understand, my line of thought was that kravis could serve two purposes as that wouldn't require significant changes in the API or documentation.
However if it couldn't then perhaps some 3rd community project could emerge providing .-based API around Lets-Plot.

@holgerbrandl
Copy link
Author

Got it. Thanks for the clarification.

I'd still be curious about general developer preference regarding . vs + builders in kotlin. To me + breathes too much R (where it was also realized by Hadley Wickham as a mistake - with %>% chaining as the correct modern alternative - but he did not want to change it in ggplot because of backward compatibility.

@JetBrains JetBrains locked and limited conversation to collaborators Jun 28, 2023
@alshan alshan converted this issue into discussion #191 Jun 28, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants