Skip to content

Add plugin_config and columns_config defaults API - #3267

Merged
texodus merged 1 commit into
masterfrom
config-defaults
Oct 24, 2026
Merged

texodus merged 1 commit into
masterfrom
config-defaults

Conversation

@texodus

@texodus texodus commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

This PR adds a new plugin_config and columns_config defaults API: static methods to <perspective-viewer> for overriding the plugin-declared default of any plugin_config or columns_config key, page-wide.

Config defaults

  • Added setPluginConfigDefaults(defaults, options?) / setColumnConfigDefaults(defaults, options?) and their get* counterparts. options filters a default to a plugin and (for columns) a column type.
  • Calls merge into the defaults set by earlier calls with the same options, null removes a key at any depth, or the whole slot.
  • Overridden defaults behave exactly like the built-in ones: the settings and column style editors show them as the unedited value, and values equal to them are left out of save(), saveWorkspace() and perspective-config-update. Defaults are never saved themselves, and restore() / reset() don't touch them.
  • Charts' tooltips and adaptive axis labels now respect timeZone / hour12. A default which sets only these keeps the adaptive (zoom-dependent) axis labels.
  • Malformed arguments are now (fully) reported errors. A value a particular plugin can't use (out-of-range number, unknown enum) is logged with the plugin, column and key, and that plugin keeps its own default.

Breaking: date_format

  • date_format is now a flat subset of Intl.DateTimeFormatOptions. "disabled" and the format: "custom" marker are removed; just omit the field. timeZone and hour12 inherit from defaults per key, the display fields (dateStyle/timeStyle or the per-part fields) as one group.
  • Configs saved by earlier versions are migrated on restore(), addPanel() and restoreWorkspace() and render identically. Third-party plugins which declare "disabled" in a DatetimeFormat control default will need to be updated.

Fixes

Example

Display every datetime column in UTC, in every plugin

const Viewer = customElements.get("perspective-viewer");
Viewer.setColumnConfigDefaults(
    { date_format: { timeZone: "UTC" } },
    { type: "datetime" },
);

No thousands separators, everywhere or just Datagrid integer columns

Viewer.setColumnConfigDefaults({ number_format: { useGrouping: false } });
Viewer.setColumnConfigDefaults(
    { number_format: { useGrouping: false } },
    { plugin: "Datagrid", type: "integer" },
);

Plugin config defaults, and removing them

Viewer.setPluginConfigDefaults({ group_pad: 10 });
Viewer.setColumnConfigDefaults(
    { date_format: { timeZone: null } },
    { type: "datetime" },
);
Viewer.setPluginConfigDefaults(null);

date_format migration

// Before
{ date_format: { dateStyle: "short", timeStyle: "disabled" } }

// After
{ date_format: { dateStyle: "short" } }
@texodus texodus added enhancement Feature requests or improvements breaking labels Oct 23, 2026
@texodus
texodus force-pushed the config-defaults branch 3 times, most recently from 9f621f8 to 9491c99 Compare October 24, 2026 00:06
Signed-off-by: Andrew Stein <steinlink@gmail.com>
@texodus
texodus marked this pull request as ready for review October 24, 2026 01:55
@texodus
texodus merged commit d03a0b6 into master Oct 24, 2026
19 checks passed
@texodus
texodus deleted the config-defaults branch October 24, 2026 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking enhancement Feature requests or improvements

1 participant