Skip to content

Commit

Permalink
custom label function support added
Browse files Browse the repository at this point in the history
  • Loading branch information
rdboyes committed Apr 3, 2024
1 parent 51e294d commit 3efca51
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/scales.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ function continuous_scale_to_ggoptions(args_dict::Dict)
options_dict[args_dict["scale"] * "reversed"] = args_dict["reversed"]
end

return AxisOptions(Dict(Symbol(k) => v for (k, v) in options_dict))
if haskey(args_dict, "labels")
options_dict[Symbol(args_dict["scale"] * "tickformat")] = args_dict["labels"]
end

return AxisOptions(
Dict(Symbol(k) => v for (k, v) in options_dict)
)

end

Expand Down Expand Up @@ -50,7 +56,7 @@ end
# Generator - generates two function signatures

function scale_template(scale, f; trans = nothing, reverse = nothing)
function scale_function(args...; kwargs...)
function scale_function(args...; trans = trans, reverse = reverse, scale = scale, f = f, kwargs...)
aes_dict, args_dict = extract_aes(args, kwargs)
if !isnothing(scale)
args_dict["scale"] = scale
Expand All @@ -61,10 +67,10 @@ function scale_template(scale, f; trans = nothing, reverse = nothing)
if !isnothing(reverse)
args_dict["reversed"] = reverse
end

println(args_dict)
return f(args_dict)
end
function scale_function(plot::GGPlot, args...; kwargs...)
function scale_function(plot::GGPlot, args...; trans = trans, reverse = reverse, scale = scale, f = f, kwargs...)
aes_dict, args_dict = extract_aes(args, kwargs)
if !isnothing(scale)
args_dict["scale"] = scale
Expand All @@ -75,7 +81,7 @@ function scale_template(scale, f; trans = nothing, reverse = nothing)
if !isnothing(reverse)
args_dict["reversed"] = reverse
end

println(args_dict)
return plot + f(args_dict)
end
return scale_function
Expand Down

2 comments on commit 3efca51

@rdboyes
Copy link
Member Author

@rdboyes rdboyes commented on 3efca51 Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/104213

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.2 -m "<description of version>" 3efca51f3014d9c2f76851efc779c03cfc3264e8
git push origin v0.6.2

Please sign in to comment.