Closed DeepanshKhurana closed 6 months ago
I think I missed checking the locale
parameter. Part of my problem gets solved here, since the commas are visible now!
data |>
e_charts(Account) |>
e_bar(Balance) |>
e_y_axis(
formatter = e_axis_formatter(
style = "currency",
currency = "INR",
local = "en-IN")
)
However, it would still be really neat just to be able to modify the tick labels however we want, especially using a wrapper function.
Hope this is what you're after @DeepanshKhurana. I have added JS wrapper function (there is probably a better way to write this wrapper function, my JS knowledge is very limited). Feel free to update the wrapper function to include other aesthetics you might wish (commas, dollar signs etc as per your locale requirement).
set.seed(123)
df <- data.frame(
Account = LETTERS[1:6]
,Balance = rnorm(6, mean = 1000000, sd = 500000)
)
shorten_currency <- 'function (value) {
val = Math.round(value)/10000
val = val + "L"
return val
}'
df %>%
e_charts(Account) %>%
e_bar(Balance) %>%
e_y_axis(
axisLabel = list(
show = TRUE
,formatter = htmlwidgets::JS(shorten_currency)
)
)
@sactyr Thank you for this. This sets me up in a good direction. 💯
Hello 👋🏼
I have a plot that is based on currencies. I have a custom function to shorten prices based on Indian denominations. All I'm trying to do is achieve something similar to what is shown in the eCharts Documentation here.
But I cannot seem to plug it in correctly (or maybe it is not supported).
e_axis_labels
seems to be a separate functionality to only add x- and y-axis labels such as "distance" or "speed".e_y_axis
ande_y_axis_
do not seem to allow for these parameters in the formattedcurrency = "INR"
as a param in the formatterlocale
solves it, but there is still a need to be able to wrap the values in a function to display them.For reference, here is a gist with the function I'm hoping to use.
Assuming there are two columns,
Account
andBalance
, whereBalance
is numeric, I can simply create a bar chart using the following snippet.Note: The values are random here
The behaviour I am talking about is to be able to apply any function on the y-axis labels to display.
Something akin to the following,
which would give me a plot where the y-axis is processed (the screenshot below is edited with Photoshop for illustration)
Is something like this possible or in the pipeline?