Fork me on GitHub

API-Doc

ODIN component

The ODIN library uses Cubbles as base technology. Therefore, every ODIN component is a Cubbles component. ODIN components are designed to be used for ETL processes with data visualisation in mind. One key difference between a Cubble and an ODIN component is the specialisation on handling various forms of data. Processing data can be generalised, but to support a wide variety of use cases one needs to balance between simplicity and complexity. Thats the goal of this library and its components and utilities. The library itself introduces three component types: Connectors, Transformers and Views. Each component type has a number of restrictions and requirements that implementations must fulfill. This way, its easy to connect ODIN components together to archive what one wants to: processing data to get meaningful information and present them in a modern fashion.

Connectors

A connector is a component which provides data from a specific source. The source should be stable. Requests should be performed asynchronously and via a secured protocol like HTTPS. The internal request process must start when an input slot changes, but exceptions may be stated for first-time changes.

Input slots

The component input slots define certain aspects of the internal request process. Slot names should express what is needed. Also, some slots can be defined as optional, but every slot must accept JSON as data type only.

Output slots

Every connector must have two output slots. One must output the result in case of a successful request process, called data, and the other one in case of an error, called error.

slot name description
data Outputs the data that was requested. The data type can be anything, but implementations should consider outputting JSON for compatibility reasons.
error This slot signals an error. The error must be wrapped in an Error object. Use odin.createErrorObj to generate one.

Process synchronization

In general, connectors are considered to work asynchronously by default, but every connector should clearly state his internal request process. An asynchronous process implies that once the input slots are set it'll take some indeterminate time for the result to be evaluated and accessible via getter's and output slots. In this case an user should use a listener/observer like pattern on the output slots, so that he'll be notified once a result is ready to access (use the cifModelChange event on the component). In case of a synchronously internal request process the user may access the results via getter's directly. See RTE / User Guide / The Cubbles Javascript API / Intercepting changes on output slots for more information.

List of components

dbpedialite-connector

A connector which requests simple data from DBpedia (http://www.dbpedialite.org/) in different output formats. The requested data must be specified by unique wikipedia page ids. The internal request process starts when an input slot changes, but all other input slots must be set with a valid value first. After the value is set, each change will trigger the process with the current changed value of an input slot and with all previously setted values of the other input slots.

Please note: This connector queries all data via a non-secured protocol (http).

Usage example

See demo page.

Methods

Method Returns Description
getData() Object[]|String[] See dbpedialite-connector-data for more details.
getError() Error object|undefined|null See dbpedialite-connector-error for more details.
setPageIds( <String[]> pageIds) See dbpedialite-connector-pageIds for more details.
setDataFormat( <String> dataFormat) See dbpedialite-connector-dataFormat for more details.

Process synchronization

As all connectors, this one works asynchronously. See connectors-synchronization.

Input slots

Name Type Default Description
pageIds String[] An array of strings containing unique wikipedia page ids. A wikipedia page id is located at the "Page information" of each wikipedia article (on the left column in the section "Tools"). E.g. https://en.wikipedia.org/w/index.php?title=Berlin&action=info is the page information for "Berlin".
dataFormat String A string enum. Value can be one of:
  • JSON
  • JSON-LD
  • N-TRIPLES
  • RDF/XML
  • TRIX
  • TURTLE

Output slots

Name Type Description
data Object[]|String[] Returns an array of objects, each object contains the queried data of each given wikipedia page id by the latest inputs. The order is defined by the input slots pageIds array. The type of each element in dbpedialite-connector-data is defined by the input slot dbpedialite-connector-dataFormat. The data formats JSON and JSON-LD will produce objects while all others will be strings.
error Error object|undefined|null Returns an Error object, if an error occured while processing the latest inputs, otherwise undefined or null.

Transformers

A transformer is a component which handles data and transforms them. That may include transformations like mapping, filtering, adding, splitting or even validating of data. The internal process must start when an input slot changes, but exceptions may be stated for first-time changes.

Input slots

Each transformer must have one input slot called dataIn. Another input slot is optional, called config.

slot name description
dataIn Used to put in the incoming data for the component. The data type can be anything, but implementations should consider JSON for compatibility reasons.
config The configuration of this component. It's optional, but if present it must feature certain aspects of the internal process and it must be an object.

Output slots

Every transformer must have two output slots. One must output the result in case of a successful process, called dataOut, and the other one in case of an error, called error.
slot name description
dataOut Outputs the transformed data. The data type can be anything, but implementations should consider outputting JSON for compatibility reasons.
error This slot signals an error. The error must be wrapped in an Error object. Use odin.createErrorObj to generate one.

Process synchronization

In general, transformers are considered to work synchronously by default, but every transformer should clearly state his internal process. A synchronous process implies that once the input slots are set the result will be evaluated and accessible afterwards via getter's directly. In case of an asynchronously internal process an user should use a listener/observer like pattern on the output slots, so that he'll be notified once a result is ready to access (use the cifModelChange event on the component). See RTE / User Guide / The Cubbles Javascript API / Intercepting changes on output slots for more information.

List of components

array-element-mapper

A transformer which maps an array of data to a normalized data structure (all data structures). The internal process starts when an input slot changes, but all other input slots must be set with a valid value first. After the value is set, each change will trigger the process with the current changed value of an input slot and with all previously setted values of the other input slots.

Usage example

See demo page.

Methods

Method Returns Description
getDataOut() Object|Array See array-element-mapper-dataOut for more details.
getError() Error object|undefined|null See array-element-mapper-error for more details.
setConfig( <AEM Config Options> config) See array-element-mapper-config for more details.
setDataIn( <Array> dataIn) See array-element-mapper-dataIn for more details.

Process synchronization

As all transformers, this one works synchronously. See transformers-synchronization.

Input slots

Name Type Default Description
config AEM Config Options The configuration of this component. It defines how to map the incoming data to the desired result (normalized data structure).
dataIn Array The incoming data, which is an array that may contain elements of either the type object or array, but not both. In case of object elements, each property of such an object may be of any type. In case of array elements, each element of such an array may be of any type.

Output slots

Name Type Description
dataOut Object|Array Returns an object or array as the mapping result (normalized data structure). The structure and type of the result is determined by the AEM Config Options of the input slot array-element-mapper-config.
error Error object|undefined|null Returns an Error object, if an error occured while processing the latest inputs, otherwise undefined or null.

Slot options

Config object

The configuration object of this component.

Name Type Default Description
mapToObjects Boolean true if the resulting data structure shall be composed of objects, otherwise false for arrays. See normalized data structure for more details.
mapToTuples Boolean true true if the resulting data structure shall be composed of data tuples, otherwise false for data series. See normalized data structure for more details.
mappings Mapping[] An array of Mapping elements, with each element defining a mapping rule. Each rule must be unique.

Mapping object

A mapping object defines a mapping rule.

Name Type Default Description
src Odin Path w/ parsing A path to the source data in array-element-mapper-dataIn with an optional parsing option. See Odin Path w/ parsing for more details.
target String Specifies a target property. Applies if array-element-mapper-config-mapToObjects is true.
target Array index Specifies a target index. Applies if array-element-mapper-config-mapToObjects is false.

xml-to-json-converter

This component converts XML (as string) to JSON. Uses Fast XML Parser for the conversion. The internal process starts when an input slot changes, but all other input slots must be set with a valid value first. After the value is set, each change will trigger the process with the current changed value of an input slot and with all previously setted values of the other input slots.

Usage example

See demo page.

Methods

Method Returns Description
getDataOut() Object See xml-to-json-converter-dataOut for more details.
getError() Error object|undefined|null See xml-to-json-converter-error for more details.
setConfig( <XTJC Config Options> config) See xml-to-json-converter-config for more details.
setDataIn( <String> dataIn) See xml-to-json-converter-dataIn for more details.

Process synchronization

As all transformers, it works synchronously. See transformers-synchronization.

Input slots

Name Type Default Description
config XTJC Config Options The configuration of this component. It provides different ways to influence the conversion, but its optional.
dataIn String The incoming data, which is a XML string.

Output slots

Name Type Description
dataOut Object Returns the result as JSON. The result is determined by the XTJC Config Options of the input slot xml-to-json-converter-config.
error Error object|undefined|null Returns an Error object, if an error occured while processing the latest inputs, otherwise undefined or null.

Slot options

Config object

The configuration object of this component.

Name Type Default Description
attributeNamePrefix String "@_" Defines the prefix that should be prepended for XML attributes.
attrNodeName String A group name that compacts all XML attributes in one JSON object with the name as property key.
textNodeName String "#text" Defines the JSON property key for XML text nodes.
ignoreAttributes Boolean true true if XML attributes should be ignored, otherwise false.
ignoreNameSpace Boolean false true if XML namespace references should be omitted, otherwise false.
allowBooleanAttributes Boolean false true if XML attributes w/o a value should be allowed and interpreted as boolean, otherwise false.
parseNodeValue Boolean true true if XML node values should be parsed to JSON values, otherwise false if they should be strings.
parseAttributeValue Boolean true true if XML attribute values should be parsed to JSON values, otherwise false if they should be strings. true if all values should be trimmed (removing spaces at the beginning and end).
cdataTagName String Defines the JSON property key for XML CDATA sections. If not defined, then the CDATA section will appear in the value of the node that defined it.
cdataPositionChar String "\\c" A marker that will be placed in the node containing a CDATA section. Useful to maintain the position.
localeRange String Defines the acceptable character range for handling non-english element and attribute names.

json-to-xml-converter

This component converts JSON object to a XML string. Uses Fast XML Parser for the conversion. The internal process starts when an input slot changes, but all other input slots must be set with a valid value first. After the value is set, each change will trigger the process with the current changed value of an input slot and with all previously setted values of the other input slots.

Usage example

See demo page.

Methods

Method Returns Description
getDataOut() Object See json-to-xml-converter-dataOut for more details.
getError() Error object|undefined|null See json-to-xml-converter-error for more details.
setConfig( <JTXC Config Options> config) See json-to-xml-converter-config for more details.
setDataIn( <Object> dataIn) See json-to-xml-converter-dataIn for more details.

Process synchronization

As all transformers, it works synchronously. See transformers-synchronization.

Input slots

Name Type Default Description
config JTXC Config Options The configuration of this component. It provides different ways to influence the conversion, but its optional.
dataIn Object The incoming data, which is a JSON object.

Output slots

Name Type Description
dataOut String Returns the result as JSON. The result is determined by the JTXC Config Options of the input slot json-to-xml-converter-config.
error Error object|undefined|null Returns an Error object, if an error occured while processing the latest inputs, otherwise undefined or null.

Slot options

Config object

The configuration object of this component.

Name Type Default Description
attributeNamePrefix String "@_" Defines the prefix that identifies properties which should be treated as XML attributes.
attrNodeName String A property key of an object that contains key-value pairs which should be treated as XML attributes.
textNodeName String "#text" Defines the property which should be treated as XML text node.
ignoreAttributes Boolean true true if properties which are treated as XML attributes should be omitted, otherwise false.
cdataTagName String Defines the property for the XML CDATA section.
cdataPositionChar String "\\c" A marker that identifies an occurence of a XML CDATA section.
format Boolean false true if the result should be formatted, otherwise false.
indentBy String "" Defines the indention if format is true.
supressEmptyNode Boolean false true if XML elements without any value (text or nested elements) should be self closing elements (e.g. <br >), otherwise false.

nds-inverter

A transformer which maps an array of data to a normalized data structure (all data structures). The internal process starts when an input slot changes, but all other input slots must be set with a valid value first. After the value is set, each change will trigger the process with the current changed value of an input slot and with all previously set values of the other input slots. A demo example:

name dataIn config dataOut
Array with object tuples
[ //    "a",       "b",       "c",       "d" <-- keys (columns)
    { "a": 1234, "b": 5432, "c":  235, "d": 6547 }, // 0 <-- indices (rows)
    { "a": 9876, "b": 5498, "c": 1234, "d": 6547 }, // 1
    { "a":  754, "b":  234, "c": 5498, "d": 1234 }  // 2
]
{
  "elementsAreObjects": true,
  "dataContainsTuples": true
}
[  //      0,         1,         2 <-- former indicies (columns)
     { "0": 1234, "1": 9876, "2":  754 }, // "a" <-- former keys (rows)
     { "0": 5432, "1": 5498, "2":  234 }, // "b"
     { "0":  235, "1": 1234, "2": 5498 }, // "c"
     { "0": 6547, "1": 6547, "2": 1234 }  // "d"
]
Object with series per property
{ //        0,    1,    2 <-- indicies (columns)
    "a": [ 1234, 9876,  754 ], // "a" <-- keys (rows)
    "b": [ 5432, 5498,  234 ], // "b"
    "c": [  235, 1234, 5498 ], // "c"
    "d": [ 6547, 6547, 1234 ]  // "d"
}
{
  "elementsAreObjects": true,
  "dataContainsTuples": false
}
{  //      "a",  "b",  "c",  "d" <-- former keys (columns)
    "0": [ 1234, 5432,  235, 6547 ], // 0 <-- former indicies (rows)
    "1": [ 9876, 5498, 1234, 6547 ], // 1
    "2": [  754,  234, 5498, 1234 ]  // 2
}
Array with array tuples
[ //   0,    1,    2,    3 <-- inner array indices (columns)
    [ 1234, 5432,  235, 6547 ], // 0 <-- outer array indicies (rows)
    [ 9876, 5498, 1234, 6547 ], // 1
    [  754,  234, 5498, 1234 ]  // 2
]
{
  "elementsAreObjects": false,
  "dataContainsTuples": true
}
[  //   0,    1,    2 <-- former outer array indices (columns)
    [ 1234, 9876,  754 ], // 0 <-- former inner array indices (rows)
    [ 5432, 5498,  234 ], // 1
    [  235, 1234, 5498 ], // 2
    [ 6547, 6547, 1234 ]  // 3
]
Array with array series
[ //   0,    1,    2 <-- inner array indices (columns)
    [ 1234, 9876,  754 ], // 0 <-- outer array indices (rows)
    [ 5432, 5498,  234 ], // 1
    [  235, 1234, 5498 ], // 2
    [ 6547, 6547, 1234 ]  // 3
]
{
  "elementsAreObjects": false,
  "dataContainsTuples": false
}
[  //   0,    1,    2,    3 <-- former outer array indices (columns)
    [ 1234, 5432,  235, 6547 ], // 0 <-- former inner array indices (rows)
    [ 9876, 5498, 1234, 6547 ], // 1
    [  754,  234, 5498, 1234 ]  // 2
]

Usage example

See demo page.

Methods

Method Returns Description
setDataOut() normalized data structure See nds-inverter-dataOut for more details.
getError() Error object|undefined|null See nds-inverter-error for more details.
setConfig( <NDSI Config Options> config) See nds-inverter-config for more details.
setDataIn( <normalized data structure> dataIn) See nds-inverter-dataIn for more details.

Process synchronization

As all transformers, this one works synchronously. See transformers-synchronization.

Input slots

Name Type Default Description
config NDSI Config Options The configuration of this component. It defines how to map the incoming data to the desired result (normalized data structure).
dataIn normalized data structure The incoming data, which is an array/object that may contain elements of either the type object or array, but not both. In case of object elements, each property of such an object may be of any type. In case of array elements, each element of such an array may be of any type.

Output slots

Name Type Description
dataOut normalized data structure Returns an object or array as the mapping result (normalized data structure). The structure and type of the result is determined by the AEM Config Options of the input slot nds-inverter-config.
error Error object|undefined|null Returns an Error object, if an error occurred while processing the latest inputs, otherwise undefined or null.

Slot options

Config object

The configuration object of this component.

Name Type Default Description
elementsAreObjects Boolean true if the resulting data structure is composed of objects, otherwise false for arrays. See normalized data structure for more details.
dataContainsTuples Boolean true true if the resulting data structure is composed of data tuples, otherwise false for data series. See normalized data structure for more details.

Views

A view is a component which displays data in a meaningful way. That may include tables, chart, geographical maps or even just text. Views tend to be complex, therefore they should feature a configuration to reflect it, offering users choices to visualise the data in many ways. Views usually do not define any styling (css) themselves. Instead they feature configuration options to let the user place css classes for styling. The internal request process must start when an input slot changes, but exceptions may be stated for first-time changes.

Input slots

A view must have two input slots. One for putting data in, called data, and one for the configuration, called config.

slot name description
data Used to put in the incoming data for the component. The data type must be JSON for compatibility reasons.
config The configuration of this component. It must feature certain aspects of the view (formatting etc.) and it must be an object. Also every view must have a configuration option called wrapperClass which accepts a css class as string. This string must be placed in the surrounding div element of the view. Any other configuration option that is meant to hold a css class should have Class at the end of its name.

Output slots

Views are endpoints, meaning once the data arrives the ETL process is at its end. Therefore views only feature diagnostic results. One in case of a successful process, called onViewUpdate, and the other one in case of an error, called error.
slot name description
onViewUpdate Signals that the component updated its internal state successfully (this does not include the rendering process). Implementation should use odin.triggerOnViewUpdate to set this slot.
error This slot signals an error. The error must be wrapped in an Error object. Use odin.createErrorObj to generate one.

Process synchronization

In general, views are considered to work partially synchronously and asynchronously. While the internal process of processing the data and configuration is likely to be a synchronous process, the rendering might happen asynchronously, but every view should clearly state his internal process. This implies that once the input slots are set it'll take some determinate time for the result to be evaluated, but an indeterminate time to rendering it. In any case an user should use a listener/observer like pattern on the output slots, so that he'll be notified once a result is ready to access (use the cifModelChange event on the component). See RTE / User Guide / The Cubbles Javascript API / Intercepting changes on output slots for more information.

List of components

plaintext-view

A view which displays any given data in a <pre> element as it is (excluding HTML entities). The internal process starts when an input slot changes, but all other input slots must be set with a valid value first. After the value is set, each change will trigger the process with the current changed value of an input slot and with all previously setted values of the other input slots.

Usage example

See demo page.

Methods

Method Returns Description
getOnViewUpdate() View update object See plaintext-view-onViewUpdate for more details.
getError() Error object|undefined|null See plaintext-view-error for more details.
setConfig( <PTV Config Options> config) See plaintext-view-config for more details.
setData( <null|Boolean|Number|String|Object|Array> data) See plaintext-view-data for more details.

Process synchronization

As all views, this one works synchronously, but rendering might be asynchronously. See views-synchronization.

Input slots

Name Type Default Description
config PTV Config Options The configuration of this component. It defines how to format the content.
data null|Boolean|Number|String|Object|Array The incoming data to display.

Output slots

Name Type Description
onViewUpdate View update object Signals that the internal process of this view has ended successfully (this does not include the rendering process).
error Error object|undefined|null Returns an Error object, if an error occured while processing the latest inputs, otherwise undefined or null.

Slot options

Config object

The configuration object of this component.

Name Type Default Description
wrapperClass String A css class name that can be used as selector for the entire component.
preClass String A css class name that can be used as selector for the entire <pre> element.
space Number|String If a Number, then it defines the tab size (or indention) of the content as spaces. As a String it defines the indention character sequence to use.

table-view

A view which displays the given data as a table. The internal process starts when an input slot changes, but all other input slots must be set with a valid value first. After the value is set, each change will trigger the process with the current changed value of an input slot and with all previously setted values of the other input slots.

Usage example

See demo page.

Methods

Method Returns Description
getOnViewUpdate() View update object See table-view-onViewUpdate for more details.
getError() Error object|undefined|null See table-view-error for more details.
setConfig( <TV Config Options> config) See table-view-config for more details.
setData( <normalized data structure> data) See table-view-data for more details.

Process synchronization

As all views, this one works synchronously, but rendering might be asynchronously. See views-synchronization.

Input slots

Name Type Default Description
config TV Config Options The configuration of this component. It defines how to interprete the incoming data (normalized data structure) and format the table.
data normalized data structure The incoming data, which must be a normalized data structure.

Output slots

Name Type Description
onViewUpdate View update object Signals that the internal process of this view has ended successfully (this does not include the rendering process).
error Error object|undefined|null Returns an Error object, if an error occured while processing the latest inputs, otherwise undefined or null.

Slot options

Config object

The configuration object of this component.

Name Type Default Description
elementsAreObjects Boolean true if the resulting data structure is composed of objects, otherwise false for arrays. See normalized data structure for more details.
dataContainsTuples Boolean true true if the resulting data structure is composed of data tuples, otherwise false for data series. See normalized data structure for more details.
wrapperClass String A css class name that can be used as selector for the entire component.
tableClass String A css class name that can be used as selector for the entire <table> element.
headClass String A css class name that can be used as selector for the entire <thead> element.
bodyClass String A css class name that can be used as selector for the entire <tbody> element.
rowClass String A css class name that can be used as selector for all <tr> elements.
headerClass String A css class name that can be used as selector for all <th> elements.
cellClass String A css class name that can be used as selector for all <td> elements.
showRowNumbers Boolean false true if the table should show the number of each row in the first column, otherwise false.
header Header[] An array of Header elements, with each element defining a column heading of the table. Each definition must be unique.

Header object

A header object defines a heading for the table.

Name Type Default Description
name String The name of the column heading to display.
key String Specifies the property to use from the data objects. Applies if table-view-config-elementsAreObjects is true.
key Array index Specifies the index to use from the data objects. Applies if table-view-config-elementsAreObjects is false.

chart-view

A view which displays the given data in a chart. Uses c3.js and d3 (as dependency). It supports various chart types including bar, line, area, donut and others. The internal process starts when an input slot changes, but all other input slots must be set with a valid value first. After the value is set, each change will trigger the process with the current changed value of an input slot and with all previously setted values of the other input slots.

Usage example

See demo page.

Methods

Method Returns Description
getOnViewUpdate() View update object See chart-view-onViewUpdate for more details.
getError() Error object|undefined|null See chart-view-error for more details.
setConfig( <CV Config Options> config) See chart-view-config for more details.
setData( <normalized data structure> data) See chart-view-data for more details.

Process synchronization

As all views, this one works synchronously, but rendering might be asynchronously. See views-synchronization.

Input slots

Name Type Default Description
config CV Config Options The configuration of this component. It defines how to interprete the incoming data (normalized data structure) and format the chart.
data normalized data structure The incoming data, which must be a normalized data structure.

Output slots

Name Type Description
onViewUpdate View update object Signals that the internal process of this view has ended successfully (this does not include the rendering process).
error Error object|undefined|null Returns an Error object, if an error occured while processing the latest inputs, otherwise undefined or null.

Slot options

Config object

The configuration object of this component.

Name Type Default Description
elementsAreObjects Boolean true if the resulting data structure is composed of objects, otherwise false for arrays. See normalized data structure for more details.
dataContainsTuples Boolean true true if the resulting data structure is composed of data tuples, otherwise false for data series. See normalized data structure for more details.
wrapperClass String A css class name that can be used as selector for the entire component.
dataSeries DataSeries[] An array of DataSeries elements, with each element defining a visible series for the chart. Each definition must be unique.
c3 Object This object contains the entire c3-specific configuration. The structure is defined by c3.js itself. Please take a look at the c3 reference which options are available. Most of the option can be used for this component, too.

Chart:

  • size.width
  • size.height
  • padding.top
  • padding.right
  • padding.bottom
  • padding.left
  • color.pattern
  • interaction.enabled
  • transition.duration
Data:
  • data.x
  • data.xs
  • data.xFormat
  • data.type
  • data.types
  • data.groups
  • data.axes
  • data.labels
  • data.order (no function value)
  • data.regions (either use a string or array index for start and end)
  • data.colors
  • data.hide
  • data.empty.label.text
Axis:
  • axis.rotated
  • axis.x.show
  • axis.x.type
  • axis.x.localtime
  • axis.x.categories
  • axis.x.tick.centered
  • axis.x.tick.culling
  • axis.x.tick.culling.max
  • axis.x.tick.count
  • axis.x.tick.fit
  • axis.x.tick.values (either use strings or integers)
  • axis.x.tick.rotate
  • axis.x.tick.outer
  • axis.x.max (either use string or number)
  • axis.x.min (either use string or number)
  • axis.x.padding
  • axis.x.height
  • axis.x.extent (no function value)
  • axis.x.label
  • axis.y.show
  • axis.y.inner
  • axis.y.max
  • axis.y.min
  • axis.y.inverted
  • axis.y.center
  • axis.y.label
  • axis.y.tick.outer
  • axis.y.tick.values
  • axis.y.tick.count
  • axis.y.padding
  • axis.y.default
  • axis.y2.show
  • axis.y2.inner
  • axis.y2.max
  • axis.y2.min
  • axis.y2.inverted
  • axis.y2.center
  • axis.y2.label
  • axis.y2.tick.outer
  • axis.y2.tick.values
  • axis.y2.tick.count
  • axis.y2.padding
  • axis.y2.default
Grid:
  • grid.x.show
  • grid.x.lines (either use a string or number for value)
  • grid.y.show
  • grid.y.lines
Region:
  • regions (for x use strings or numbers, for y and y2 use numbers)
Legend:
  • legend.show
  • legend.hide
  • legend.position
  • legend.inset
Tooltip:
  • tooltip.show
  • tooltip.grouped
Subchart:
  • subchart.show
  • subchart.size.height
Zoom:
  • zoom.enabled
  • zoom.rescale
  • zoom.extent
Point:
  • point.show
  • point.r
  • point.focus.expand.enabled
  • point.focus.expand.r
  • point.select.r
Line:
  • line.connectNull
  • line.step.type
Area:
  • area.zerobased
Bar:
  • bar.width
  • bar.width.ratio
  • bar.zerobased
Pie:
  • pie.label.show
  • pie.label.threshold
  • pie.expand
Donut:
  • donut.label.show
  • donut.label.threshold
  • donut.expand
  • donut.width
  • donut.title
Gauge:
  • gauge.label.show
  • gauge.expand
  • gauge.min
  • gauge.max
  • gauge.units
  • gauge.width

DataSeries object

A DataSeries object defines a series for the chart.

Name Type Default Description
name String The name of the series. Will be used as display name.
seriesClass String A css class name that can be used as selector for this series.
key String Specifies the property to use from the data objects. Applies if chart-view-config-elementsAreObjects is true.
key Array index Specifies the index to use from the data objects. Applies if chart-view-config-elementsAreObjects is false.

maplayer-view

A view which displays geographical maps and associated data. Uses leaflet and various leaflet plugins. It supports different map tile providers by name (see Leaflet-providers) or url, GeoJSON, markers, popups etc. The internal process starts when an input slot changes, but all other input slots must be set with a valid value first. After the value is set, each change will trigger the process with the current changed value of an input slot and with all previously setted values of the other input slots.

Usage example

See demo page.

Methods

Method Returns Description
getOnViewUpdate() View update object See maplayer-view-onViewUpdate for more details.
getError() Error object|undefined|null See maplayer-view-error for more details.
setConfig( <MLV Config Options> config) See maplayer-view-config for more details.
setData( <*> data) See maplayer-view-data for more details.

Process synchronization

As all views, this one works synchronously, but rendering might be asynchronously. See views-synchronization.

Input slots

Name Type Default Description
config MLV Config Options The configuration of this component. It defines how to interprete the incoming data and format the map.
data * The incoming data for the map.

Output slots

Name Type Description
onViewUpdate View update object Signals that the internal process of this view has ended successfully (this does not include the rendering process).
error Error object|undefined|null Returns an Error object, if an error occured while processing the latest inputs, otherwise undefined or null.

Slot options

Config object

The configuration object of this component.

Name Type Default Description
wrapperClass String A css class name that can be used as selector for the entire component.
size Object A size object that contains width (optional) and height (mandatory) as css values (px, %, em, rem or blank). The value can be a string or a number. It defines the dimension of the maplayer component.

Example:

{
    height: 300,
    width: '100%'
}

preferCanvas Boolean See leaflet API Reference.
attributionControl Boolean See leaflet API Reference.
zoomControl Boolean See leaflet API Reference.
closePopupOnClick Boolean See leaflet API Reference.
zoomSnap Number See leaflet API Reference.
zoomDelta Number See leaflet API Reference.
trackResize Boolean See leaflet API Reference.
boxZoom Boolean See leaflet API Reference.
doubleClickZoom Boolean|String See leaflet API Reference.
dragging Boolean See leaflet API Reference.
center LatLng See LatLng & leaflet API Reference.
zoom Number See leaflet API Reference.
minZoom Number See leaflet API Reference.
maxZoom Number See leaflet API Reference. See leaflet API Reference.
maxBounds LatLngBounds See LatLngBounds & leaflet API Reference.
renderer String SVG or Canvas. See leaflet API Reference.
zoomAnimation Boolean See leaflet API Reference.
fadeAnimation Boolean See leaflet API Reference.
markerZoomAnimation Boolean See leaflet API Reference.
transform3DLimit Number See leaflet API Reference.
inertia Boolean See leaflet API Reference.
inertiaDeceleration Number See leaflet API Reference.
inertiaMaxSpeed Number See leaflet API Reference.
easeLinearity Number See leaflet API Reference.
worldCopyJump Boolean See leaflet API Reference.
maxBoundsViscosity Number See leaflet API Reference.
keyboard Boolean See leaflet API Reference.
keyboardPanDelta Integer See leaflet API Reference.
scrollWheelZoom Boolean|String See leaflet API Reference.
wheelDebounceTime Integer See leaflet API Reference.
wheelPxPerZoomLevel Integer See leaflet API Reference.
tap Boolean See leaflet API Reference.
tapTolerance Integer See leaflet API Reference.
touchZoom Boolean|String See leaflet API Reference.
bounceAtZoomLimits Boolean See leaflet API Reference.
tileLayers TileLayer[] An array of TileLayer elements, with each element defining a tile layer for the map. Each definition must be unique.
markerLayers MarkerLayer[] An array of MarkerLayer elements, with each element defining a marker for the map. Each definition must be unique.
geoJsonLayers GeoJsonLayer[] An array of GeoJsonLayer elements, with each element defining a layer based on GeoJSON for the map. Each definition must be unique.

TileLayer object

A tile layer defines how to get tiles from a map tile provider and display them. A map tile provider can be defined via a name (see Leaflet-providers) or url.

Name Type Default Description
provider String This option enables one to use a specific identifier to easily define a tile layer. Some identifiers may pre-define some options. One can overwrite these by setting them in this options object. Some tile map providers need additional options, which can be set in this options object directly (e.g. api token). Please do not use reserved option names. For the identifiers & additional options see Leaflet-providers.
Please note: Do not use this together with the url option.
url String This string needs to be a valid URI template (RFC 6570), which points to the tile data of the map tile provider.
E.g. http://{s}.somedomain.com/somefolder/{z}/{x}/{y}{r}.png?{additionalParam} with

uri param param type description
s reserved subdomains, will be set by leaflet
z reserved zoom level, will be set by leaflet
x reserved the horizontal coordinate of the tile, will be set by leaflet
y reserved the vertical coordinate of the tile, will be set by leaflet
r reserved, optional resolution of the tile, will be set by leaflet
additionalParam optional additional options, which can be set in this options object directly (e.g. api token), please do not use reserved option names

Also see leaflet API Reference.
Please note: Do not use this together with the provider option.

minZoom Integer See leaflet API Reference.
maxZoom Integer See leaflet API Reference.
maxNativeZoom Integer See leaflet API Reference.
minNativeZoom Integer See leaflet API Reference.
subdomains String|String[] See leaflet API Reference.
errorTileUrl String See leaflet API Reference.
zoomOffset Integer See leaflet API Reference.
tms Boolean See leaflet API Reference.
zoomReverse Boolean See leaflet API Reference.
detectRetina Boolean See leaflet API Reference.
crossOrigin Boolean See leaflet API Reference.
tileSize Integer|Point Defines the size of the tile in pixel. An Integer value will define width & height, a Point object defines the width as x & the height as y. See Point & leaflet API Reference.
opacity Percent See Percent & see leaflet API Reference.
updateWhenIdle Boolean See leaflet API Reference.
updateWhenZooming Boolean See leaflet API Reference.
updateInterval Integer See leaflet API Reference.
zIndex Integer See leaflet API Reference.
bounds LatLngBounds See LatLngBounds & leaflet API Reference.
className String See leaflet API Reference. See leaflet API Reference.
keepBuffer Integer See leaflet API Reference.

MarkerLayer object

A marker layer places icons on the map. A marker layer can be defined statically or template-like. A template-like marker layer uses the maplayer-view-data to generate the final markers and some options need to use the Odin Path w/ parsing type to point to the final value to use (dataPath, lat, lng), other options may be set directly in this config object or also point to a value in maplayer-view-data.

Name Type Default Description
icon Icon object The icon to use for the markers.
popup Popup object Defines a popup (template) and its content for all markers.
dataPath Odin Path w/o parsing A path to the data to use for all template-like markers. The path must result in an array with objects (each object defines a marker). The resulting potion of maplayer-view-data will be used to get the values of all other options that uses the Odin Path w/ parsing type.
Please note: Using the Odin Path w/ parsing type for the lat & lng options requires the definition of this option.
lat Number|Odin Path w/ parsing The value for the latitude (between -90 and 90, both inclusive) for a static or Odin Path w/ parsing for a template-like marker.
Please note: Using Odin Path w/ parsing requires the lng option to be of the same type.
lng Number|Odin Path w/ parsing The value for the longitude (between -180 and 180, both inclusive) for a static or Odin Path w/ parsing for a template-like marker.
Please note: Using Odin Path w/ parsing requires the lat option to be of the same type.
draggable Boolean|Odin Path w/ parsing See leaflet API Reference.
keyboard Boolean|Odin Path w/ parsing See leaflet API Reference.
title String|Odin Path w/ parsing See leaflet API Reference.
alt String|Odin Path w/ parsing See leaflet API Reference.
zIndexOffset Integer|Odin Path w/ parsing See leaflet API Reference.
opacity Percent|Odin Path w/ parsing See Percent & see leaflet API Reference.
riseOnHover Boolean|Odin Path w/ parsing See leaflet API Reference.
riseOffset Integer|Odin Path w/ parsing See leaflet API Reference.
interactive Boolean|Odin Path w/ parsing See leaflet API Reference.
attribution String|Odin Path w/ parsing See leaflet API Reference.

GeoJsonLayer object

A GeoJsonLayer displayes geometric objects on the map that are defined by GeoJSON data. It also features the ability to render them as a choropleth map.

Name Type Default Description
dataPath Odin Path w/o parsing A path to the data to use. The path must result in a valid GeoJSON data structure that will be used for the rendering.
popup Popup object Defines a popup (template) and its content for all GeoJSON feature objects.
choropleth Choropleth object Defines the choropleth map. Can only be used if the GeoJSON data contains feature objects.
attribution String See leaflet API Reference.
style Pathstyle object An object with styling information for each GeoJSON feature object.

Choropleth object

Defines how the choropleth map will be rendered. Uses the Leaflet Choropleth plugin.

Name Type Default Description
valueProperty String A reference to the value that should be used as scaling value. The reference must be a key that is valid for each properties section of each GeoJSON feature object.
mode String The scaling computation mode. quantile, equidistant or k-means.
scale Boolean true true, if the scale should be computed automatically, otherwise false.
steps Integer The number of breaks of the scaling.
Please note: if the scale option is false, then the this option defines how many elements are in the colors option.
colors Array An array of strings. Each String must be a valid html color.
Please note: if the scale option is false, then the this option must contain as many elements as the steps option states.

LatLng object

An object that contains latitude and longitude.

Example:

{
    lat: 15.1, lng: 103.54
}

Name Type Default Description
lat Number The value for the latitude (between -90 and 90, both inclusive).
lng Number The value for the longitude (between -180 and 180, both inclusive).

LatLngBounds object

An array that contains exactly 2 LatLng objects.

Example:

[{
    lat: 15.1, lng: 103.54
}, {
    lat: 20.8, lng: 105.3
}]

Name Type Default Description
first LatLng The values for the top-left corner.
second LatLng The values for the bottom-right corner.

Point object

An object representing a point with a x & y value.

Example:

{
    x: 10, y: 20
}

Name Type Default Description
x Integer The value for x.
y Integer The value for y.

Icon object

The definition of an icon. An icon can be defined either as a div element with a specific style (see leaflet API Reference) or with an url.

Name Type Default Description
iconSize Integer|Point Defines the size of the icon in pixel. An Integer value will define width & height, a Point object defines the width as x & the height as y. See Point & leaflet API Reference.
iconAnchor Point See Point & leaflet API Reference.
popupAnchor Point See Point & leaflet API Reference.
attribution String See leaflet API Reference.
className String See leaflet API Reference.
Please note: Defining a div icon requires the definition of this option, but url icons can use this option, too. If one wants a div icon, then the iconUrl option should not be defined.
html String See leaflet API Reference.
Please note: Only for div icons.
bgPos Point See Point & leaflet API Reference.
Please note: Only for div icons.
iconUrl String See leaflet API Reference.
Please note: Defining a url icon requires the definition of this option.
iconRetinaUrl String See leaflet API Reference.
Please note: Only for url icons.
shadowUrl String See leaflet API Reference.
Please note: Only for url icons.
shadowRetinaUrl String See leaflet API Reference.
Please note: Only for url icons.
shadowSize Integer|Point Defines the size of the icons shadow in pixel. An Integer value will define width & height, a Point object defines the width as x & the height as y. See Point & leaflet API Reference.
Please note: Only for url icons.
shadowAnchor Point See Point & leaflet API Reference.
Please note: Only for url icons.

Pathstyle object

Defines all styling options for vector-based overlays. E.g. used in GeoJsonLayer.

Name Type Default Description
stroke Boolean See leaflet API Reference.
color String See leaflet API Reference.
weight Integer See leaflet API Reference.
opacity Percent See Percent & see leaflet API Reference.
lineCap String butt, round, square or inherit. See leaflet API Reference.
lineJoin String butt, round, square or inherit. See leaflet API Reference.
dashArray String none, inherit or any other valid stroke dash pattern. See leaflet API Reference.
dashOffset String inherit or any other valid stroke dash offset. See leaflet API Reference.
fill Boolean See leaflet API Reference.
fillColor String See leaflet API Reference.
fillOpacity Percent See Percent & see leaflet API Reference.
fillRule String nonzero, evenodd or inherit. See leaflet API Reference.
className String See leaflet API Reference.
interactive Boolean See leaflet API Reference.
attribution String See leaflet API Reference.

Popup object

The definition of a popup.

Name Type Default Description
title String|Odin Path w/ parsing The title of the popup. Can be defined statically or template-like with the Odin Path w/ parsing type. The data potion that will be queried is defined by the object that also defines this popup. E.g. for a static marker the data potion will be the whole maplayer-view-data, for a template-like marker it will be the data potion that resulted by quering the MarkerLayer.dataPath option.
errorText String A string to show if the popup content couldn't be generated. A default value is provided.
content String|Object The definition of the content. Can be a string or an view component.

content usage
Text
"content": "Just a plain simple string to display."
Plain text
"content": {
    "dataPath": "/plaintextData",
    "component": {
        "view": "plaintext",
        "config": {...}
    }
}
content.dataPath = The data potion that will be queried is defined by the object that also defines this popup. E.g. for a static marker the data potion will be the whole maplayer-view-data, for a template-like marker it will be the data potion that resulted by quering the MarkerLayer.dataPath option.
content.component.config = see plaintext-view
Table
"content": {
    "dataPath": "/tableData",
    "component": {
        "view": "table",
        "config": {...}
    }
}
content.dataPath = The data potion that will be queried is defined by the object that also defines this popup. E.g. for a static marker the data potion will be the whole maplayer-view-data, for a template-like marker it will be the data potion that resulted by quering the MarkerLayer.dataPath option.
content.component.config = see table-view
Chart
"content": {
    "dataPath": "/chartData",
    "component": {
        "view": "chart",
        "config": {...}
    }
}
content.dataPath = The data potion that will be queried is defined by the object that also defines this popup. E.g. for a static marker the data potion will be the whole maplayer-view-data, for a template-like marker it will be the data potion that resulted by quering the MarkerLayer.dataPath option.
content.component.config = see chart-view

maxWidth Integer See leaflet API Reference.
minWidth Integer See leaflet API Reference.
maxHeight Integer See leaflet API Reference.
autoPan Boolean See leaflet API Reference.
autoPanPaddingTopLeft Point See Point & leaflet API Reference.
autoPanPaddingBottomRight Point See Point & leaflet API Reference.
autoPanPadding Point See Point & leaflet API Reference.
keepInView Boolean See leaflet API Reference.
closeButton Boolean See leaflet API Reference.
closeOnClick Boolean See leaflet API Reference.
autoClose Boolean See leaflet API Reference.
className String See leaflet API Reference.
offset Point See Point & leaflet API Reference.
attribution String See leaflet API Reference.

Utilities

All ODIN utilities contain basic features which provide helpful assistance for common tasks in dealing with features of the ODIN library, either as component author or user of the ODIN components in context of JavaScript code or templates.

Normalized data structures

Most data structures are special in terms of their structure. The ODIN library tries to leverage this by providing a normalized definition of data structures that most ODIN components support and some components produce for compatibility reasons.

The table below illustrates four supported data structures. Each structure is a combination of container-like data types (object or array) and concepts (data tuples or data series). Cell values can be of any type that suits a component needs.

as objects as arrays
as data tuples Array with object tuples
[
    { "first": 1, "second": 4, "third": 7, "fourth": 10 },
    { "first": 2, "second": 5, "third": 8, "fourth": 11 },
    { "first": 3, "second": 6, "third": 9, "fourth": 12 }
]
Each element of the array is an object and in a relational database system one element represents a row (data tuple). The keys in each object are the columns and the property values are the cell values. If a cell value is missing, it must be treated as undefined or null.
Array with array tuples
[
    [ 1, 4, 7, 10 ],
    [ 2, 5, 8, 11 ],
    [ 3, 6, 9, 12 ]
]
Each element of the array is a sub-array and in a relational database system one element represents a row (data tuple). The indicies in each sub-array are the columns and the elements of the sub-array are the cell values. Some components may enforce an equality-length check over all sub-arrays. A missing cell value should be expressed as undefined or null.
as data series Object with series per property
{
    "first":   [  1,  2,  3 ],
    "second":  [  4,  5,  6 ],
    "third":   [  7,  8,  9 ],
    "fourth":  [ 10, 11, 12 ]
}
Each property of the object has a value that is an array and in a relational database system one property represents a column (data series). The keys are the columns and the property value contains the cell values in an array. The indicies of that array are the row indicies. Some components may enforce an equality-length check over all property values. A missing cell value should be expressed as undefined or null.
Array with array series
[
    [  1,  2,  3 ],
    [  4,  5,  6 ],
    [  7,  8,  9 ],
    [ 10, 11, 12 ]
]
Each element of the array is a sub-array and in a relational database system one element represents a column (data series). The indicies in each sub-array are the rows and the elements of the sub-array are the cell values. Some components may enforce an equality-length check over all sub-arrays. A missing cell value should be expressed as undefined or null.

Components that consumes normalized data structures must state which ones they are able to use and if more than one, then they must use configuration options (booleans) to differentiate the data structures:

  • elementsAreObjects to distinguish between container-like data types (true for objects otherwise false for arrays) and
  • dataContainsTuples to distinguish between concepts (true for data tuples otherwise false for data series).
Data tuples should be expected as default.

Components that produces normalized data structures must state which ones they are able to create and if more than one, then they must use configuration options (booleans) to differentiate the data structures:

  • mapToObjects to distinguish between container-like data types (true for objects otherwise false for arrays) and
  • mapToTuples to distinguish between concepts (true for data tuples otherwise false for data series).
Data tuples should be expected as default.

odin

A global object, that contains all ODIN library utilities.

Functions

Function Returns Description
triggerOnViewUpdate( <ODIN component> comp) Triggers the onViewUpdate output slot for ODIN components (views only) and passes a View update object to it.
createErrorObj( <ODIN component> comp, <String> msg, <Error|String> cause?) Error object Creates an Error object. The cause may be any error-like object with a message property or a string.
copyObject( <Object> src, <Function> filter?, <Function> transform?) Object Creates a shallow copy of the given object. filter can be used to define which properties should be transferred (the function must return true if the property should be included, otherwise false). transform may be used to alternate the property value of the source object and transfer the alternation instead (useful if one wants to copy an object deeply). Both, filter and transform functions, will receive three parameters: the key as string, the property value and the source object.

Example:

var mySrcObj = { first: 'foo', second: null };
var copy = odin.copyObject(mySrcObj, function (key, value, src) {
    // omit 'empty' properties
    return value !== undefined && value !== null;
}, function (key, value, src) {
    // add something to every string
    return odin.check.isString(value) ? value + 'bar' : value;
});
console.log(copy); // prints: { first: 'foobar' }

objectToArray( <Object> src, <Function> toIndexMapper?) Array Transforms an object to an array. toIndexMapper may be used to define the index of a certain property. The function will receive three parameters: the key as string, the property value and the source object. If a position shall be defined by the algorithm (add to the current last position of the array), the function must return undefined. In all other cases the function defines the position by returning an array index. If this position is occupied, then the algorithm will overwrite the value at this position. Depending of how the function is implemented, the resulting array may contain undefined positions. If toIndexMapper is not defined, it would be like a function which returns always undefined. The order of the elements in the resulting array is not guaranteed by the algorithm.

Example:

var obj = { first: 'foo', second: null };
var array = odin.objectToArray(obj, function (key, value, src) {
    // 'first' should be at position 0, 'second' should be at position 2
    return key === 'first' ? 0 : (key === 'second' ? 2 : undefined);
});
console.log(array); // prints: [ 'foo', undefined, null ]

arrayToObject( <Array> src, <Function> toKeyMapper?) Object Transforms an array to an object. toKeyMapper may be used to define the property keys of a certain element. The function will receive three parameters: the element, the index and the source object. If a position (or element) should be omitted, the function must return undefined. In all other cases the function defines the property key by returning a string. If this key is occupied, then the algorithm will overwrite the property value for this key. If toKeyMapper is not defined, it would be like a function which returns the index of the element as key.

Example:

var array = [ 'foo', undefined, null ];
var obj = odin.objectToArray(array, function (elem, idx, src) {
    // position 0 should be 'first', position 2 should be 'second'
    return idx === 0 ? 'first' ? (idx === 2 ? 'second' : undefined);
});
console.log(obj); // prints: { first: 'foo', second: null }

mergeArrays( <Array> first, <Array> second) Array Combines two array into a new array. Elements that are present in both arrays won't appear twice in the new array. The comparison is based on ===.

Example:

var first = [ 'foo', 1 ];
var second = [ 'foo', 2 ];
var merged = odin.mergeArrays(first, second);
console.log(merged); // prints: [ 'foo', 1, 2 ]

mergeObjects( <Object> first, <Object> second) Object Combines two objects into a new object. Property keys that are present in both objects don't overwrite each others property value. Instead, the property value of first will be given a higher priority.

Example:

var first = { foo: 'bar', bar: 2 };
var second = { foo: 'foo', foo: 1 };
var merged = odin.mergeObjects(first, second);
console.log(merged); // prints: { foo: 'bar', foo: 1, bar: 2 }

getObjectValues( <Object> obj) Array Puts every property value of an object in a new array. The order of the elements in the resulting array is not guaranteed by the algorithm.

odin.check

A global object, that contains useful functions for type checking.

Functions

Function Returns Description
isBoolean( <*> value) Boolean Checks if the given value is a primitive boolean or an object Boolean (prototype). Returns true, if the check was successful, otherwise false.
isNumber( <*> value) Boolean Checks if the given value is a primitive number or an object Number (prototype). Returns true, if the check was successful, otherwise false.
isString( <*> value) Boolean Checks if the given value is a primitive string or an object String (prototype). Returns true, if the check was successful, otherwise false.

odin.parse

A global object, that contains useful functions for type parsing.

Functions

Function Returns Description
toBoolean( <*> value) Boolean Parses a given value to a primitive boolean. Type checks include primitive and object checks.

value type conversion test parsing result
String value === 'true' test is true → returns true, otherwise false
Number value === 1 test is true → returns true, otherwise false
Boolean returns a primitive version of value
Any other type returns false

toNumber( <*> value) Number Parses a given value to a primitive number. Type checks include primitive and object checks.

value type conversion test parsing result
String A strict test based of the syntax of JSON numbers test is true → parses the string with parseFloat(value) and returns the number, otherwise NaN
Number returns a primitive version of value
Boolean value === true test is true → returns 1, otherwise 0
Any other type returns NaN

toString( <*> value) String Parses a given value to a primitive string. Type checks include primitive and object checks.

value type parsing result
String returns a primitive version of value
Number returns value.toString()
Boolean returns value.toString()
Any other type returns an empty string

odin.path

A global object, that contains functions and properties for handling the ODIN path notation (Path tokens and Path object).

Functions

Function Returns Description
isPathTokens( <*> obj) Boolean true if the given parameter has the type Path tokens, otherwise false.
create( <Path tokens> pathTokens) Path object Creates a Path object from the given Path tokens. This function may throw errors.

Errors:

Name Condition
TODO TODO

resolve( <Path object> pathObj, <*> obj) * Extracts a value from a given value (obj) with the given Path object. If a parsing option is specified, then TODO. This function may throw errors.

Errors:

Name Condition
TODO TODO

Properties

Property Type Description
schemaPart Json Schema Part Defines a rule according the definition of Path tokens without a parsing option (see Odin Path w/o parsing).
schemaPartWithParse Json Schema Part Defines a rule according the definition of Path tokens with an optional parsing option (see Odin Path w/ parsing).

odin.validate

A global object, that contains useful functions and properties for validation tasks.

TODO in den components erwähnen dass json schema usw. genutzt wird

Functions

Function Returns Description
withSchema( <Json Schema> schema, <*> data) Errors|undefined Validates a value (data) based on a given Json Schema. Returns a collection of validation errors if the validation fails, otherwise undefined. If the schema is in itself flawed, then an error object will be returned.

Example:

var data = [ 'not a valid "Array with object tuples" data structure' ];
var schema = odin.validate.schema.dataObjectTuples;
var errors = odin.validate.withSchema(schema, data);
if (errors) {
    console.error(errors);
    return;
}

Uses ajv as Json Schema validator.

odin.validate.schema

A property of odin.validate, which contains common Json Schemata. All schemata are based on Draft-06.

Properties

Property Type Description
dataObjectTuples Json Schema A Json Schema that one can use to validate a value according to the definition of a Array with object tuples data structure (see normalized data structure).
dataObjectSeries Json Schema A Json Schema that one can use to validate a value according to the definition of a Object with series per property data structure (see normalized data structure). Equality-length check of the property values is not covered by this schema.
dataArrays Json Schema A Json Schema that one can use to validate a value according to the definition of a Array with array tuples and Array with array series data structures (see normalized data structure). Equality-length check of the sub-arrays is not covered by this schema.
geojson Json Schema A Json Schema that one can use to validate a value according to the definition of the RFC 7946: The GeoJSON Format.

odin.validate.schemaPart

A property of odin.validate, which contains common Json Schemata Parts. Parts are validation rule definitions that can be used in a JavaScript context to replace common rules in a schema (meaning: less code).

Properties

for Strings

Property Type Description
stringEmptyDefault Json Schema Part Defines a rule with the type string and an empty string as default.
minString Json Schema Part Defines a rule with the type string and a minimum length of 1.
urlString Json Schema Part Defines a rule with the type string and a format url (see here for more information).
uriTemplateString Json Schema Part Defines a rule with the type string and a format uri-template (see here for more information).
jsonPointerString Json Schema Part Defines a rule with the type string and a format json-pointer (see here for more information).
notJsonPointerString Json Schema Part Defines a rule with the type string, a minimum length of 1 and is not a valid json-pointer (see here for more information).
hexColor Json Schema Part Defines a rule with the type string and a pattern to check if the string is a hexadecimal notation of a web color. Notation syntax is based on CSS Color Module Level 4 (Draft).
rgbColor Json Schema Part Defines a rule with the type string and a pattern to check if the string is a functional notation (rgb/rgba) of a web color. Notation syntax is based on CSS Color Module Level 4 (Draft).
hslColor Json Schema Part Defines a rule with the type string and a pattern to check if the string is a functional notation (hsl/hsla) of a web color. Notation syntax is based on CSS Color Module Level 4 (Draft).
htmlColor Json Schema Part Defines a rule with the type string and one of the web color definitions: hexColor, rgbColor, hslColor, a string containing only alpha characters (for the color keywords) or one of the strings transparent or currentcolor. Notation syntax and other definitions are based on CSS Color Module Level 4 (Draft).

for Numbers

Property Type Description
positiveNumber Json Schema Part Defines a rule with the type number and an exclusiveMinimum of 0.
zeroPositiveNumber Json Schema Part Defines a rule with the type number and a minimum of 0.
negativeNumber Json Schema Part Defines a rule with the type number and an exclusiveMaximum of 0.
zeroNegativeNumber Json Schema Part Defines a rule with the type number and a maximum of 0.
positiveInteger Json Schema Part Defines a rule with the type integer and an exclusiveMinimum of 0.
zeroPositiveInteger Json Schema Part Defines a rule with the type integer and a minimum of 0.
negativeInteger Json Schema Part Defines a rule with the type integer and an exclusiveMaximum of 0.
zeroNegativeInteger Json Schema Part Defines a rule with the type integer and a maximum of 0.
percent Json Schema Part Defines a rule with the type number, a minimum of 0 and a maximum of 1.

for Booleans

Property Type Description
booleanDefaultTrue Json Schema Part Defines a rule with the type boolean and true as default.
booleanDefaultFalse Json Schema Part Defines a rule with the type boolean and false as default.

Misc

This section features all common objects that are used throughout the ODIN library.

Error object

The definition of an error object generated by odin.createErrorObj.

Properties

Property Type Description
componentName String The name of the ODIN component, which had an error.
message String A description of the error.
cause String|undefined A description of why the error happened.

Path tokens

TODO

Odin Path w/o parsing

TODO

Odin Path w/ parsing

TODO

Path object

TODO

View update object

The definition of an view update object generated by odin.triggerOnViewUpdate. This object should only be used, if a view component wants to signal an update.

Properties

Property Type Description
componentName String The name of the ODIN component.
id Number An unique identifier for the view update.
ODIN library is open source
Find us on GitHub
Maintained by incowia GmbH
Get in touch with us