Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: animint2
Title: Animated Interactive Grammar of Graphics
Version: 2025.10.27
Version: 2025.10.31
URL: https://animint.github.io/animint2
BugReports: https://github.com/animint/animint2/issues
Authors@R: c(
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Changes in version 2025.10.31 (PR#272)

- Download status table now displays three new columns: `total_MB` (total disk space used by all downloaded chunks), `mean_MB` (average chunk size), and `rows` (total number of data rows). Chunk sizes are calculated in R using `file.size()` and exported via plot.json for efficient display updates after each chunk download.

# Changes in version 2025.10.27 (PR#269)

- `geom_point()` default shape changed from 19 to 21 to enable both color and fill aesthetics for more consistent static rendering.
Expand Down
4 changes: 4 additions & 0 deletions R/z_animint.R
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,12 @@ storeLayer <- function(meta, g, g.data.varied){
## Save each variable chunk to a separate tsv file.
meta$chunk.i <- 1L
meta$g <- g
meta$chunk_info <- list() # Initialize chunk info storage
g$chunks <- saveChunks(g.data.varied, meta)
g$total <- length(unlist(g$chunks))

## Add chunk size information to geom
g$chunk_info <- meta$chunk_info

## Finally save to the master geom list.
meta$geoms[[g$classed]] <- g
Expand Down
14 changes: 13 additions & 1 deletion R/z_animintHelpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -917,9 +917,21 @@ saveChunks <- function(x, meta){
# fwrite defaults ensure fields are quoted so that embedded
# newlines or tabs in string fields do not break the TSV format
# when read by d3.tsv.
csv.path <- file.path(meta$out.dir, csv.name)
data.table::fwrite(
na.omit(x), file.path(meta$out.dir, csv.name),
na.omit(x), csv.path,
row.names=FALSE, sep="\t")
# Calculate chunk size and row count
chunk_bytes <- file.size(csv.path)
chunk_rows <- nrow(na.omit(x))
# Store chunk info
if(!exists("chunk_info", envir=meta)) {
meta$chunk_info <- list()
}
meta$chunk_info[[csv.name]] <- list(
bytes = chunk_bytes,
rows = chunk_rows
)
meta$chunk.i <- meta$chunk.i + 1L
this.i
}else if(is.list(x)){
Expand Down
28 changes: 28 additions & 0 deletions inst/htmljs/animint.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,15 @@ var animint = function (to_select, json_file) {
g_info.tr.append("td").attr("class", "chunk");
g_info.tr.append("td").attr("class", "downloaded").text(0);
g_info.tr.append("td").text(g_info.total);
g_info.td_total_MB = g_info.tr.append("td").attr("class", "total_MB");
g_info.td_mean_MB = g_info.tr.append("td").attr("class", "mean_MB");
g_info.td_rows = g_info.tr.append("td").attr("class", "rows");
g_info.tr.append("td").attr("class", "status").text("initialized");

// Initialize size tracking
g_info.total_bytes = 0;
g_info.total_rows = 0;
g_info.downloaded_chunks = 0;

// load chunk tsv
g_info.data = {};
Expand Down Expand Up @@ -999,6 +1007,22 @@ var animint = function (to_select, json_file) {
g_info.data[tsv_name] = chunk;
g_info.tr.select("td.downloaded").text(d3.keys(g_info.data).length);
g_info.download_status[tsv_name] = "saved";

// Update size information after download
if(g_info.chunk_info && g_info.chunk_info[tsv_name]){
var info = g_info.chunk_info[tsv_name];
g_info.total_bytes += info.bytes;
g_info.total_rows += info.rows;
g_info.downloaded_chunks += 1;

// Update display
var total_MB = (g_info.total_bytes / 1048576).toFixed(2);
var mean_MB = (g_info.total_bytes / g_info.downloaded_chunks / 1048576).toFixed(2);
g_info.td_total_MB.text(total_MB);
g_info.td_mean_MB.text(mean_MB);
g_info.td_rows.text(g_info.total_rows);
}

funAfter(chunk);
});
});
Expand All @@ -1008,6 +1032,7 @@ var animint = function (to_select, json_file) {
// data, and then calling draw_geom to actually draw it.
var draw_geom = function(g_info, chunk, selector_name, PANEL){
g_info.tr.select("td.status").text("displayed");

var svg = SVGs[g_info.classed];
// derive the plot name from the geometry name
var g_names = g_info.classed.split("_");
Expand Down Expand Up @@ -2375,6 +2400,9 @@ var animint = function (to_select, json_file) {
tr.append("th").attr("class", "chunk").text("selected chunk");
tr.append("th").attr("class", "downloaded").text("downloaded");
tr.append("th").attr("class", "total").text("total");
tr.append("th").attr("class", "total_MB").text("total_MB");
tr.append("th").attr("class", "mean_MB").text("mean_MB");
tr.append("th").attr("class", "rows").text("rows");
tr.append("th").attr("class", "status").text("status");

// Add geoms and construct nest operators.
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-download-status-table.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
test_that("download status table should show file sizes", {
js_file = system.file("htmljs", "animint.js", package="animint2")
js_text = paste(readLines(js_file), collapse=" ")
mb_columns = grep("total_MB", js_text)
expect_gt(length(mb_columns), 0)
})