Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/r-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@ jobs:
r-version: release
use-public-rspm: true
extra-repositories: https://rtemis-org.r-universe.dev

# Access latest packages on rtemis-org.r-universe.dev
- name: Add rtemis r-universe to repos
run: |
cat(
'options(repos = c(getOption("repos"), rtemisorg = "https://rtemis-org.r-universe.dev"))',
file = "~/.Rprofile", sep = "\n", append = TRUE
)
shell: Rscript {0}
- uses: r-lib/actions/setup-r-dependencies@v2
with:
working-directory: r
Expand Down
2 changes: 2 additions & 0 deletions r/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ __dev/
.zed/

# R
*.tar.gz
*.Rcheck/
.lintr
air.toml

Expand Down
11 changes: 6 additions & 5 deletions r/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rtemis.draw
Title: Interactive Visualization Using ECharts
Version: 0.2.1
Title: Interactive Visualization
Version: 0.2.2
Authors@R:
person(given = "E.D.", family = "Gennatas", role = c("aut", "cre", "cph"),
email = "gennatas@gmail.com",
Expand All @@ -19,19 +19,18 @@ Imports:
cli,
htmlwidgets,
jsonlite,
rtemis.core (>= 0.1.0),
rtemis (>= 1.2.4),
rtemis.core (>= 0.2.0),
S7,
signal,
viridisLite
Suggests:
knitr,
mgcv,
rmarkdown,
rtemis.a3,
testthat (>= 3.0.0)
Additional_repositories:
https://rtemis-org.r-universe.dev
VignetteBuilder: knitr
Config/testthat/edition: 3
Config/testthat/parallel: true
Collate:
Expand All @@ -50,6 +49,8 @@ Collate:
'draw.R'
'draw_a3.R'
'draw_spectrogram.R'
'draw_gantt.R'
'plot.SupervisedSession.R'
'export.R'
'zzz.R'
Config/roxygen2/version: 8.0.0
2 changes: 2 additions & 0 deletions r/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export(draw_a3)
export(draw_bar)
export(draw_boxplot)
export(draw_density)
export(draw_gantt)
export(draw_heatmap)
export(draw_histogram)
export(draw_line)
Expand All @@ -55,5 +56,6 @@ export(theme_light)
export(to_json)
export(to_list)
import(S7)
import(rtemis)
import(rtemis.core)
importFrom(stats,approx)
6 changes: 6 additions & 0 deletions r/R/axis.R
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ S7::method(to_list, AxisLabel) <- function(x, ...) {
#' @param split_line Optional [SplitLine]: Split line configuration.
#' @param minor_split_line Optional [MinorSplitLine]: Minor split line configuration.
#' @param split_area Optional [SplitArea]: Split area configuration.
#' @param axis_pointer Optional list: Interactive mouse-following axis guide
#' (`axisPointer`), e.g. `list(show = TRUE, type = "line")`. Uses
#' echarts-cased keys.
#' @param position Optional Character \{"left", "right", "top", "bottom"\}: Axis position.
#' For `yAxis`: `"left"` (default) or `"right"`. For `xAxis`: `"bottom"` (default) or `"top"`.
#' @param grid_index Optional Numeric `[0, Inf)`: Index of the grid this axis belongs to.
Expand Down Expand Up @@ -478,6 +481,9 @@ Axis <- S7::new_class(
split_line = class_or_null_property(SplitLine),
minor_split_line = class_or_null_property(MinorSplitLine),
split_area = class_or_null_property(SplitArea),
# axisPointer: interactive mouse-following guide on this axis (plain list,
# echarts-cased keys, e.g. list(show = TRUE, type = "line", label = ...)).
axis_pointer = S7::new_property(class = S7::class_any, default = NULL),
# Axis position: "left"/"right" for yAxis, "top"/"bottom" for xAxis
position = enum(c("left", "right", "top", "bottom"), nullable = TRUE),
# Multi-grid support: index of the grid this axis belongs to
Expand Down
36 changes: 33 additions & 3 deletions r/R/draw.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,44 @@ draw <- function(
# skip when `containLabel` is set explicitly (heatmap uses `containLabel =
# FALSE` for exact pixel margins).
if (!is.null(option$xAxis) || !is.null(option$yAxis)) {
# ECharts 6.1's `outerBoundsContain` decides whether a grid's outer bounds
# reserve room for the axis *name* ("all") or only the tick labels
# ("axisLabel"). Using "axisLabel" when no axis name is shown avoids a dead
# gap below the labels. Mirrors rtemislive's chartOptionBuilder.ts.
has_axis_name <- function(axis) {
if (is.null(axis)) {
return(FALSE)
}
axes <- if (is.null(names(axis))) axis else list(axis)
any(vapply(
axes,
function(a) {
nm <- a[["name"]]
is.character(nm) && length(nm) == 1L && nzchar(nm)
},
logical(1L)
))
}
outer_contain <- if (
has_axis_name(option$xAxis) || has_axis_name(option$yAxis)
) {
"all"
} else {
"axisLabel"
}
inject_obm <- function(g) {
if (is.null(g[["containLabel"]]) && is.null(g[["outerBoundsMode"]])) {
g[["outerBoundsMode"]] <- "same"
if (is.null(g[["containLabel"]])) {
if (is.null(g[["outerBoundsMode"]])) {
g[["outerBoundsMode"]] <- "same"
}
if (is.null(g[["outerBoundsContain"]])) {
g[["outerBoundsContain"]] <- outer_contain
}
}
g
}
if (is.null(option$grid)) {
option$grid <- list(outerBoundsMode = "same")
option$grid <- inject_obm(list())
} else if (is.list(option$grid) && !is.null(names(option$grid))) {
# Single grid (named list).
option$grid <- inject_obm(option$grid)
Expand Down
Loading