-
-
Notifications
You must be signed in to change notification settings - Fork 34
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 Plotting + Chart Library #92
Conversation
d3e7552
to
8bd9f53
Compare
39f9cbb
to
954bb94
Compare
954bb94
to
ed2733e
Compare
manual.typ
Outdated
#def-arg("epigraph", "b", | ||
[If true, fill the epigraph of the function (style key: `epigraph`)]) | ||
#def-arg("hypograph", "b", | ||
[If true, fill the hypograph of the function (style key: `hypograph`)]) | ||
#def-arg("fill", "b", | ||
[If true, fill the function (style key: `fill`)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could these options be set through style
, if the fill is none the filling operation doesn't occur?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering how to use style
in code where we have no context, as we can not get inherited style values. This means using style would not work as expected.
I have changed this a bit in the new version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking a bit more about this and I think we have a children-ctx
key that should be a function that accepts ctx. We could allow a group's body be that function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already possible, by just passing a function to a group.
But how should e.g. epigraph be set? like set-style(plot: (epigraph: red))
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The api feels a lot cleaner now and wow thoughs graphs :) However it would be good to get the styling to work in a similar manner to set-style
.
I've focused my review mostly on the design of the api in the manual. I don't mind how its been implemented in the lib files unless there is something specific you want me to look over.
manual.typ
Outdated
``` | ||
|
||
Note: You can pass `content` a function of the form `ctx => array` that returns the groups children. This way you get access to the groups context object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think having the return type array
is very clear as we don't explain anywhere that actually the draw functions return arrays that implicitly get joined. I also think we should rename content
to body
as you can't use Typst's content. Maybe just say "body
can also be function takes a single parameter, a dictionary that describes the group's current context such as styling".
We should also start making some separate developer documentation for the context dictionary but I'm not to bothered about it right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but we should first generate function docs from the code doc. I do not like having both.
manual.typ
Outdated
#def-arg("axis-style", "s?", | ||
[Axis style, either "scientific" or "school-book"]) | ||
#def-arg("..options", "any", | ||
[Axis options in the form `<axis-name>-<option>`. The possible options are: | ||
#box[ | ||
/ label : The axis label | ||
/ min: Axis min. value | ||
/ max: Axis max. value | ||
/ ticks: List of tick values or value/label tuples | ||
/ tick-step: Tick step or `none` | ||
/ minor-tick-step: Minor tick step or `none` | ||
/ decimals: Number of tick label decimal digits | ||
/ unit: Tick label suffix | ||
] | ||
]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the axes use a similar input to styling? As in nested dictionaries:
plot(
axes: (
x: (
label: "X",
...
),
y: ...
)
)
You could then allow options to be applied to both axes by allowing them in the base of the axes
dict or through a default
dict.
plot(
axes: (
// Applies to all axes
ticks: ...
// or if you want to keep axis names clear
default: (
ticks: ...
),
// An axis
y: ...
)
)
This might even allow them to be set through set-style
?t
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might also want to group tick options like step, minor-step, values etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if that is good, as it comes with no real benefit. Tikz also uses this "flat" approach, which I find is fast to type and looks a bit cleaner.
8ba953b
to
db0ad40
Compare
db0ad40
to
9fa69d0
Compare
f985100
to
2eb4377
Compare
This PR adds a plotting
plot
,chart
,axes
andpalette
library.