Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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: 6 additions & 3 deletions crates/amalthea/src/comm/data_explorer_comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,12 @@ pub struct BackendState {
/// requests. This parameter may change.
pub connected: Option<bool>,

/// Optional experimental parameter to provide an explanation when
/// connected=false. This parameter may change.
pub error_message: Option<String>
/// Optional experimental parameter to provide an explanation when
/// connected=false. This parameter may change.
pub error_message: Option<String>,

/// Optional formatting options for frontend display
pub format_options: Option<FormatOptions>,
}

/// Schema for a column in a table
Expand Down
14 changes: 14 additions & 0 deletions crates/ark/src/data_explorer/r_data_explorer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ use crossbeam::channel::Sender;
use crossbeam::select;
use harp::exec::RFunction;
use harp::exec::RFunctionExt;
use harp::get_option;
use harp::object::RObject;
use harp::r_symbol;
use harp::table_kind;
Expand Down Expand Up @@ -1159,6 +1160,7 @@ impl RDataExplorer {
}]),
},
},
format_options: Some(Self::current_format_options()),
};
Ok(DataExplorerBackendReply::GetStateReply(state))
}
Expand Down Expand Up @@ -1299,6 +1301,18 @@ impl RDataExplorer {
// Call the conversion function with resolved sort keys
convert_to_code::convert_to_code(params, object_name, &resolved_sort_keys)
}

fn current_format_options() -> FormatOptions {
let scipen: i64 = get_option("scipen").try_into().unwrap_or(0);
let max_integral_digits = (7 + scipen).clamp(1, 20);
FormatOptions {
large_num_digits: 2,
small_num_digits: 4,
max_integral_digits,
max_value_length: 1000,
thousands_sep: None,
}
}
}

/// Open an R object in the data viewer.
Expand Down