ZoomCharts Documentation
Data filters
After the data is received from server or added, a series of filer functions can be applied to display only part. This allows interactive selection of displayed parts of a graph without reloading data.
The following filter functions are available. They are evaluated in the order presented below.
settings.filters.nodeFilter(nodeData, linksData[])
Filters what nodes are visible. Is called on every node that is about to be added to the graph or after node data has been updated.
Parameters:
- nodeData - the node in question - data object as received from server.
- linksData - array of links data objects that are connected to the node.
Return value: return true
if node is to be shown, false
if not.
More detailed explanation of nodeFilter
function.
settings.filters.linkFilter(linkData, sourceNodeData, targetNodeData)
Filters what links are visible. Is called on every link that is about to be added to the graph or after link data has been updated.
Parameters:
- linkData - the link in question - data object as received from server.
- sourceNodeData - the data of link source node.
- targetNodeData - the data of link target node.
Return value: return true
if link is to be shown, false
if not.
settings.filters.nodeLinksProcessor(nodeData, linksData[])
Further filters what links are visible with respect to a common node. Is called whenever links connected to a specific node change.
Parameters:
- nodeData - data object of the common node for all links.
- linksData[] - array of links connected to the node.
Return value: return a new array of links containing only the links that will be displayed.
settings.filters.multilinkProcessor(linksData[], fromNodeData, toNodeData)
Allows to show a single link instead of multiple links between two nodes. Is called whenever there are multiple links connecting two nodes.
Parameters:
- linksData[] - array of links connected between two nodes.
- fromNodeData - data object of the first common node.
- toNodeData - data object of the second common node.
Note that the links can be in both directions. Some of them will have fromNode in the form field and toNode in to field, some will have the reverse.
Return value: return a single linkData object or a new array of linkData objects containing only the links that will be displayed. It's also possible to return an entirely new linkData object with desired values.
Changing filter functions
To change filter functions call chart.updateSettings(settingsObj)
with new filter functions specified in the settings
.
You can also call chart.updateFilters()
to force reevaluation of filter functions. For example if their behavior has changed.