The ChartFactor Object (CF)¶
This is the main object of the Toolkit. It represents the entry point and it will be available from the core library as soon as it is loaded.
From this object we obtain all other objects used to build our queries or visuals. These objects have their own section.
Let's take a look at some of the main methods of this object:
setProviders(providers)¶
Loads a set of providers according to the configuration passed as parameter. It takes an array of objects
1 2 3 4 5 6 7 8 9 |
|
registerProvider(provider)¶
Same as setProviders
but it register only one provider at a time. It is specially useful when a provider needs to be updated, in which case, it should be unregistered first, and recreated again.
1 2 3 4 5 |
|
unregisterProvider(providerConfig)¶
Allows to remove an existing provider.
1 |
|
getProviderByConfig(object)¶
Returns a provider object that matches the object passed as parameter.
1 |
|
async getDatasourceMetadata(source, provider)¶
Returns the metadata of the given datasource.
1 2 3 4 |
|
The meta.objectFields
will contain an array with the field specification as below:
provider(name)¶
It creates and return a new Aktive instance with the provider passed as parameter set. Is the starting point when creating a new visualization or query.
create(name)¶
It also creates and return a new Aktive instance. This method is used when we're creating a visualization without a provider that is going to be used only to load injected data or to create a non-query visualizations such as Text Search or the Interaction Manager
It takes as optional parameter a string that is useful when performing Multiple Queries
getAllVisualizations()¶
It returns an array of all Aktive objects representing all visualizations and queries registered under the instance, including child visualizations such as column statistics and column filter widgets in a Raw Data Table.
getTopLevelVisualizations()¶
It returns an array of Aktive objects representing the visualizations and queries registered under the instance, excluding child visualizations.
getChildVisualizations(parentElementId)¶
It returns an array of Aktive objects representing all child visualizations and queries registered under a parent visualization represented by the parentElementId
parameter. If no parentElementId
is provided, it returns the child visualizations of all available parent visualizations. Examples of child visualizations are column statistics and column filters in the Raw Data Table.
getVisualization(elementId)¶
Returns the Aktive instance representing the visualization using the elementId passed as parameter.
isAppLoaded(warnSecs, errorSecs)¶
Returns a promise that will be resolved when the entire application, which translate into all visualizations and/or queries registered under the cf object, has been loaded, which means that they already received the response from the server.
It takes two optional parameters: The first one is the amount of time in seconds that it'll wait before warning the user that the application is taking more than expected to load by default is 7 seconds. The second parameter is the total amount of time in seconds that the application will wait before stopping the time checking. Default to 13.
1 2 3 |
|
getIManager()¶
Returns the Aktive instance representing the Interaction Manager if it exists in the application or dashboard.
getSupportedCharts()¶
Returns the full list of visualization types that are supported depending on the visualization libraries that are loaded. It is useful to verify if they are loaded correctly before using them.
tooltip¶
The ChartFactor tooltip utility object. Please refer to the Tooltip object.
clear()¶
Delete all registered visualizations.
getDependency(name)¶
ChartFactor depends on some third-party libraries that can be reused so we don't have to load them from a CDN if we don't need to. We just need to pass the name and assign the object to a variables:
1 2 3 |
|
Here's the list of dependencies that are available from this method:
- uuid
- lodash 4.17.11
- chroma-js 1.4.1
- jquery 3.3.1
- numeral 2.0.6
- moment 2.23.0
- utils: these are ChartFactor functions within the
utils
dependency that can be used in different scenarios. Example:
1 2 3 4 5 6 7 |
|
The ChartFactor utils
functions are described below.
formatNumericValue¶
This function takes three parameters (value, field, isBigNumber)
which only the first one is mandatory.
value
is the value to be formattedfield
is an object that will contains three properties:{ type: 'NUMBER', currency: '£', displayFormat: '0.0[,]00' }
isBigNumber
specifies if the given number it is a big number
The type
could be MONEY, INTEGER, NUMBER or PERCENT.
See the following examples:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
BigNumberFormatter¶
This function is a shorcut of the formatNumericValue function, that allows you to format any big number. See the following examples.
1 2 3 4 5 |
|
isMobileDevice¶
This function determines if is a mobile device based on the user agent. However this may not work if browser apps modify they user agent. See de developer mozilla for more information.
1 2 3 4 5 |
|
getBoolValue¶
This function returns true if the parameter pased is either a boolean with true
value or a string with "true"
value. It returns false otherwise. See the examples below.
1 2 3 4 5 6 7 8 9 10 |
|
renameKeys¶
This function is useful when you need to rename some keys inside of an object. It takes three mandatory parameters (object, keys, newKeys)
. See the examples below.
1 2 3 4 5 6 7 8 9 10 11 12 |
|
remove(elementId)¶
Removes the Aktive instance representing the visualization or query, using the elementId passed as parameter.