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
104 changes: 84 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,43 +1,107 @@
.PHONY: format format-r document document-r install install-r test test-r
R_DIR := r
PKG := $(shell awk '/^Package:/{print $$2; exit}' $(R_DIR)/DESCRIPTION)
R ?= R
RSCRIPT ?= Rscript

# ── Format ───────────────────────────────────────────────────────────────────
msg = @printf '\033[38;2;108;163;160m[%s] %s\033[0m\n' "$$(date -u '+%Y-%m-%d %H:%M:%SZ')" "$(1)"

.DEFAULT_GOAL := help

.PHONY: help format format-r document document-r install install-r test test-r \
build build-r check check-r check-cran manual-r site site-r clean clean-r

# ── Help ─────────────────────────────────────────────────────────────────────
help:
$(call msg,Available targets:)
@printf '%s\n' \
' format Format R code with air CLI (if available)' \
' document Generate roxygen2 documentation' \
' install Document and install the R package with pak' \
' test Run testthat::test_local(stop_on_failure = TRUE)' \
' build Build the R source tarball' \
' check Run R CMD check on the built tarball' \
' check-cran Run R CMD check --as-cran' \
' site Build pkgdown site' \
' clean Remove tarballs and .Rcheck output'

# ── Format ────────────────────────────────────────────────────────────────────
format: format-r

format-r:
@echo "==> R: Formatting rtemis.draw"
cd r && air format .
$(call msg,─── Formatting $(PKG) [R]... ───)
@if command -v air >/dev/null 2>&1; then \
cd $(R_DIR) && air format .; \
else \
echo " Note: 'air' CLI not found — skipping R code formatting."; \
fi
$(call msg,Done)

# ── Document ─────────────────────────────────────────────────────────────────
# ── Document ─────────────────────────────────────────────────────────────────
document: document-r

document-r: format-r
@echo "=> R: Documenting rtemis.draw"
cd r && Rscript -e "devtools::document()"
$(call msg,─── Documenting $(PKG) [R]... ───)
cd $(R_DIR) && $(RSCRIPT) -e "roxygen2::roxygenize()"
$(call msg,Done)

# ── Document & Install ───────────────────────────────────────────────────────
# ── Install ───────────────────────────────────────────────────────────────────
install: install-r

install-r: document-r
@echo "==> R: Installing rtemis.draw"
cd r && Rscript -e "devtools::install()"
$(call msg,─── Installing $(PKG) [R]... ───)
cd $(R_DIR) && $(RSCRIPT) -e "pak::local_install(upgrade = TRUE)"
$(call msg,Done)

# ── Test ─────────────────────────────────────────────────────────────────────
# ── Test ─────────────────────────────────────────────────────────────────────
test: test-r

test-r:
@echo "==> R: Testing rtemis.draw"
cd r && Rscript -e "devtools::test(stop_on_failure = TRUE)"
$(call msg,─── Testing $(PKG) [R]... ───)
cd $(R_DIR) && $(RSCRIPT) -e "testthat::test_local(stop_on_failure = TRUE)"
$(call msg,Done)

# ── Build ─────────────────────────────────────────────────────────────────────
build: build-r

# ── Check ────────────────────────────────────────────────────────────────────
build-r: clean-r
$(call msg,─── Building $(PKG) [R]... ───)
cd $(R_DIR) && $(R) CMD build .
$(call msg,Done)

# ── Check ─────────────────────────────────────────────────────────────────────
check: check-r

check-r:
@echo "==> R: Checking rtemis.draw"
cd r && Rscript -e "devtools::check()"
check-r: build-r
$(call msg,─── Running R CMD check on $(PKG) [R]... ───)
cd $(R_DIR) && $(R) CMD check $(PKG)_*.tar.gz
rm -f $(R_DIR)/$(PKG)_*.tar.gz
$(call msg,Done)

check-cran: build-r
$(call msg,─── Running R CMD check --as-cran on $(PKG) [R]... ───)
cd $(R_DIR) && $(R) CMD check $(PKG)_*.tar.gz --as-cran
rm -f $(R_DIR)/$(PKG)_*.tar.gz
$(call msg,Done)

# ── Manual ───────────────────────────────────────────────────────────────────
manual-r:
$(call msg,─── Building manual for $(PKG)... ───)
cd $(R_DIR) && $(R) CMD Rd2pdf . --output=$(PKG).pdf
$(call msg,Done)

# ── Build Site ───────────────────────────────────────────────────────────────
# ── Site ──────────────────────────────────────────────────────────────────────
site: site-r

site-r:
@echo "==> R: Building pkgdown site for rtemis.draw"
cd r && Rscript -e "pkgdown::build_site()"
$(call msg,─── Building pkgdown site for $(PKG) [R]... ───)
cd $(R_DIR) && $(RSCRIPT) -e "pkgdown::build_site()"
$(call msg,Done)

# ── Clean ─────────────────────────────────────────────────────────────────────
clean: clean-r

clean-r:
$(call msg,─── Cleaning build artifacts [R]... ───)
rm -rf $(R_DIR)/$(PKG).Rcheck
rm -f $(R_DIR)/$(PKG)_*.tar.gz
$(call msg,Done)
8 changes: 5 additions & 3 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.1.0
Version: 0.2.1
Authors@R:
person(given = "E.D.", family = "Gennatas", role = c("aut", "cre", "cph"),
email = "gennatas@gmail.com",
Expand All @@ -15,12 +15,11 @@ URL: https://www.rtemis.org, https://docs.rtemis.org/draw/r, https://docs.rtemis
License: GPL (>= 3)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.3
Imports:
cli,
htmlwidgets,
jsonlite,
rtemis.core,
rtemis.core (>= 0.1.0),
S7,
signal,
viridisLite
Expand All @@ -36,6 +35,7 @@ VignetteBuilder: knitr
Config/testthat/edition: 3
Config/testthat/parallel: true
Collate:
'00_init.R'
'rtemis.draw-package.R'
'rtemis_color_system.R'
'utils.R'
Expand All @@ -44,10 +44,12 @@ Collate:
'axis.R'
'components.R'
'series.R'
'series_sankey.R'
'option.R'
'theme.R'
'draw.R'
'draw_a3.R'
'draw_spectrogram.R'
'export.R'
'zzz.R'
Config/roxygen2/version: 8.0.0
5 changes: 5 additions & 0 deletions r/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export(MarkAreaDataPoint)
export(MinorSplitLine)
export(MinorTick)
export(PieSeries)
export(SankeyEdgeItem)
export(SankeyLevelOption)
export(SankeyNodeItem)
export(SankeySeries)
export(ScatterSeries)
export(SplitArea)
export(SplitLine)
Expand All @@ -40,6 +44,7 @@ export(draw_heatmap)
export(draw_histogram)
export(draw_line)
export(draw_pie)
export(draw_sankey)
export(draw_scatter)
export(draw_spectrogram)
export(renderDraw)
Expand Down
28 changes: 28 additions & 0 deletions r/R/00_init.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 00_init.R
# Local property definitions that mirror upstream rtemis.core exports not yet
# on CRAN. Remove each entry here once the corresponding rtemis.core version
# is available on CRAN and declared in DESCRIPTION.

# nonneg_integer_scalar / optional_nonneg_integer_scalar
# Added to rtemis.core >= 0.1.1; mirrors 00_S7_properties.R.
nonneg_integer_scalar <- S7::new_property(
S7::class_integer,
validator = function(value) {
if (length(value) != 1L || is.na(value) || value < 0L) {
return("must be a non-negative integer scalar (>= 0, e.g. 0L)")
}
NULL
}
)

optional_nonneg_integer_scalar <- S7::new_property(
class = S7::new_union(NULL, S7::class_integer),
validator = function(value) {
if (
!is.null(value) && (length(value) != 1L || is.na(value) || value < 0L)
) {
return("must be NULL or a non-negative integer scalar (>= 0, e.g. 0L)")
}
NULL
}
)
51 changes: 27 additions & 24 deletions r/R/axis.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ AxisLine <- S7::new_class(
"must be TRUE, FALSE, 'auto', or NULL"
}
),
on_zero = bool_or_null_property(),
on_zero = optional_logical_scalar,
on_zero_axis_index = numeric_or_null_property(),
symbol = S7::new_property(
class = S7::class_any,
Expand Down Expand Up @@ -124,9 +124,9 @@ AxisTick <- S7::new_class(
"must be TRUE, FALSE, 'auto', or NULL"
}
),
inside = bool_or_null_property(),
inside = optional_logical_scalar,
length = numeric_or_null_property(),
align_with_label = bool_or_null_property(),
align_with_label = optional_logical_scalar,
line_style = class_or_null_property(LineStyle)
)
)
Expand All @@ -152,7 +152,7 @@ S7::method(to_list, AxisTick) <- function(x, ...) {
MinorTick <- S7::new_class(
"MinorTick",
properties = list(
show = bool_or_null_property(),
show = optional_logical_scalar,
split_number = numeric_or_null_property(),
length = numeric_or_null_property(),
line_style = class_or_null_property(LineStyle)
Expand Down Expand Up @@ -181,7 +181,7 @@ S7::method(to_list, MinorTick) <- function(x, ...) {
SplitLine <- S7::new_class(
"SplitLine",
properties = list(
show = bool_or_null_property(),
show = optional_logical_scalar,
interval = S7::new_property(
class = S7::class_any,
default = NULL,
Expand All @@ -198,8 +198,8 @@ SplitLine <- S7::new_class(
"must be a number, 'auto', or NULL"
}
),
show_min_line = bool_or_null_property(),
show_max_line = bool_or_null_property(),
show_min_line = optional_logical_scalar,
show_max_line = optional_logical_scalar,
line_style = class_or_null_property(LineStyle)
)
)
Expand All @@ -223,7 +223,7 @@ S7::method(to_list, SplitLine) <- function(x, ...) {
MinorSplitLine <- S7::new_class(
"MinorSplitLine",
properties = list(
show = bool_or_null_property(),
show = optional_logical_scalar,
line_style = class_or_null_property(LineStyle)
)
)
Expand All @@ -248,7 +248,7 @@ S7::method(to_list, MinorSplitLine) <- function(x, ...) {
SplitArea <- S7::new_class(
"SplitArea",
properties = list(
show = bool_or_null_property(),
show = optional_logical_scalar,
interval = S7::new_property(
class = S7::class_any,
default = NULL,
Expand Down Expand Up @@ -297,14 +297,14 @@ S7::method(to_list, SplitArea) <- function(x, ...) {
AxisLabel <- S7::new_class(
"AxisLabel",
properties = list(
show = bool_or_null_property(),
inside = bool_or_null_property(),
show = optional_logical_scalar,
inside = optional_logical_scalar,
rotate = numeric_or_null_property(),
margin = numeric_or_null_property(),
formatter = S7::new_property(class = S7::class_any, default = NULL),
show_min_label = bool_or_null_property(),
show_max_label = bool_or_null_property(),
hide_overlap = bool_or_null_property(),
show_min_label = optional_logical_scalar,
show_max_label = optional_logical_scalar,
hide_overlap = optional_logical_scalar,
interval = S7::new_property(
class = S7::class_any,
default = NULL,
Expand Down Expand Up @@ -386,16 +386,19 @@ Axis <- S7::new_class(
"Axis",
properties = list(
# AxisBaseOptionCommon
type = enum_property(c("value", "category", "time", "log")),
show = bool_or_null_property(),
inverse = bool_or_null_property(),
name = string_or_null_property(),
name_location = enum_property(c("start", "middle", "center", "end")),
type = enum(c("value", "category", "time", "log"), nullable = TRUE),
show = optional_logical_scalar,
inverse = optional_logical_scalar,
name = optional_character_scalar,
name_location = enum(
c("start", "middle", "center", "end"),
nullable = TRUE
),
name_rotate = numeric_or_null_property(),
name_gap = numeric_or_null_property(),
name_text_style = class_or_null_property(TextStyle),
silent = bool_or_null_property(),
trigger_event = bool_or_null_property(),
silent = optional_logical_scalar,
trigger_event = optional_logical_scalar,
# Min/max: number, string ("dataMin"/"dataMax"), or NULL
min = S7::new_property(
class = S7::class_any,
Expand Down Expand Up @@ -438,13 +441,13 @@ Axis <- S7::new_class(
}
),
# ValueAxisBaseOption
scale = bool_or_null_property(),
scale = optional_logical_scalar,
# NumericAxisBaseOptionCommon
split_number = numeric_or_null_property(),
interval = numeric_or_null_property(),
min_interval = numeric_or_null_property(),
max_interval = numeric_or_null_property(),
align_ticks = bool_or_null_property(),
align_ticks = optional_logical_scalar,
# LogAxisBaseOption
log_base = numeric_or_null_property(),
# CategoryAxisBaseOption: boundaryGap is boolean
Expand Down Expand Up @@ -476,7 +479,7 @@ Axis <- S7::new_class(
minor_split_line = class_or_null_property(MinorSplitLine),
split_area = class_or_null_property(SplitArea),
# Axis position: "left"/"right" for yAxis, "top"/"bottom" for xAxis
position = enum_property(c("left", "right", "top", "bottom")),
position = enum(c("left", "right", "top", "bottom"), nullable = TRUE),
# Multi-grid support: index of the grid this axis belongs to
grid_index = numeric_or_null_property()
)
Expand Down
Loading