Skip to content

HeliosFilter

class

Back to Helios Web API

Kind
class
Source
src/filters/HeliosFilter.js:227

Description

Builder for reusable graph filter rule sets.

Signature

export class HeliosFilter {

Parameters

NameTypeAttributesDefaultDescription
optionsObjectoptionalFilter id, display name, graph scope, and initial rules.

Returns

Filter model that can be activated through helios.activateHeliosFilter(...) or FilterBehavior.

Type HeliosFilter

Notes

Rules compile to Helios Network query expressions. Supported rule types are numeric, categorical, string, and raw query.

Filtering And State

Graph filtering and interaction state. When active, FilterBehavior and SelectionBehavior coordinate this area.

toGraphFilterOptions() → {Object}

Source: src/filters/HeliosFilter.js:427

Convert this model to the graph-filter options consumed by Helios.

Returns

Graph-filter options with node and edge query strings.

Type Object

Configuration

General configuration setters and compatibility helpers.

setScope(scope) → {HeliosFilter}

Source: src/filters/HeliosFilter.js:270

Set the graph filter scope.

Parameters

NameTypeAttributesDefaultDescription
scope'render'|'render+layout'Graph filter scope.

Returns

This filter.

Type HeliosFilter

getScope() → {'render'|'render+layout'}

Source: src/filters/HeliosFilter.js:280

Return the graph filter scope.

Returns

Current graph filter scope.

Type 'render'|'render+layout'

Example


const value = helios.getScope();

getRules(scope = null) → {Array.<Object>}

Source: src/filters/HeliosFilter.js:290

Return copied rules, optionally limited to node or edge rules.

Parameters

NameTypeAttributesDefaultDescription
scope'node'|'edge'optionalOptional rule scope.

Returns

Copied rule descriptors.

Type Array.<Object>

clear(scope = null) → {HeliosFilter}

Source: src/filters/HeliosFilter.js:379

Remove all rules, or all rules for one node/edge scope.

Parameters

NameTypeAttributesDefaultDescription
scope'node'|'edge'optionalOptional rule scope to clear.

Returns

This filter.

Type HeliosFilter

Utilities

Additional public helpers that do not belong to a narrower API area.

clone() → {HeliosFilter}

Source: src/filters/HeliosFilter.js:255

Return a deep copy of this filter model.

Returns

Independent filter with copied rule descriptors.

Type HeliosFilter

addRule(rule) → {Object}

Source: src/filters/HeliosFilter.js:320

Add a filter rule.

Parameters

NameTypeAttributesDefaultDescription
ruleObjectRule descriptor.

Returns

Normalized copied rule descriptor.

Type Object

updateRule(ruleId, patch = {}) → {Object}

Source: src/filters/HeliosFilter.js:334

Update an existing rule by id.

Parameters

NameTypeAttributesDefaultDescription
ruleIdstringRule id to update.
patchObjectoptionalRule fields to replace.

Returns

Normalized copied rule descriptor.

Type Object

upsertRule(rule) → {Object}

Source: src/filters/HeliosFilter.js:352

Update a rule by id when it exists, otherwise add it.

Parameters

NameTypeAttributesDefaultDescription
ruleObjectRule descriptor.

Returns

Normalized copied rule descriptor.

Type Object

removeRule(ruleId) → {boolean}

Source: src/filters/HeliosFilter.js:366

Remove a rule by id.

Parameters

NameTypeAttributesDefaultDescription
ruleIdstringRule id to remove.

Returns

True when a rule was removed.

Type boolean

compileScopeQuery(scope) → {string|null}

Source: src/filters/HeliosFilter.js:397

Compile active rules for one node/edge scope into a query string.

Parameters

NameTypeAttributesDefaultDescription
scope'node'|'edge'Rule scope to compile.

Returns

Query expression, or null when no active criteria apply.

Type string|null

hasCriteria() → {boolean}

Source: src/filters/HeliosFilter.js:418

Test whether this filter has any active criteria.

Returns

True when at least one rule compiles to a query.

Type boolean

Example


const value = helios.hasCriteria();

Example

const filter = new HeliosFilter({ scope: 'render' })
  .addRule({ type: 'numeric', scope: 'node', attribute: 'score', min: 0.5, max: 1 });