Providers are global entities used for a variety of applications such as logging, fetching data from url and so forth. To access the providers:
- In ES6
import {viewProviders} from 'd3-view'
- In common JS
d3.viewProviders
The logger is available at
d3.viewProviders.logger
Activate or deactivate the logger debug handler. The active
parameter can be true
, activate debug logging,
false
deactivate debug logging or a function, in which case it activates debug logging with a custom handler (rather than the default console).
Retrieve data from urls
d3.viewProviders.fetch
Handlebars is required when rendering templates with static context. To use handlebars, one can either include it as a script in the page or load it via require and store it as a view provider:
import {viewProviders} from 'd3-view';
require('handlebars').then(handlebars => {
viewProviders.compileTemplate = handlebars.compile;
});
Function for asynchronously loading modules
require(name).then(...)
The function has the libs
map for mapping name to url if needed:
require.libs.set('marked', '/assets/marked.min.js');
Function for resolving library names.