Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b216d7f
feat: add DataZoom component with axis-index and mouse-modifier prope…
egenn Apr 19, 2026
ea9f530
feat: add zoom functionality and point markers to draw_line function
egenn Apr 19, 2026
8597c41
feat: add data_zoom parameter to EChartsOption for axis zoom function…
egenn Apr 19, 2026
268deca
export DataZoom
egenn Apr 19, 2026
c59bc0c
docs
egenn Apr 19, 2026
0002c02
feat: add tests for DataZoom component including validation and defau…
egenn Apr 19, 2026
de2b016
feat: add tests for data_zoom functionality in EChartsOption
egenn Apr 19, 2026
2c9d01c
feat: enhance draw_line tests for point visibility and dataZoom funct…
egenn Apr 19, 2026
7911b59
feat: add support for vertical background bands and axis limits in dr…
egenn Apr 19, 2026
3b114d1
feat: add MarkArea and MarkAreaDataPoint classes for shaded bands in …
egenn Apr 19, 2026
04b25d1
feat: add validate_axis_lim function to check axis limits for numeric…
egenn Apr 19, 2026
55f923c
docs
egenn Apr 19, 2026
139efd5
feat: add MarkArea and MarkAreaDataPoint tests for default creation a…
egenn Apr 19, 2026
06d3eab
feat: add tests for draw_line block behavior and axis limits
egenn Apr 19, 2026
9225fa8
feat: export MarkArea and MarkAreaDataPoint in NAMESPACE
egenn Apr 19, 2026
6d55fa8
cleanup
egenn Apr 19, 2026
a699109
cleanup
egenn Apr 19, 2026
4a2592c
feat: enhance draw_line and draw_scatter with default axis configurat…
egenn Apr 19, 2026
78764c1
docs
egenn Apr 19, 2026
3c88d5d
feat: add tests for draw_line and draw_scatter axis configurations
egenn Apr 19, 2026
6381cbc
feat: update axisLine configuration for draw_line and draw_scatter to…
egenn Apr 19, 2026
4c2e95c
=> echarts 6.0.0
egenn Apr 19, 2026
7363360
use outerBoundsMode
egenn Apr 19, 2026
3ba10ce
feat: enhance dataZoom serialization and add error handling for inval…
egenn Apr 19, 2026
baf508a
fix: improve error handling for xlim and block_opacity parameters in …
egenn Apr 19, 2026
a9a5b34
fix: improve validation for axis limits to ensure finite numeric values
egenn Apr 19, 2026
4986343
docs
egenn Apr 19, 2026
455ea4e
test: add tests for data_zoom handling and draw_line parameter valida…
egenn Apr 19, 2026
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Dev
__dev/
specs/

# macOS
.DS_Store
Expand Down
3 changes: 3 additions & 0 deletions r/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export(AxisLine)
export(AxisTick)
export(BarSeries)
export(BoxplotSeries)
export(DataZoom)
export(EChartsOption)
export(Grid)
export(HeatmapSeries)
Expand All @@ -16,6 +17,8 @@ export(LabelOption)
export(Legend)
export(LineSeries)
export(LineStyle)
export(MarkArea)
export(MarkAreaDataPoint)
export(MinorSplitLine)
export(MinorTick)
export(PieSeries)
Expand Down
200 changes: 200 additions & 0 deletions r/R/components.R
Original file line number Diff line number Diff line change
Expand Up @@ -424,3 +424,203 @@ VisualMap <- S7::new_class(
S7::method(to_list, VisualMap) <- function(x, ...) {
props_to_list(x)
}

# -- DataZoom -------------------------------------------------------------------

#' Axis-index property validator
#'
#' Accepts a single number, numeric vector, the literal `"all"`, or `NULL`.
#' Used by `DataZoom` axis-index slots.
#' @keywords internal
#' @noRd
axis_index_property <- function() {
S7::new_property(
class = S7::class_any,
default = NULL,
validator = function(value) {
if (is.null(value)) {
return(NULL)
}
if (is.numeric(value)) {
return(NULL)
}
if (
is.character(value) &&
length(value) == 1L &&
identical(value, "all")
) {
return(NULL)
}
"must be a number, numeric vector, 'all', or NULL"
}
)
}

#' Mouse-modifier property validator
#'
#' Accepts `TRUE`, `FALSE`, or one of `"shift"`, `"ctrl"`, `"alt"`, or `NULL`.
#' Used by the inside-zoom mouse-control slots of `DataZoom`.
#' @keywords internal
#' @noRd
mouse_modifier_property <- function() {
S7::new_property(
class = S7::class_any,
default = NULL,
validator = function(value) {
if (is.null(value)) {
return(NULL)
}
if (is.logical(value) && length(value) == 1L) {
return(NULL)
}
if (
is.character(value) &&
length(value) == 1L &&
value %in% c("shift", "ctrl", "alt")
) {
return(NULL)
}
"must be TRUE, FALSE, 'shift', 'ctrl', 'alt', or NULL"
}
)
}

#' Data Zoom
#'
#' Axis-range zoom component. ECharts renders `dataZoom` as an array; common
#' usage pairs a `"slider"` (visible scrollbar) with an `"inside"` (mouse-wheel
#' / drag) entry targeting the same axis. Unused styling / mouse-behavior
#' fields stay `NULL` and are dropped from the serialized output.
#'
#' Corresponds to `DataZoomOption` in
#' `src/component/dataZoom/DataZoomModel.ts` (line 38),
#' `SliderDataZoomOption` in `src/component/dataZoom/SliderZoomModel.ts`
#' (line 38), and `InsideDataZoomOption` in
#' `src/component/dataZoom/InsideZoomModel.ts` (line 23).
#' ECharts docs: \url{https://echarts.apache.org/en/option.html#dataZoom}
#'
#' @param type Character \{"slider", "inside"\}: Zoom type. `"slider"` shows a
#' draggable handle; `"inside"` enables zoom/drag directly on the coordinate
#' system.
#' @param id Optional Character: Component identifier used for updates.
#' @param disabled Optional Logical: Whether the component is disabled.
#' @param x_axis_index Optional Numeric, numeric vector, or Character \{"all"\}:
#' Index of the x-axis (or axes) this zoom targets.
#' @param y_axis_index Optional Numeric, numeric vector, or Character \{"all"\}:
#' Index of the y-axis (or axes) this zoom targets.
#' @param radius_axis_index Optional Numeric, numeric vector, or Character
#' \{"all"\}: Polar radius axis index.
#' @param angle_axis_index Optional Numeric, numeric vector, or Character
#' \{"all"\}: Polar angle axis index.
#' @param single_axis_index Optional Numeric, numeric vector, or Character
#' \{"all"\}: Single-axis index.
#' @param filter_mode Optional Character \{"filter", "weakFilter", "empty",
#' "none"\}: How out-of-window data points are handled.
#' @param start Optional Numeric \[0, 100\]: Left/start position as a
#' percentage of the full data range.
#' @param end Optional Numeric \[0, 100\]: Right/end position as a percentage
#' of the full data range.
#' @param start_value Optional Numeric, Character, or Date: Absolute start
#' value (alternative to `start`).
#' @param end_value Optional Numeric, Character, or Date: Absolute end value
#' (alternative to `end`).
#' @param min_span Optional Numeric \[0, 100\]: Minimum window size, as a
#' percentage.
#' @param max_span Optional Numeric \[0, 100\]: Maximum window size, as a
#' percentage.
#' @param min_value_span Optional Numeric or Character: Minimum window size in
#' data units.
#' @param max_value_span Optional Numeric or Character: Maximum window size in
#' data units.
#' @param orient Optional Character \{"horizontal", "vertical"\}: Layout
#' orientation. Defaults are inferred from the axis the zoom targets.
#' @param throttle Optional Numeric \[0, Inf): Throttle delay in milliseconds
#' for zoom events.
#' @param range_mode Optional length-2 Character vector of \{"value",
#' "percent"\}: Per-boundary interpretation for start/end.
#' @param show Optional Logical: Whether the slider is visible
#' (slider type only).
#' @param background_color Optional Character: Slider background color.
#' @param left Optional Numeric or Character: Slider left position.
#' @param right Optional Numeric or Character: Slider right position.
#' @param top Optional Numeric or Character: Slider top position.
#' @param bottom Optional Numeric or Character: Slider bottom position.
#' @param width Optional Numeric or Character: Slider width.
#' @param height Optional Numeric or Character: Slider height.
#' @param zoom_lock Optional Logical: Whether to lock the window size
#' (allow move but not zoom).
#' @param zoom_on_mouse_wheel Optional Logical or Character \{"shift", "ctrl",
#' "alt"\}: Whether/how the mouse wheel zooms (inside type only).
#' @param move_on_mouse_move Optional Logical or Character \{"shift", "ctrl",
#' "alt"\}: Whether/how mouse drag pans (inside type only).
#' @param move_on_mouse_wheel Optional Logical or Character \{"shift", "ctrl",
#' "alt"\}: Whether/how the mouse wheel pans (inside type only).
#' @param prevent_default_mouse_move Optional Logical: Whether to call
#' `event.preventDefault()` on drag (inside type only).
#' @export
DataZoom <- S7::new_class(
"DataZoom",
properties = list(
# Common (DataZoomOption)
type = enum_property(c("slider", "inside"), default = "slider"),
id = string_or_null_property(),
disabled = bool_or_null_property(),
x_axis_index = axis_index_property(),
y_axis_index = axis_index_property(),
radius_axis_index = axis_index_property(),
angle_axis_index = axis_index_property(),
single_axis_index = axis_index_property(),
filter_mode = enum_property(c(
"filter",
"weakFilter",
"empty",
"none"
)),
start = numeric_or_null_property(),
end = numeric_or_null_property(),
start_value = S7::new_property(class = S7::class_any, default = NULL),
end_value = S7::new_property(class = S7::class_any, default = NULL),
min_span = numeric_or_null_property(),
max_span = numeric_or_null_property(),
min_value_span = numeric_or_string_property(),
max_value_span = numeric_or_string_property(),
orient = enum_property(c("horizontal", "vertical")),
throttle = numeric_or_null_property(),
range_mode = S7::new_property(
class = S7::class_any,
default = NULL,
validator = function(value) {
if (is.null(value)) {
return(NULL)
}
if (
is.character(value) &&
length(value) == 2L &&
all(value %in% c("value", "percent"))
) {
return(NULL)
}
"must be a length-2 character vector of 'value'/'percent', or NULL"
}
),
# SliderDataZoomOption-specific
show = bool_or_null_property(),
background_color = color_property(),
left = numeric_or_string_property(),
right = numeric_or_string_property(),
top = numeric_or_string_property(),
bottom = numeric_or_string_property(),
width = numeric_or_string_property(),
height = numeric_or_string_property(),
zoom_lock = bool_or_null_property(),
# InsideDataZoomOption-specific
zoom_on_mouse_wheel = mouse_modifier_property(),
move_on_mouse_move = mouse_modifier_property(),
move_on_mouse_wheel = mouse_modifier_property(),
prevent_default_mouse_move = bool_or_null_property()
)
)

S7::method(to_list, DataZoom) <- function(x, ...) {
props_to_list(x)
}
Loading
Loading