API Reference
Table of contents
- function: nucleus(app[, instanceConfig])
- class: AppSelections
- interface: BaseConfig
- interface: Configuration
- interface: Context
- interface: CreateConfig
- type
Field
= <[string]|qae.NxDimension
|qae.NxMeasure
|[LibraryField]> - interface: GetConfig
- interface: LibraryField
- interface: LoadType(type, env)
- class: Nucleus
- class: SupernovaController
- interface: ThemeInfo
- interface: TypeInfo
API
function: nucleus(app[, instanceConfig])
app
<enigma.Doc
>instanceConfig
<Configuration>returns:
<Nucleus>
Initiates a new Nucleus
instance using the specified app
.
import nucleus from '@nebula.js/nucleus';
const n = nucleus(app);
n.render({ id: 'abc' });
nucleus.createConfiguration(configuration)
configuration
<Configuration> The configuration objectreturns:
<nucleus>
Creates a new nucleus
scope bound to the specified configuration
.
The configuration is merged with all previous scopes.
import nucleus from '@nebula.js/nucleus';
// create a 'master' config which registers all types
const m = nucleus.createConfiguration({
types: [
{
name: 'mekko',
version: '1.0.0',
load: () => Promise.resolve(mekko),
},
],
});
// create an alternate config with dark theme
// and inherit the config from the previous
const d = m.createConfiguration({
theme: 'dark',
});
m(app).render({ type: 'mekko' }); // will render the object with default theme
d(app).render({ type: 'mekko' }); // will render the object with 'dark' theme
nucleus(app).render({ type: 'mekko' }); // will throw error since 'mekko' is not a register type on the default instance
class: AppSelections
appSelections.mount(element)
element
<HTMLElement
>
Mounts the app selection UI into the provided HTMLElement
selections.mount(element);
appSelections.unmount()
Unmounts the app selection UI from the DOM
selections.unmount();
interface: BaseConfig
element
<HTMLElement
>options
<Object>
interface: Configuration
interface: Context
interface: CreateConfig
- extends: <BaseConfig>
Field
= <string|qae.NxDimension
|qae.NxMeasure
|LibraryField>
type interface: GetConfig
- extends: <BaseConfig>
id
<string>
interface: LibraryField
qLibraryId
<string>type
<'dimension'
|'measure'
>
interface: LoadType(type, env)
class: Nucleus
nucleus.context(ctx)
ctx
<Context> The context to update.
Updates the current context of this nucleus instance. Use this when you want to change some part of the current context, like theme.
// change theme
n.context({ theme: 'dark' });
// limit constraints
n.context({ constraints: { active: true } });
nucleus.render(cfg)
cfg
<CreateConfig|GetConfig> The render configuration.returns:
<Promise<SupernovaController>> A controller to the rendered supernova
Renders a supernova into an HTMLElement.
// render from existing object
n.render({
element: el,
id: 'abcdef',
});
// render on the fly
n.render({
type: 'barchart',
fields: ['Product', { qLibraryId: 'u378hn', type: 'measure' }],
});
nucleus.selections()
returns:
<Promise<AppSelections>>
Gets the app selections of this instance.
const selections = await n.selections();
selections.mount(element);
class: SupernovaController
A controller to further modify a supernova after it has been rendered.
const ctl = await nucleus(app).render({
element,
type: 'barchart',
});
ctl.destroy();
supernovaController.destroy()
Destroys the supernova and removes if from the the DOM.
const ctl = ctl.destroy();
interface: ThemeInfo
id
<string> Theme identifierload
<Function> A function that should return a Promise that resolve to a raw JSON theme