diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index fe48f28952..85a2543a6a 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -592,6 +592,7 @@ pub fn accepts_field(d: &Dialog, field: &str) -> bool { /// Options setting set this way for several rows is sent to every row (Template also sets Lock /// and Dim Images, as its checkbox does). A DXF Options preset set this way sets its fields, as /// one picked from its menu does, and the preset it shows follows the DXF options set this way. +/// A Graph Data Column Width set this way sets every column, as Cell Style's does. pub fn set_field(d: &mut Dialog, field: String, value: Value) { if d.kind == brush_options::KIND { brush_art_options::note_set(d, &field); @@ -606,10 +607,14 @@ pub fn set_field(d: &mut Dialog, field: String, value: Value) { crate::prefs_dialog::note_set(d, &field, &value); } let dxf = (d.kind == dxf_options::KIND).then(|| field.clone()); + let graph = (d.kind == graph_data::KIND).then(|| field.clone()); d.fields.insert(field, value); if let Some(field) = dxf { dxf_options::note_set(d, &field); } + if let Some(field) = graph { + graph_data::note_set(d, &field); + } } /// The fields `ui.dialog.set` can set on `d`, sorted: those it holds other than its `__` ones, the diff --git a/crates/ui-egui/src/dialogs/graph_data.rs b/crates/ui-egui/src/dialogs/graph_data.rs index ecfb0c303e..90cc7d9f55 100644 --- a/crates/ui-egui/src/dialogs/graph_data.rs +++ b/crates/ui-egui/src/dialogs/graph_data.rs @@ -7,13 +7,15 @@ //! don't move the caret in the entry box). Pasting tab- or line-separated text fills the cells from //! the picked one. Import Data reads a tab-separated text file, Transpose row/column swaps rows and //! columns, Switch x/y swaps a scatter graph's y and x columns, Cell Style sets the number of -//! decimals the sheet shows and its columns' width, and Revert reads the graph's data again. Apply -//! (`graph.setData` with its series, categories and rows) redraws the graph and leaves the window -//! open. +//! decimals the sheet shows and the width of every column, dragging a column's right edge sets that +//! column's width (in whole digits, 0 to 20, as Cell Style), and Revert reads the graph's data +//! again. Apply (`graph.setData` with its series, categories and rows) redraws the graph and leaves +//! the window open. //! //! Fields: `grid` (rows of cell texts), `sel` ([row, column]), `entry` (the picked cell's text -//! being edited), `decimals` (null: as typed), `width` (digits), `__graph` (the graph's id) and -//! `__scatter`. +//! being edited), `decimals` (null: as typed), `width` (digits), `widths` (a column's own width in +//! digits by its index, null or missing: `width`; setting `width` empties it), `__graph` (the graph's +//! id) and `__scatter`. use serde_json::{Value, json}; use vectorcraft_doc::{MAX_GRAPH_CATEGORIES, MAX_GRAPH_SERIES}; @@ -62,7 +64,7 @@ pub fn open(app: &mut VectorcraftApp) -> Result { let entry = cell(&grid, 0, 1); app.ui.dialog = Some(Dialog::new( KIND, - json!({ "grid": grid, "sel": [0, 1], "entry": entry, "decimals": null, "width": 7, "__graph": id, "__scatter": scatter }), + json!({ "grid": grid, "sel": [0, 1], "entry": entry, "decimals": null, "width": 7, "widths": [], "__graph": id, "__scatter": scatter }), )); Ok(Value::Null) } @@ -355,7 +357,7 @@ fn import(app: &mut VectorcraftApp, d: &mut Dialog) -> Result<(), String> { } /// Draw the graph-data sheet: keyboard cell movement, block paste, import, transpose, switch-x/y -/// and revert actions, decimals and column width, and only the cells in view. +/// and revert actions, decimals and column widths, and only the cells in view. fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { let entry_id = egui::Id::unique("graph-data-entry"); if ui.memory(|m| m.has_focus(entry_id)) { @@ -435,37 +437,20 @@ fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { ui.add_space(12.0); widgets::dim_label(ui, tl!("Column Width:")); let mut w = d.fields.get("width").and_then(Value::as_u64).unwrap_or(7); - if ui.add(egui::DragValue::new(&mut w).range(0..=MAX_WIDTH)).changed() { - d.fields.insert("width".into(), json!(w)); + let r = ui.add(egui::DragValue::new(&mut w).range(0..=MAX_WIDTH)); + // A value entered with Enter sets every column, also when it is the width shown. Leaving the + // field without a new value keeps the columns' own widths. + if r.changed() || (r.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter))) { + set_width(d, w); } }); ui.add_space(6.0); - let at = sel(d); - let (rows, cols) = extent(d, at); - let decimals = d.fields.get("decimals").and_then(Value::as_u64); - let w = (d.fields.get("width").and_then(Value::as_u64).unwrap_or(7).min(MAX_WIDTH) as f32 * 7.0 + 10.0).max(12.0); - let mut clicked = None; - widgets::list_box(ui, |ui| { - // Only the cells in view are drawn: a graph's sheet can be 10,001 × 257. - egui::ScrollArea::both().id_salt("graph-data-sheet").max_height(280.0).auto_shrink([false, false]).show_viewport(ui, |ui, view| { - let (cw, ch) = (w + 1.0, ROW_H); - ui.set_min_size(egui::vec2(cols as f32 * cw, rows as f32 * ch)); - let origin = ui.max_rect().min; - let span = |lo: f32, hi: f32, size: f32, n: usize| ((lo / size).floor().max(0.0) as usize, ((hi / size).ceil().max(0.0) as usize).min(n)); - let (r0, r1) = span(view.min.y, view.max.y, ch, rows); - let (c0, c1) = span(view.min.x, view.max.x, cw, cols); - for r in r0..r1 { - for c in c0..c1 { - let rect = egui::Rect::from_min_size(origin + egui::vec2(c as f32 * cw, r as f32 * ch), egui::vec2(w, ch - 1.0)); - let text = shown(cell_at(d, r, c), decimals); - let b = egui::Button::selectable((r, c) == at, egui::RichText::new(text).monospace()).truncate(); - if ui.put(rect, b).clicked() && (r, c) != (0, 0) { - clicked = Some((r, c)); - } - } - } - }); - }); + let (clicked, resized) = sheet(ui, d); + if let Some((c, n)) = resized + && n != col_digits(d, c) + { + set_col_digits(d, c, n); + } if let Some(to) = clicked { pick(d, to); ui.memory_mut(|mem| mem.request_focus(entry_id)); @@ -479,6 +464,143 @@ fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { false } +/// Cell Style's Column Width in digits. +fn width(d: &Dialog) -> u64 { + d.fields.get("width").and_then(Value::as_u64).unwrap_or(7).min(MAX_WIDTH) +} + +/// A column's width in digits: its own when its edge was dragged, else Cell Style's. +fn col_digits(d: &Dialog, c: usize) -> u64 { + d.fields.get("widths").and_then(|w| w.get(c)).and_then(Value::as_u64).unwrap_or_else(|| width(d)).min(MAX_WIDTH) +} + +/// Cell Style's Column Width: every column `n` digits wide, the ones given their own width too. +fn set_width(d: &mut Dialog, n: u64) { + d.fields.insert("width".into(), json!(n.min(MAX_WIDTH))); + note_set(d, "width"); +} + +/// `ui.dialog.set` set `field`: a Column Width sets every column, as Cell Style's does. +pub(super) fn note_set(d: &mut Dialog, field: &str) { + if field == "width" { + d.fields.insert("widths".into(), json!([])); + } +} + +/// Set column `c`'s own width in digits (at most MAX_WIDTH). +fn set_col_digits(d: &mut Dialog, c: usize, n: u64) { + if c >= MAX_COLS { + return; + } + let widths = d.fields.entry("widths").or_insert_with(|| json!([])); + if !widths.is_array() { + *widths = json!([]); + } + let Some(widths) = widths.as_array_mut() else { return }; + if widths.len() <= c { + widths.resize(c + 1, Value::Null); + } + if let Some(w) = widths.get_mut(c) { + *w = json!(n.min(MAX_WIDTH)); + } +} + +/// A column `n` digits wide, in points on the sheet. +fn digits_px(n: u64) -> f32 { + (n.min(MAX_WIDTH) as f32 * 7.0 + 10.0).max(12.0) +} + +/// The width in digits nearest to `px` points, within Cell Style's 0 to MAX_WIDTH. +fn px_digits(px: f32) -> u64 { + if px.is_finite() { ((px - 10.0) / 7.0).round().clamp(0.0, MAX_WIDTH as f32) as u64 } else { 0 } +} + +/// The id of column `c`'s right edge on the sheet. +fn edge_id(c: usize) -> egui::Id { + egui::Id::unique(("graph-data-column-edge", c)) +} + +/// The cell clicked on the sheet ([row, column]), and the column whose edge is dragged with its width +/// in digits. +type SheetInput = (Option<(usize, usize)>, Option<(usize, u64)>); + +/// Draw the sheet's cells in view, each column at its own width. Returns the cell clicked, and the +/// column whose right edge is being dragged with the width in digits the pointer gives it. +fn sheet(ui: &mut egui::Ui, d: &Dialog) -> SheetInput { + let at = sel(d); + let (rows, cols) = extent(d, at); + let decimals = d.fields.get("decimals").and_then(Value::as_u64); + // Each column's left edge, and the sheet's width last: a column is its width and a 1-point gap. + let mut xs = Vec::with_capacity(cols + 1); + let mut x = 0.0; + xs.push(x); + for c in 0..cols { + x += digits_px(col_digits(d, c)) + 1.0; + xs.push(x); + } + let left = |c: usize| xs.get(c).copied().unwrap_or(x); + let (mut clicked, mut resized) = (None, None); + widgets::list_box(ui, |ui| { + // Only the cells in view are drawn: a graph's sheet can be 10,001 × 257. + egui::ScrollArea::both().id_salt("graph-data-sheet").max_height(280.0).auto_shrink([false, false]).show_viewport(ui, |ui, view| { + let ch = ROW_H; + ui.set_min_size(egui::vec2(x, rows as f32 * ch)); + let origin = ui.max_rect().min; + let (r0, r1) = ((view.min.y / ch).floor().max(0.0) as usize, ((view.max.y / ch).ceil().max(0.0) as usize).min(rows)); + // The columns that reach into the view. + let c0 = (0..cols).find(|&c| left(c + 1) > view.min.x).unwrap_or(cols); + let c1 = (c0..cols).find(|&c| left(c) >= view.max.x).unwrap_or(cols); + for r in r0..r1 { + for c in c0..c1 { + let size = egui::vec2(left(c + 1) - left(c) - 1.0, ch - 1.0); + let rect = egui::Rect::from_min_size(origin + egui::vec2(left(c), r as f32 * ch), size); + let text = shown(cell_at(d, r, c), decimals); + let b = egui::Button::selectable((r, c) == at, egui::RichText::new(text).monospace()).truncate(); + if ui.put(rect, b).clicked() && (r, c) != (0, 0) { + clicked = Some((r, c)); + } + } + } + // A column's right edge, over the rows in view: dragging it sets that column's width. The + // edge being dragged stays in the loop when it leaves the view, so the drag goes on, also in + // the frame it is released. + let (top, bottom) = (origin.y + r0 as f32 * ch, origin.y + r1 as f32 * ch); + let dragged = ui + .ctx() + .dragged_id() + .or_else(|| ui.ctx().drag_stopped_id()) + .and_then(|id| (0..cols).find(|&c| edge_id(c) == id)) + .filter(|c| !(c0..c1).contains(c)); + for c in (c0..c1).chain(dragged) { + let gap = origin.x + left(c + 1) - 0.5; + let edge = egui::Rect::from_x_y_ranges(gap - 3.0..=gap + 3.0, top..=bottom); + let h = ui.interact(edge, edge_id(c), egui::Sense::drag()).on_hover_cursor(egui::CursorIcon::ResizeColumn); + // The width is the column's width when the drag started plus how far the pointer has + // moved since, so a scroll offset that changes with the sheet's width doesn't change it. + if h.drag_started() + && let Some(p) = ui.input(|i| i.pointer.press_origin()).or_else(|| h.interact_pointer_pos()) + { + ui.data_mut(|m| m.insert_temp(edge_id(c), (p.x, left(c + 1) - left(c) - 1.0))); + } + if h.dragged() { + ui.ctx().set_cursor_icon(egui::CursorIcon::ResizeColumn); + } + // The release can come in the same frame as the last move: it sets the width too. + if (h.dragged() || h.drag_stopped()) + && let Some(p) = h.interact_pointer_pos() + && let Some((x0, w0)) = ui.data(|m| m.get_temp::<(f32, f32)>(edge_id(c))) + { + resized = Some((c, px_digits(w0 + p.x - x0))); + } + if h.drag_stopped() { + ui.data_mut(|m| m.remove::<(f32, f32)>(edge_id(c))); + } + } + }); + }); + (clicked, resized) +} + #[cfg(test)] mod tests { use serde_json::json; @@ -685,6 +807,171 @@ mod tests { assert_eq!(sel(app.ui.dialog.as_ref().unwrap()), (0, 1), "Up"); } + /// Dragging a column's right edge shows the column-resize pointer and sets that column's width in + /// whole digits, the columns after it moving along; the other columns keep Cell Style's width. + /// A drag past 20 digits stops at 20, and Cell Style's Column Width then sets every column. + #[test] + fn dragging_a_column_edge_sets_that_columns_width() { + let (mut app, _) = app_with(",a,b\nQ1,1,2", "column"); + open(&mut app).unwrap(); + let ctx = egui::Context::default(); + crate::theme::install_fonts(&ctx); + let frame = |app: &mut VectorcraftApp, events: Vec| { + let mut out = ctx.run_ui(egui::RawInput { events, ..Default::default() }, |ui| super::super::show(app, ui.ctx())); + out.textures_delta.clear(); + out.platform_output.cursor_icon + }; + let button = + |pos, pressed| egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE }; + let edge = |c: usize| ctx.read_response(edge_id(c)).map(|r| r.rect).unwrap_or_else(|| panic!("column {c}'s edge is drawn")); + let drag = |app: &mut VectorcraftApp, c: usize, dx: f32| { + let at = edge(c).center(); + frame(app, vec![egui::Event::PointerMoved(at), button(at, true)]); + for step in 1..=4 { + frame(app, vec![egui::Event::PointerMoved(at + egui::vec2(dx * step as f32 / 4.0, 0.0))]); + } + frame(app, vec![button(at + egui::vec2(dx, 0.0), false)]); + frame(app, vec![egui::Event::PointerMoved(egui::pos2(0.0, 0.0))]); + }; + let digits = |app: &VectorcraftApp| { + let d = app.ui.dialog.as_ref().unwrap(); + (0..4).map(|c| col_digits(d, c)).collect::>() + }; + frame(&mut app, vec![]); + frame(&mut app, vec![]); + // The window takes its place over the first frames: hover where the edge is now. + let hovered = (0..10).any(|_| frame(&mut app, vec![egui::Event::PointerMoved(edge(1).center())]) == egui::CursorIcon::ResizeColumn); + assert!(hovered, "hovering an edge shows the column-resize pointer"); + let (one, two) = (edge(1).center().x, edge(2).center().x); + // 70 points is 10 digits. + drag(&mut app, 1, 70.0); + assert_eq!(digits(&app), [7, 17, 7, 7]); + let moved = [edge(1).center().x - one, edge(2).center().x - two]; + assert!(moved.iter().all(|m| (m - 70.0).abs() < 0.01), "the columns after it move along: {moved:?}"); + drag(&mut app, 2, -500.0); + assert_eq!(digits(&app), [7, 17, 0, 7], "no narrower than 0 digits"); + drag(&mut app, 0, 500.0); + assert_eq!(digits(&app), [20, 17, 0, 7], "no wider than 20 digits"); + let d = app.ui.dialog.as_mut().unwrap(); + set_width(d, 9); + assert_eq!(digits(&app), [9; 4], "Cell Style sets every column"); + } + + /// A drag whose last move comes in the frame it is released sets the width to where it was + /// released. A held drag on a sheet scrolled to its right end keeps its width while the scroll + /// offset follows the narrower sheet. Entering the width that Column Width shows sets every + /// column, the dragged ones too. + #[test] + fn a_column_drag_ends_where_released_and_the_shown_width_entered_sets_every_column() { + let rows: Vec> = (0..3).map(|i| vec![i as f64; 30]).collect(); + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + app.run("graph.create", json!({"type": "column", "x": 0, "y": 0, "width": 200, "height": 150, "rows": rows})).unwrap(); + open(&mut app).unwrap(); + let cols = extent(app.ui.dialog.as_ref().unwrap(), (0, 1)).1; + let ctx = egui::Context::default(); + ctx.enable_accesskit(); + crate::theme::install_fonts(&ctx); + let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1280.0, 900.0)); + let frame = |app: &mut VectorcraftApp, events: Vec| { + let mut out = + ctx.run_ui(egui::RawInput { screen_rect: Some(screen), events, ..Default::default() }, |ui| super::super::show(app, ui.ctx())); + out.textures_delta.clear(); + out.platform_output.accesskit_update.map(|u| u.nodes).unwrap_or_default() + }; + let button = + |pos, pressed| egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE }; + let edge = |c: usize| ctx.read_response(edge_id(c)).map(|r| r.rect).unwrap_or_else(|| panic!("column {c}'s edge is drawn")); + let digits = |app: &VectorcraftApp, c: usize| col_digits(app.ui.dialog.as_ref().unwrap(), c); + for _ in 0..3 { + frame(&mut app, vec![]); + } + // The last move and the release in one frame: 70 points is 10 digits. + let at = edge(1).center(); + frame(&mut app, vec![egui::Event::PointerMoved(at), button(at, true)]); + let to = at + egui::vec2(70.0, 0.0); + frame(&mut app, vec![egui::Event::PointerMoved(to), button(to, false)]); + frame(&mut app, vec![egui::Event::PointerMoved(egui::pos2(0.0, 0.0))]); + assert_eq!(digits(&app, 1), 17, "the width where the drag was released"); + // Scroll the sheet to its right end, then narrow a column by 5 digits and hold the pointer still. + let over = edge(1).center() - egui::vec2(20.0, 0.0); + let wheel = egui::Event::MouseWheel { + unit: egui::MouseWheelUnit::Point, + delta: egui::vec2(-100_000.0, 0.0), + phase: egui::TouchPhase::Move, + modifiers: Default::default(), + source: egui::MouseWheelSource::Unknown, + }; + frame(&mut app, vec![egui::Event::PointerMoved(over), wheel]); + for _ in 0..30 { + frame(&mut app, vec![]); + } + let c = cols - 2; + let at = edge(c).center(); + frame(&mut app, vec![egui::Event::PointerMoved(at), button(at, true)]); + for step in 1..=5 { + frame(&mut app, vec![egui::Event::PointerMoved(at - egui::vec2(7.0 * step as f32, 0.0))]); + } + for _ in 0..10 { + frame(&mut app, vec![]); + } + assert_eq!(digits(&app, c), 2, "a held drag keeps its width"); + let to = at - egui::vec2(35.0, 0.0); + frame(&mut app, vec![button(to, false)]); + frame(&mut app, vec![egui::Event::PointerMoved(egui::pos2(0.0, 0.0))]); + assert_eq!(digits(&app, c), 2, "the width where the drag was released"); + // Column Width still shows 7: entering 7 there sets every column to 7. + let nodes = frame(&mut app, vec![]); + let label = nodes + .iter() + .find(|(_, n)| n.role() == egui::accesskit::Role::Label && n.value() == Some("Column Width:")) + .and_then(|(_, n)| n.bounds()) + .expect("the Column Width label is drawn"); + let field = nodes + .iter() + .filter(|(_, n)| n.role() == egui::accesskit::Role::SpinButton) + .filter_map(|(_, n)| n.bounds()) + .filter(|b| b.x0 >= label.x1 && b.y0 < label.y1 && b.y1 > label.y0) + .min_by(|a, b| a.x0.total_cmp(&b.x0)) + .expect("the Column Width field is drawn"); + let at = egui::pos2(((field.x0 + field.x1) / 2.0) as f32, ((field.y0 + field.y1) / 2.0) as f32); + let click = |app: &mut VectorcraftApp, at| { + frame(app, vec![egui::Event::PointerMoved(at), button(at, true)]); + frame(app, vec![button(at, false)]); + frame(app, vec![]); + }; + // Clicking into the field and away from it, without a new value, keeps the columns' widths. + click(&mut app, at); + click(&mut app, egui::pos2(((label.x0 + label.x1) / 2.0) as f32, ((label.y0 + label.y1) / 2.0) as f32)); + assert_eq!((digits(&app, 1), digits(&app, c), digits(&app, 0)), (17, 2, 7), "leaving the field keeps the widths"); + click(&mut app, at); + frame(&mut app, vec![egui::Event::Text("7".into())]); + let enter = egui::Event::Key { key: egui::Key::Enter, physical_key: None, pressed: true, repeat: false, modifiers: Default::default() }; + frame(&mut app, vec![enter]); + frame(&mut app, vec![]); + assert_eq!((digits(&app, 1), digits(&app, c), digits(&app, 0)), (7, 7, 7), "Column Width sets every column"); + } + + #[test] + fn a_column_width_in_points_maps_to_whole_digits() { + for n in 0..=MAX_WIDTH { + assert_eq!(px_digits(digits_px(n)), n); + } + assert_eq!((px_digits(-40.0), px_digits(1e9), px_digits(f32::NAN)), (0, MAX_WIDTH, 0)); + let mut d = Dialog::new(KIND, json!({ "width": 7 })); + set_col_digits(&mut d, 3, 99); + set_col_digits(&mut d, MAX_COLS, 5); + assert_eq!((col_digits(&d, 2), col_digits(&d, 3)), (7, MAX_WIDTH)); + assert_eq!(d.fields["widths"].as_array().map(Vec::len), Some(4), "a column past the sheet is left alone"); + // `width` set by `ui.dialog.set` sets every column too, also when set back to the width before. + for w in [12, 7] { + crate::dialogs::set_field(&mut d, "width".into(), json!(w)); + assert_eq!((col_digits(&d, 2), col_digits(&d, 3)), (w, w)); + } + set_col_digits(&mut d, 1, 4); + assert_eq!((col_digits(&d, 1), col_digits(&d, 3)), (4, 7), "a drag after it gives that column its own width"); + } + /// How many buttons (the sheet's cells and the window's own) Graph Data draws in the second of two /// frames in a 1280 × 900 window, for a graph of `categories` rows of `series` values. fn buttons_drawn(categories: usize, series: usize) -> usize { diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 972b740e66..9fca26164e 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -846,6 +846,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Variables: Import Data Sets… (`dataset.import`) reads tab-separated files as well as comma-separated ones. Every header cell is a variable, and the rows replace the document's data sets as Data Set 1, Data Set 2 and so on. An import error about a row's values gives the file line the row starts on. - Variables: Import Data Sets… (`dataset.import`) reads a UTF-16 file without a byte-order mark, instead of refusing it, when at least half of its two-byte units hold a NUL byte; it uses the byte order that reads its line breaks. - Graphs: the Graph Data window's Import Data reads a UTF-16 text file without a byte-order mark by the same rule as Import Data Sets…, instead of filling the cells with NUL characters. It reads a file cut short by one byte, or with an unpaired surrogate, as it reads one after a byte-order mark. + - Graphs: in the Graph Data window, the pointer becomes a column-resize arrow over a column's right edge, and dragging the edge sets that column's width in whole digits, from 0 to 20 as Cell Style's Column Width allows. The columns after it move along. Cell Style's Column Width still sets every column, the dragged ones included ([Adjust decimal digits and column width](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/visualize-data/adjust-column-width.html)). - Variables: Import Data Sets… (`dataset.import`) defines the variables a file's header names that the document lacks, unbound. `#Shown` defines a visibility variable, `@Photo` defines an image variable, and a header without a prefix defines a text variable. A header that is a variable's exact name keeps naming it, and any other `%` header (graph data files) is refused. - Variables: Load Variable Library… in the Variables panel menu (`variable.loadLibrary`) replaces the document's variables and data sets with a variable library's, read from its XML file, in one undo step: every data set is deleted, and every variable is deleted with its bindings and values, except a variable the library also declares with the same kind, which stays bound so the library's data sets change its objects (#4136); then the library's other variables are defined, unbound: text, visibility, image (linked file) and graph variables, and variables without a known `trait` as unknown. Its data sets take text values from each value's `p` elements, one paragraph each, visibility values from `true` or `false`, image values from a file's absolute path or `file:` URL, and graph values from a `data` element of series names and rows. - Variables: Save Variable Library… in the Variables panel menu (`variable.saveLibrary`) writes the document's variables of every kind and its data sets as a variable library's XML file, which Load Variable Library reads back with the same variables, kinds, data set names and values.