Files
nebula.js/docs/nucleus-reference.md
2020-03-16 18:29:31 +01:00

6.6 KiB

id, title
id title
nucleus-reference API Reference

Table of contents

API

function: nucleus(app[, instanceConfig])

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)

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

type Field= <string|qae.NxDimension|qae.NxMeasure|LibraryField>

interface: GetConfig

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)

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()

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 identifier
  • load <Function> A function that should return a Promise that resolve to a raw JSON theme

interface: TypeInfo