Attaches any API callbacks specified in the callbacks object.
function HookFvEvents(callbacks) {
_.forEach(callbacks.Events, function(func, key) {
if(fv.HasEvent(key)) {
fv.on(key, func);
}
});
}
module.exports = App;
Option name | Type | Description |
---|---|---|
config | String | The relative path to the config JSON file |
selector | String | A CSS-style selector for the SVG tag the visualization should be created in |
setup | object | A setup object that has three fields: events (for FlowViz event listeners), callbacks (for overriding default FlowViz logic), and validators (for validating data items or custom constraint checking). |
The FlowViz.App module is responsible for handling the user-facing API of FlowViz. Through this module, developers
can create and hookup event listeners, callbacks, and validators into the FlowViz API. This is additionally
responsible for creating and managing an instance of the FlowViz object.
function App(config, selector, setup) {
this.Callbacks = setup;
if(!this.Callbacks.hasOwnProperty("Events")) {
this.Callbacks.Events = {};
}
if(!this.Callbacks.hasOwnProperty("DataValidation")) {
this.Callbacks.DataValidation = {};
}
if(!this.Callbacks.hasOwnProperty("Interactions")) {
this.Callbacks.Interactions = {};
}
if(!this.Callbacks.hasOwnProperty("GraphValidators")) {
this.Callbacks.GraphValidators = {};
}
fv = new FlowViz(this, config, selector);
this.FlowViz = fv;
HookFvEvents(this.Callbacks);
}
Option name | Type | Description |
---|---|---|
valName | string | Custom validator key |
oldVal | object | The old value for this data item |
newVal | object | The new value for this data item |
Validates a value given the key for a custom validator, the old data item value, and the new data item value.
App.prototype.Validate = function(valName, oldVal, newVal) {
if(this.Callbacks.DataValidation.hasOwnProperty(valName)) {
return this.Callbacks.DataValidation[valName](oldVal, newVal);
}
throw new Error("No validator exists with the name " + valName + "!");
};