Skip to content

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
    // define providers
    var providers = [{
        name:'Elastic',
        provider:'elasticsearch',
        url:'https://chartfactor.com/elastic/'
    }]

    // Set the data provider list to chartfactor
    cf.setProviders(providers);

getProviderByConfig(object)

Returns a provider object that matches the object passed as parameter.

1
    let provider = cf.getProviderByConfig({ name: 'Elastic' })

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 Aktive objects representing all visualizations / queries registered under the instance.

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
    cf.isAppLoaded().then(() => {
        console.log('All visualization are ready!')
    })

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.

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
    let moment = cf.getDependency('moment');

    console.log(moment.now())

Here's the list of dependencies that are available from this method: