nebula.js: stardust
Product and framework agnostic integration API for Qlik's Associative Engine, commonly used with enigma.js. Consider using the qlik-embed toolkit for an easier embedding experience, whilst building on the same core technologies.
Provides conversion functionality to extensions.
Properties
- hypercube hyperCubeConversionRequiredAvailable since: 1.1.0
Provides conversion functionality to extensions with hyperCubes.
hypercube properties
- hyperCubeConversion interfaceRequiredAvailable since: 1.1.0
-
Conversion
import { conversion } from '@nebula.js/stardust';
export default function() { return { qae: { ... importProperties: ( exportFormat, initialProperties ) => conversion.hyperCube.importProperties(exportFormat, initialProperties), exportProperties: ( fullPropertyTree ) => conversion.hyperCube.exportProperties(fullPropertyTree) }, ... };}Initiates a new Embed instance using the specified enigma app.
Parameters
- app qix.DocRequired
- instanceConfig Configuration
instanceConfig properties
- anything object
- context Context
Settings for the rendering instance
context properties
-
constraints properties
- active boolean
Whether or not active constraints are on. Should block any active interaction by users, ie: scroll, click
- edit boolean
Whether or not edit actions are available. Should block any edit action.
- passive boolean
Whether or not passive constraints are on. Should block any passive interaction by users, ie: tooltips
- select boolean
Whether or not select constraints are on. Should block any selection action. Implied when active is true.
-
- dataViewType string
Type used for toggling to the data view (toggleDataView) This type need to be registered as well
- deviceType string
- disableCellPadding boolean
- interactions Interactions
interactions properties
- active boolean
Whether or not active interactions are on. Allows active interaction by users, ie: scroll, click
- edit boolean
Whether or not edit actions are on. Allows edit actions.
- passive boolean
Whether or not passive interactions are on. Allows passive interaction by users, ie: tooltips
- select boolean
Whether or not select interactions are on. Allows selection actions. Implied when active is false.
-
- boolean
- language string
-
navigation properties
- functionRequiredExperimentalAvailable since: 5.4.0
Return the current sheet id
Returns- string | falseRequired
The current sheet Id. false means there is no current sheet.
-
- functionRequiredExperimentalAvailable since: 5.4.0
Navigate to the supplied sheet and emit 'sheetChanged' event if the target sheet Id is valid. This allows a navigation object to synchronize its current sheet item with the active sheet.
Parameters- stringRequired
Id of the sheet to navigate to
-
-
- theme string
-
- hostConfig object
Qlik api compatible host config, see https://github.com/qlik-oss/qlik-api-ts/blob/main/docs/authentication.md#the-host-config
- load LoadFallback
Fallback load function for missing types
load properties
- LoadFallback() functionRequired
Fallback load function for missing types
Parameters- Required
properties
- LoadType interfaceRequiredParameters
- type objectRequired
type properties
- name stringRequired
- version stringRequired
-
Returns- Promise < Visualization >Required
-
-
Returns- Promise < Visualization >Required
-
-
- themes Array< ThemeInfo >
Themes to register
- types Array< TypeInfo >
Visualization types to register
-
Returns
- Required
properties
- context() functionRequired
Updates the current context of this embed instance. Use this when you want to change some part of the current context, like theme.
Parameters- ctx ContextRequired
The context to update.
Returns- Promise < undefined >Required
-
- create() functionRequired
Creates a visualization model
Parameters- cfg CreateConfigRequired
The create configuration.
cfg properties
- type stringRequired
- fields Array< Field >
- properties qix.GenericObjectProperties
- version string
-
Returns- Promise < qix.GenericObject >Required
An engima model
-
- field() functionRequiredAvailable since: 1.1.0
Gets the listbox instance of the specified field
Parameters- fieldIdentifier string | LibraryField | QInfoRequired
Fieldname as a string, a Library dimension or an object id
Returns- Promise < FieldInstance >Required
-
- generateProperties() functionRequired
Generates properties for a visualization object
Parameters- cfg CreateConfigRequired
The create configuration.
Returns- Promise < object >Required
The objects properties
-
- getRegisteredTypes() functionRequired
Gets a list of registered visualization types and versions
Returns- Array< Object >Required
types
-
- render() functionRequired
Renders a visualization or sheet into an HTMLElement. Visualizations can either be existing objects or created on the fly. Support for sense sheets is experimental.
Parameters- cfg RenderConfigRequired
The render configuration.
cfg properties
- element HTMLElementRequired
Target html element to render in to
- extendProperties boolean
For creating objects: Whether to deeply extend properties or not. If false then subtrees will be overwritten.
- fields Array< Field >
For creating objects: Data fields to use
- id string
For existing objects: Engine identifier of object to render
- onError() function
Callback function called if an error occurs. Also called with AbortError when signal aborts.
Parameters- Required
properties
- originalError ErrorRequired
-
-
- onRender() function
Callback function called after rendering successfully
- options object
Options passed into the visualisation
- plugins Array< Plugin >
plugins passed into the visualisation
- properties qix.GenericObjectProperties
For creating objects: Explicit properties to set
- signal AbortSignal
Optional AbortSignal to cancel the render operation. When aborted, destroy() is called for cleanup before onError() is called with the AbortError.
- type string
For creating objects: Type of visualisation to render
- version string
For creating objects: Version of visualization to render
-
Returns-
A controller to the rendered visualization or sheet.
-
- selections() functionRequired
Gets the app selections of this instance.
Returns- Promise < AppSelections >Required
-
-
embed
import { embed } from '@nebula.js/stardust'const n = embed(app);n.render({ id: 'abc' });Creates a new embed scope bound to the specified configuration.
The configuration is merged with all previous scopes.
Parameters
- configuration ConfigurationRequired
The configuration object
configuration properties
- anything object
- context Context
Settings for the rendering instance
context properties
-
constraints properties
- active boolean
Whether or not active constraints are on. Should block any active interaction by users, ie: scroll, click
- edit boolean
Whether or not edit actions are available. Should block any edit action.
- passive boolean
Whether or not passive constraints are on. Should block any passive interaction by users, ie: tooltips
- select boolean
Whether or not select constraints are on. Should block any selection action. Implied when active is true.
-
- dataViewType string
Type used for toggling to the data view (toggleDataView) This type need to be registered as well
- deviceType string
- disableCellPadding boolean
- interactions Interactions
interactions properties
- active boolean
Whether or not active interactions are on. Allows active interaction by users, ie: scroll, click
- edit boolean
Whether or not edit actions are on. Allows edit actions.
- passive boolean
Whether or not passive interactions are on. Allows passive interaction by users, ie: tooltips
- select boolean
Whether or not select interactions are on. Allows selection actions. Implied when active is false.
-
- boolean
- language string
-
navigation properties
- functionRequiredExperimentalAvailable since: 5.4.0
Return the current sheet id
Returns- string | falseRequired
The current sheet Id. false means there is no current sheet.
-
- functionRequiredExperimentalAvailable since: 5.4.0
Navigate to the supplied sheet and emit 'sheetChanged' event if the target sheet Id is valid. This allows a navigation object to synchronize its current sheet item with the active sheet.
Parameters- stringRequired
Id of the sheet to navigate to
-
-
- theme string
-
- hostConfig object
Qlik api compatible host config, see https://github.com/qlik-oss/qlik-api-ts/blob/main/docs/authentication.md#the-host-config
- load LoadFallback
Fallback load function for missing types
load properties
- LoadFallback() functionRequired
Fallback load function for missing types
Parameters- Required
properties
- LoadType interfaceRequiredParameters
- type objectRequired
type properties
- name stringRequired
- version stringRequired
-
Returns- Promise < Visualization >Required
-
-
Returns- Promise < Visualization >Required
-
-
- themes Array< ThemeInfo >
Themes to register
- types Array< TypeInfo >
Visualization types to register
-
Returns
- Required
properties
- createConfiguration() functionRequired
Creates a new
embedscope bound to the specifiedconfiguration.The configuration is merged with all previous scopes.
Parameters- configuration ConfigurationRequired
The configuration object
Returns- Required
-
-
createConfiguration
import { embed } from '@nebula.js/stardust';// create a 'master' config which registers all typesconst m = embed.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 previousconst d = m.createConfiguration({ context: { theme: 'dark' }});
m(app).render({ type: 'mekko' }); // will render the object with default themed(app).render({ type: 'mekko' }); // will render the object with 'dark' themeembed(app).render({ type: 'mekko' }); // will throw error since 'mekko' is not a register type on the default instanceMocks Engima app functionality. It accepts one / many generic objects as input argument and returns the mocked Enigma app. Each generic object represents one visualisation and specifies how it behaves. For example, what layout to use the data to present.
The generic object is represented with a Javascript object with a number of properties. The name of the property correlates to the name in the Enigma model for app.getObject(id). For example, the property getLayout in the generic object is used to define app.getObject(id).getLayout(). Any property can be added to the fixture (just make sure it exists and behaves as in the Enigma model!).
The value for each property is either fixed (string / boolean / number / object) or a function. Arguments are forwarded to the function to allow for greater flexibility. For example, this can be used to return different hypercube data when scrolling in the chart.
Parameters
- genericObjects Array< object >Required
Generic objects controlling behaviour of visualizations.
- options EnigmaMockerOptions
Options
options properties
- delay numberRequired
Simulate delay (in ms) for calls in enigma-mocker.
- appMethods object
Object with methods to add to the mocked app.
-
Returns
- Promise < qix.Doc >Required
fromGenericObjects
const genericObject = { getLayout() { return { qInfo: { qId: 'qqj4zx', qType: 'sn-grid-chart' }, ... } }, getHyperCubeData(path, page) { return [ ... ]; }};const app = await EnigmaMocker.fromGenericObjects([genericObject]);Registers a callback that is called when a snapshot is taken.
Parameters
- snapshotCallback() functionRequiredParameters
- qix.GenericObjectLayoutRequired
Returns- Promise < qix.GenericObjectLayout >Required
-
onTakeSnapshot
import { onTakeSnapshot } from '@nebula.js/stardust';import { useState } from '@nebula.js/stardust';import { useLayout } from '@nebula.js/stardust';
const layout = useLayout();const [zoomed] = useState(layout.isZoomed || false);
onTakeSnapshot((copyOfLayout) => { copyOfLayout.isZoomed = zoomed; return Promise.resolve(copyOfLayout);});Registers a custom action.
Parameters
- factory() functionRequiredReturns
- Required
properties
- action ARequired
- disabled boolean
- boolean
- icon object
icon properties
- viewBox string
- shapes Array< object >Required
-
-
-
- deps Array< any >
Returns
- ARequired
useAction
import { useAction } from '@nebula.js/stardust';// ...const [zoomed, setZoomed] = useState(false);const act = useAction(() => ({ hidden: false, disabled: zoomed, action() { setZoomed(prev => !prev); }, icon: {}}), [zoomed]);useApp
import { useApp } from '@nebula.js/stardust';// ...const app = useApp();useEffect(() => { app.getAllInfos().then(infos => { console.log(infos); })}, []);Gets the layout of the app associated with this visualization.
Returns
- qix.NxAppLayoutRequired
The app layout
useAppLayout
import { useAppLayout } from '@nebula.js/stardust';// ...const appLayout = useAppLayout();console.log(appLayout.qLocaleInfo);Gets the desired constraints that should be applied when rendering the visualization.
The constraints are set on the embed configuration before the visualization is rendered and should be respected when implementing the visualization.
Returns
- Required
properties
- active boolean
Whether or not active constraints are on. Should block any active interaction by users, ie: scroll, click
- edit boolean
Whether or not edit actions are available. Should block any edit action.
- passive boolean
Whether or not passive constraints are on. Should block any passive interaction by users, ie: tooltips
- select boolean
Whether or not select constraints are on. Should block any selection action. Implied when active is true.
-
useConstraints
// configure embed to disallow active interactions when renderingembed(app, { context: { constraints: { active: true, // do not allow interactions } }}).render({ element, id: 'sdfsdf' });import { useConstraints } from '@nebula.js/stardust';// ...const constraints = useConstraints();useEffect(() => { if (constraints.active) { // do not add any event listener if active constraint is set return undefined; } const listener = () => {}; element.addEventListener('click', listener); return () => { element.removeEventListener('click', listener); };}, [constraints])Gets the device type. ('touch' or 'desktop')
Returns
- stringRequired
device type.
useDeviceType
import { useDeviceType } from '@nebula.js/stardust';// ...const deviceType = useDeviceType();if (deviceType === 'touch') { ... };Triggers a callback function when a dependent value changes.
Omitting the dependency array will have the hook run on each update and an empty dependency array runs only once.
Parameters
- effect EffectCallbackRequired
The callback.
effect properties
- EffectCallback() functionRequired
Callback function that should return a function that in turns gets called before the hook runs again or when the component is destroyed. For example to remove any listeners added in the callback itself.
Returns- void | functionRequired
-
-
- deps Array< any >
The dependencies that should trigger the callback.
useEffect
import { useEffect } from '@nebula.js/stardust';// ...useEffect(() => { console.log('mounted'); return () => { console.log('unmounted'); };}, []);
useEffect(() => { const clickHandler = () => { console.log('click') }; const button = element.querySelector('.button'); button.addEventListener('click', clickHandler); return () => { button.removeEventListener('click', clickHandler); };}, []);Gets the HTMLElement this visualization is rendered into.
Returns
- HTMLElementRequired
useElement
import { useElement } from '@nebula.js/stardust';// ...const el = useElement();el.innerHTML = 'Hello!';Gets the embed instance used.
Returns
- Required
The embed instance used.
properties
- context() functionRequired
Updates the current context of this embed instance. Use this when you want to change some part of the current context, like theme.
Parameters- ctx ContextRequired
The context to update.
ctx properties
-
constraints properties
- active boolean
Whether or not active constraints are on. Should block any active interaction by users, ie: scroll, click
- edit boolean
Whether or not edit actions are available. Should block any edit action.
- passive boolean
Whether or not passive constraints are on. Should block any passive interaction by users, ie: tooltips
- select boolean
Whether or not select constraints are on. Should block any selection action. Implied when active is true.
-
- dataViewType string
Type used for toggling to the data view (toggleDataView) This type need to be registered as well
- deviceType string
- disableCellPadding boolean
- interactions Interactions
interactions properties
- active boolean
Whether or not active interactions are on. Allows active interaction by users, ie: scroll, click
- edit boolean
Whether or not edit actions are on. Allows edit actions.
- passive boolean
Whether or not passive interactions are on. Allows passive interaction by users, ie: tooltips
- select boolean
Whether or not select interactions are on. Allows selection actions. Implied when active is false.
-
- boolean
- language string
-
navigation properties
- functionRequiredExperimentalAvailable since: 5.4.0
Return the current sheet id
Returns- string | falseRequired
The current sheet Id. false means there is no current sheet.
-
- functionRequiredExperimentalAvailable since: 5.4.0
Navigate to the supplied sheet and emit 'sheetChanged' event if the target sheet Id is valid. This allows a navigation object to synchronize its current sheet item with the active sheet.
Parameters- stringRequired
Id of the sheet to navigate to
-
-
- theme string
-
Returns- Promise < undefined >Required
-
- create() functionRequired
Creates a visualization model
Parameters- cfg CreateConfigRequired
The create configuration.
cfg properties
- type stringRequired
- fields Array< Field >
- properties qix.GenericObjectProperties
- version string
-
Returns- Promise < qix.GenericObject >Required
An engima model
-
- field() functionRequiredAvailable since: 1.1.0
Gets the listbox instance of the specified field
Parameters- fieldIdentifier string | LibraryField | QInfoRequired
Fieldname as a string, a Library dimension or an object id
Returns- Promise < FieldInstance >Required
-
- generateProperties() functionRequired
Generates properties for a visualization object
Parameters- cfg CreateConfigRequired
The create configuration.
Returns- Promise < object >Required
The objects properties
-
- getRegisteredTypes() functionRequired
Gets a list of registered visualization types and versions
Returns- Array< Object >Required
types
-
- render() functionRequired
Renders a visualization or sheet into an HTMLElement. Visualizations can either be existing objects or created on the fly. Support for sense sheets is experimental.
Parameters- cfg RenderConfigRequired
The render configuration.
cfg properties
- element HTMLElementRequired
Target html element to render in to
- extendProperties boolean
For creating objects: Whether to deeply extend properties or not. If false then subtrees will be overwritten.
- fields Array< Field >
For creating objects: Data fields to use
- id string
For existing objects: Engine identifier of object to render
- onError() function
Callback function called if an error occurs. Also called with AbortError when signal aborts.
Parameters- Required
properties
- originalError ErrorRequired
-
-
- onRender() function
Callback function called after rendering successfully
- options object
Options passed into the visualisation
- plugins Array< Plugin >
plugins passed into the visualisation
- properties qix.GenericObjectProperties
For creating objects: Explicit properties to set
- signal AbortSignal
Optional AbortSignal to cancel the render operation. When aborted, destroy() is called for cleanup before onError() is called with the AbortError.
- type string
For creating objects: Type of visualisation to render
- version string
For creating objects: Version of visualization to render
-
Returns-
A controller to the rendered visualization or sheet.
-
- selections() functionRequired
Gets the app selections of this instance.
Returns- Promise < AppSelections >Required
-
-
useEmbed
import { useEmbed } from '@nebula.js/stardust';
const embed = useEmbed();embed.render(...)Gets an event emitter instance for the visualization.
Returns
- Required
properties
- Emitter classRequired
-
useEmitter
// In a Nebula visualizationimport { useEmitter } from '@nebula.js/stardust';useEffect(()=> { // on some trigger emitter.emit("trigger", params)}, [...])
// In a mashupconst viz = await n.render({ element: el, id: 'abcdef'});viz.addListener("trigger", ()=> { // do something})useGlobal
import { useGlobal } from '@nebula.js/stardust';
// ...const g = useGlobal();useEffect(() => { g.engineVersion().then(version => { console.log(version); })}, []);This is an empty object by default, but enables you to provide a custom API of your visualization to make it possible to control after it has been rendered.
You can only use this hook once, calling it more than once is considered an error.
Parameters
- factory() functionRequiredReturns
- TRequired
-
- deps Array< any >
useImperativeHandle
import { useImperativeHandle } form '@nebula.js/stardust';// ...useImperativeHandle(() => ({ resetZoom() { setZoomed(false); }}));// when embedding the visualization, you can get a handle to this API// and use it to control the visualizationconst ctl = await embed(app).render({ element, type: 'my-chart',});ctl.getImperativeHandle().resetZoom();Gets the desired interaction states that should be applied when rendering the visualization.
The interactions are set on the embed configuration before the visualization is rendered and should be respected when implementing the visualization.
Returns
- Required
properties
- active boolean
Whether or not active interactions are on. Allows active interaction by users, ie: scroll, click
- edit boolean
Whether or not edit actions are on. Allows edit actions.
- passive boolean
Whether or not passive interactions are on. Allows passive interaction by users, ie: tooltips
- select boolean
Whether or not select interactions are on. Allows selection actions. Implied when active is false.
-
useInteractionState
// configure embed to disallow active interactions when renderingembed(app, { context: { interactions: { active: false, // do not allow interactions } }}).render({ element, id: 'sdfsdf' });import { useInteractionState } from '@nebula.js/stardust';// ...const interactions = useInteractionState();useEffect(() => { if (!interactions.active) { // do not add any event listener if active constraint is set return undefined; } const listener = () => {}; element.addEventListener('click', listener); return () => { element.removeEventListener('click', listener); };}, [interactions])Gets the desired keyboard settings and status to applied when rendering the visualization.
A visualization should in general only have tab stops if either keyboard.enabled is false or if active is true.
This means that either Nebula isn't configured to handle keyboard input or the chart is currently focused.
Enabling or disabling keyboardNavigation are set on the embed configuration and
should be respected by the visualization.
Returns
- Required
properties
- active booleanRequired
Set to true when the chart is activated, ie a user tabs to the chart and presses Enter or Space.
- enabled booleanRequired
Whether or not Nebula handles keyboard navigation or not.
- blur() function
Function used by the visualization to tell Nebula it wants to relinquish focus
Parameters- booleanRequired
-
- focus() function
Function used by the visualization to tell Nebula it wants to focus
- focusSelection() function
Function used by the visualization to tell Nebula that focus the selection toolbar
Parameters- booleanRequired
-
-
useKeyboard
// configure nebula to enable navigation between chartsembed(app, { context: { keyboardNavigation: true, // tell Nebula to handle navigation }}).render({ element, id: 'sdfsdf' });import { useKeyboard } from '@nebula.js/stardust';// ...const keyboard = useKeyboard();useEffect(() => { // Set a tab stop on our button if in focus or if Nebulas navigation is disabled button.setAttribute('tabIndex', keyboard.active || !keyboard.enabled ? 0 : -1); // If navigation is enabled and focus has shifted, lets focus the button keyboard.enabled && keyboard.active && button.focus();}, [keyboard])Gets the layout of the generic object associated with this visualization.
Returns
- qix.GenericObjectLayoutRequired
useLayout
import { useLayout } from '@nebula.js/stardust';// ...const layout = useLayout();console.log(layout);Creates a stateful value when a dependent changes.
Parameters
- factory() functionRequired
The factory function.
Returns- TRequired
-
- deps Array< any >Required
The dependencies.
Returns
- TRequired
The value returned from the factory function.
useMemo
import { useMemo } from '@nebula.js/stardust';// ...const v = useMemo(() => { return doSomeHeavyCalculation();}), []);Gets the generic object API of the generic object connected to this visualization.
Returns
- qix.GenericObject | undefinedRequired
useModel
import { useModel } from '@nebula.js/stardust';// ...const model = useModel();useEffect(() => { model.getInfo().then(info => { console.log(info); })}, []);Gets the navigation api to control sheet navigation. When useNavigation is used in Sense, it returns Sense.navigation.
Returns
- Required
navigation api.
properties
- functionRequiredExperimentalAvailable since: 5.4.0
Return the current sheet id
Returns- string | falseRequired
The current sheet Id. false means there is no current sheet.
-
- functionRequiredExperimentalAvailable since: 5.4.0
Navigate to the supplied sheet and emit 'sheetChanged' event if the target sheet Id is valid. This allows a navigation object to synchronize its current sheet item with the active sheet.
Parameters- stringRequired
Id of the sheet to navigate to
-
-
useNavigation
import { useNavigation } from "@nebula.js/stardust";// ...const navigation = useNavigation();const [activeSheetId, setActiveSheetId] = useState(navigation?.getCurrentSheetId() || "");Gets the options object provided when rendering the visualization.
This is an empty object by default but enables customization of the visualization through this object. Options are different from setting properties on the generic object in that options are only temporary settings applied to the visualization when rendered.
You have the responsibility to provide documentation of the options you support, if any.
Returns
- objectRequired
useOptions
// when embedding the visualization, anything can be set in optionsembed(app).render({ element, type: 'my-chart', options: { showNavigation: true, }});// it is up to you use and implement the provided optionsimport { useOptions } from '@nebula.js/stardust';import { useEffect } from '@nebula.js/stardust';// ...const options = useOptions();useEffect(() => { if (!options.showNavigation) { // hide navigation } else { // show navigation }}, [options.showNavigation]);Gets the array of plugins provided when rendering the visualization.
Returns
- Array< Plugin >Required
array of plugins.
usePlugins
// provide plugins that can be used when renderingembed(app).render({ element, type: 'my-chart', plugins: [plugin]});// It's up to the chart implementation to make use of plugins in any wayimport { usePlugins } from '@nebula.js/stardust';// ...const plugins = usePlugins();plugins.forEach((plugin) => { // Invoke plugin plugin.fn();});Runs a callback function when a dependent changes.
Useful for async operations that otherwise cause no side effects. Do not add for example listeners withing the callback as there is no teardown function.
Parameters
- factory() functionRequired
The factory function that calls the promise.
Returns- Promise < P >Required
-
- deps Array< any >
The dependencies.
Returns
- Array< P , Error >Required
The resolved value or rejected error
usePromise
import { usePromise } from '@nebula.js/stardust';import { useModel } from '@nebula.js/stardust';// ...const model = useModel();const [resolved, rejected] = usePromise(() => model.getLayout(), [model]);Gets the size of the HTMLElement the visualization is rendered into.
Returns
- Required
The size of the element.
properties
- height numberRequired
- left numberRequired
- top numberRequired
- width numberRequired
-
useRect
import { useRect } from '@nebula.js/stardust';// ...const rect = useRect();useEffect(() => { console.log('resize');}, [rect.width, rect.height])Creates a reference to a value not needed for rendering
While Nebula does not have a virtual DOM, it is still useful to have a reference to an object that is retained across renders and in it self does not trigger a render.
Parameters
- initialValue RRequired
The initial value.
Returns
- Required
An object with the current value
properties
- current RRequired
Current value
-
useRef
import { useRef } from '@nebula.js/stardust';// ...// initiate with simple valueconst timesRendered = useRef(0);
useEffect(() => { render(layout); // increments the render counter, a useState would trigger another render timesRendered.current += 1;},[layout]);Gets render state instance.
Used to update properties and get a new layout without triggering onInitialRender.
Returns
- Required
The render state.
properties
- pending anyRequired
- restore anyRequired
-
useRenderState
import { useRenderState } from '@nebula.js/stardust';
const renderState = useRenderState();useState(() => { if(needPropertiesUpdate(...)) { useRenderState.pending(); updateProperties(...); } else { useRenderState.restore(); ... }}, [...]);Gets the object selections.
Returns
- Required
The object selections.
properties
- addListener() functionRequired
Event listener function on instance
Parameters- eventType stringRequired
event type that function needs to listen
- callback() functionRequired
a callback function to run when event emits
-
- begin() functionRequiredParameters
- paths Array< string >Required
Returns- Promise < undefined >Required
-
- canCancel() functionRequiredReturns
- booleanRequired
-
- cancel() functionRequiredReturns
- Promise < undefined >Required
-
- canClear() functionRequiredReturns
- booleanRequired
-
- canConfirm() functionRequiredReturns
- booleanRequired
-
- clear() functionRequiredReturns
- Promise < undefined >Required
-
- confirm() functionRequiredReturns
- Promise < undefined >Required
-
- goModal() functionRequiredParameters
- paths Array< string >Required
Returns- Promise < undefined >Required
-
- isActive() functionRequiredReturns
- booleanRequired
-
- isModal() functionRequiredReturns
- booleanRequired
-
- noModal() functionRequiredParameters
- accept boolean
Returns- Promise < undefined >Required
-
- removeListener() functionRequired
Remove listener function on instance
Parameters- eventType stringRequired
event type that function needs to listen
- callback() functionRequired
a callback function to run when event emits
-
- select() functionRequiredParameters
- s objectRequired
s properties
- method stringRequired
- params Array< any >Required
-
Returns- Promise < boolean >Required
-
-
useSelections
import { useSelections } from '@nebula.js/stardust';import { useElement } from '@nebula.js/stardust';import { useEffect } from '@nebula.js/stardust';// ...const selections = useSelections();const element = useElement();useEffect(() => { const onClick = () => { selections.begin('/qHyperCubeDef'); }; element.addEventListener('click', onClick); return () => { element.removeEventListener('click', onClick); };}, []);Gets the layout of the generic object associated with this visualization.
Unlike the regular layout, a stale layout is not changed when a generic object enters
the modal state. This is mostly notable in that qSelectionInfo.qInSelections in the layout is
always false.
The returned value from useStaleLayout() and useLayout() are identical when the object
is not in a modal state.
Returns
- qix.GenericObjectLayoutRequired
useStaleLayout
import { useStaleLayout } from '@nebula.js/stardust';// ...const staleLayout = useStaleLayout();console.log(staleLayout);Creates a stateful value.
Parameters
- initialState S | functionRequired
The initial state.
Returns
- Array< S , SetStateFn >Required
The value and a function to update it.
useState
import { useState } from '@nebula.js/stardust';// ...// initiate with simple primitive valueconst [zoomed, setZoomed] = useState(false);
// updatesetZoomed(true);
// lazy initiationconst [value, setValue] = useState(() => heavy());Gets the theme.
Returns
- Required
The theme.
properties
- getColorPickerColor() functionRequired
Resolve a color object using the color picker palette from the provided JSON theme.
Parameters- c objectRequired
c properties
- color string
- index number
-
Returns- stringRequired
The resolved color.
-
- getContrastingColorTo() functionRequired
Get the best contrasting color against the specified
color. This is typically used to find a suitable text color for a label placed on an arbitrarily colored background.The returned colors are derived from the theme.
Parameters- color stringRequired
A color to measure the contrast against
Returns- stringRequired
- The color that has the best contrast against the specified
color.
- The color that has the best contrast against the specified
-
- getDataColorPalettes() functionRequiredReturns
- Array< DataPalette >Required
-
- getDataColorPickerPalettes() functionRequiredReturns
- Array< ColorPickerPalette >Required
-
- getDataColorScales() functionRequiredReturns
- Array< ScalePalette >Required
-
- getDataColorSpecials() functionRequiredReturns
- Required
properties
- nil stringRequired
- others stringRequired
- primary stringRequired
-
-
- getStyle() functionRequired
Get the value of a style attribute in the theme by searching in the theme's JSON structure. The search starts at the specified base path and continues upwards until the value is found. If possible it will get the attribute's value using the given path. When attributes separated by dots are provided, such as 'hover.color', they are required in the theme JSON file
Parameters- basePath stringRequired
Base path in the theme's JSON structure to start the search in (specified as a name path separated by dots).
- path stringRequired
Expected path for the attribute (specified as a name path separated by dots).
- attribute stringRequired
Name of the style attribute. (specified as a name attribute separated by dots).
Returns- string | undefinedRequired
The style value or undefined if not found
-
- name() functionRequired
Returns theme name
Returns- stringRequired
Current theme.
-
-
useTheme
import { useTheme } from '@nebula.js/stardust';
const theme = useTheme();console.log(theme.getContrastingColorTo('#ff0000'));Gets the translator.
Returns
- Required
The translator.
properties
- add() functionRequired
Registers a string in multiple locales
Parameters- item objectRequired
item properties
- id stringRequired
- locale objectRequired
-
-
- get() functionRequired
Translates a string for current locale.
Parameters- str stringRequired
ID of the registered string.
- args Array< string >
Values passed down for string interpolation.
Returns- stringRequired
The translated string.
-
- language() functionRequired
Returns current locale.
Parameters- lang string
language Locale to updated the currentLocale value
Returns- stringRequired
current locale.
-
-
useTranslator
import { useTranslator } from '@nebula.js/stardust';// ...const translator = useTranslator();console.log(translator.get('SomeString'));Properties
- action ARequired
- disabled boolean
- boolean
- icon object
icon properties
- viewBox string
- shapes Array< object >Required
-
Properties
- className 'njs-cell-action'Required
Properties
- className 'njs-action-toolbar-popover'Required
Mounts the app selection UI into the provided HTMLElement.
Parameters
- element HTMLElementRequired
mount
selections.mount(element);unmount
selections.unmount();Properties
- 'njs-cell-footer'Required
Properties
- className 'njs-cell-sub-title'Required
Properties
- className 'njs-cell-title'Required
Properties
- key stringRequired
The key of the component. Currently supporting components "theme" and "selections".
Component
const n = embed(app);const inst = await n.field('field_name');inst.mount(document.querySelector('.listbox'), { components: [{ key: 'theme', header: { fontColor: { color: '#f00' }, fontSize: 23, }, content: { fontSize: 16, useContrastColor: false, } },{ key: 'selections', colors: { selected: { color: '#0f0' }, alternative: { color: '#ededed' }, excluded: { color: '#ccc' }, selectedExcluded: { color: '#bbb' }, possible: { color: '#fefefe' }, possible: { color: '#fefefe' }, } }]});Properties
- anything object
- context Context
Settings for the rendering instance
context properties
-
constraints properties
- active boolean
Whether or not active constraints are on. Should block any active interaction by users, ie: scroll, click
- edit boolean
Whether or not edit actions are available. Should block any edit action.
- passive boolean
Whether or not passive constraints are on. Should block any passive interaction by users, ie: tooltips
- select boolean
Whether or not select constraints are on. Should block any selection action. Implied when active is true.
-
- dataViewType string
Type used for toggling to the data view (toggleDataView) This type need to be registered as well
- deviceType string
- disableCellPadding boolean
- interactions Interactions
interactions properties
- active boolean
Whether or not active interactions are on. Allows active interaction by users, ie: scroll, click
- edit boolean
Whether or not edit actions are on. Allows edit actions.
- passive boolean
Whether or not passive interactions are on. Allows passive interaction by users, ie: tooltips
- select boolean
Whether or not select interactions are on. Allows selection actions. Implied when active is false.
-
- boolean
- language string
-
navigation properties
- functionRequiredExperimentalAvailable since: 5.4.0
Return the current sheet id
Returns- string | falseRequired
The current sheet Id. false means there is no current sheet.
-
- functionRequiredExperimentalAvailable since: 5.4.0
Navigate to the supplied sheet and emit 'sheetChanged' event if the target sheet Id is valid. This allows a navigation object to synchronize its current sheet item with the active sheet.
Parameters- stringRequired
Id of the sheet to navigate to
-
-
- theme string
-
- hostConfig object
Qlik api compatible host config, see https://github.com/qlik-oss/qlik-api-ts/blob/main/docs/authentication.md#the-host-config
- load LoadFallback
Fallback load function for missing types
load properties
- LoadFallback() functionRequired
Fallback load function for missing types
Parameters- Required
properties
- LoadType interfaceRequiredParameters
- type objectRequired
type properties
- name stringRequired
- version stringRequired
-
Returns- Promise < Visualization >Required
-
-
Returns- Promise < Visualization >Required
-
-
- themes Array< ThemeInfo >
Themes to register
- types Array< TypeInfo >
Visualization types to register
Configuration
import { embed } from '@nebula.js/stardust'n = embed(app, { context: { keyboardNavigation: true, theme: 'purple', }, load: ({ name, version }) => { if (name === 'linechart') { return Promise.resolve(line); } }, types: [ { name: 'bar', load: () => Promise.resolve(bar), }, ], themes: [ { id: 'purple', load: () => Promise.resolve(purpleThemeJson), }, ],});Properties
- active boolean
Whether or not active constraints are on. Should block any active interaction by users, ie: scroll, click
- edit boolean
Whether or not edit actions are available. Should block any edit action.
- passive boolean
Whether or not passive constraints are on. Should block any passive interaction by users, ie: tooltips
- select boolean
Whether or not select constraints are on. Should block any selection action. Implied when active is true.
Properties
-
constraints properties
- active boolean
Whether or not active constraints are on. Should block any active interaction by users, ie: scroll, click
- edit boolean
Whether or not edit actions are available. Should block any edit action.
- passive boolean
Whether or not passive constraints are on. Should block any passive interaction by users, ie: tooltips
- select boolean
Whether or not select constraints are on. Should block any selection action. Implied when active is true.
-
- dataViewType string
Type used for toggling to the data view (toggleDataView) This type need to be registered as well
- deviceType string
- disableCellPadding boolean
- interactions Interactions
interactions properties
- active boolean
Whether or not active interactions are on. Allows active interaction by users, ie: scroll, click
- edit boolean
Whether or not edit actions are on. Allows edit actions.
- passive boolean
Whether or not passive interactions are on. Allows passive interaction by users, ie: tooltips
- select boolean
Whether or not select interactions are on. Allows selection actions. Implied when active is false.
-
- boolean
- language string
-
navigation properties
- functionRequiredExperimentalAvailable since: 5.4.0
Return the current sheet id
Returns- string | falseRequired
The current sheet Id. false means there is no current sheet.
-
- functionRequiredExperimentalAvailable since: 5.4.0
Navigate to the supplied sheet and emit 'sheetChanged' event if the target sheet Id is valid. This allows a navigation object to synchronize its current sheet item with the active sheet.
Parameters- stringRequired
Id of the sheet to navigate to
-
-
- theme string
Properties
- exportProperties exportPropertiesRequired
exportProperties properties
- exportProperties() functionRequiredAvailable since: 1.1.0
Exports properties for a chart with a hypercube.
Parameters- args objectRequired
args properties
- hypercubePath stringRequired
Reference to the qHyperCubeDef.
- propertyTree ObjectRequired
-
Returns- Required
properties
- data Array< ExportDataDef >
- properties object
-
-
-
- importProperties importPropertiesRequired
importProperties properties
- importProperties() functionRequiredAvailable since: 1.1.0
Imports properties for a chart with a hypercube.
Parameters- args objectRequired
args properties
- exportFormat ExportFormatRequired
The export object which is the output of exportProperties.
- hypercubePath stringRequired
Reference to the qHyperCubeDef.
- dataDefinition Object
Data definition of the target chart.
- defaultPropertyValues Object
Default values for a number of properties of the target chart.
- initialProperties Object
Initial properties of the target chart.
-
Returns- ObjectRequired
A properties tree
-
-
Rendering configuration for creating and rendering a new object
Properties
- type stringRequired
- fields Array< Field >
- properties qix.GenericObjectProperties
- version string
Properties
- path stringRequired
- dimensions FieldTarget
dimensions properties
- added fieldTargetAddedCallback
added properties
- fieldTargetAddedCallback() functionRequiredParameters
- field TRequired
- properties qix.GenericObjectPropertiesRequired
-
-
- max function | number
Number or function that returns the maximum number of fields
- min function | number
Number or function that returns the minimum number of fields
- removed fieldTargetRemovedCallback
removed properties
- fieldTargetRemovedCallback() functionRequiredParameters
- field TRequired
- properties qix.GenericObjectPropertiesRequired
- index numberRequired
-
-
-
- measures FieldTarget
Callback function that should return a function that in turns gets called before the hook runs again or when the component is destroyed. For example to remove any listeners added in the callback itself.
Returns
- void | functionRequired
Updates the current context of this embed instance. Use this when you want to change some part of the current context, like theme.
Parameters
- ctx ContextRequired
The context to update.
ctx properties
-
constraints properties
- active boolean
Whether or not active constraints are on. Should block any active interaction by users, ie: scroll, click
- edit boolean
Whether or not edit actions are available. Should block any edit action.
- passive boolean
Whether or not passive constraints are on. Should block any passive interaction by users, ie: tooltips
- select boolean
Whether or not select constraints are on. Should block any selection action. Implied when active is true.
-
- dataViewType string
Type used for toggling to the data view (toggleDataView) This type need to be registered as well
- deviceType string
- disableCellPadding boolean
- interactions Interactions
interactions properties
- active boolean
Whether or not active interactions are on. Allows active interaction by users, ie: scroll, click
- edit boolean
Whether or not edit actions are on. Allows edit actions.
- passive boolean
Whether or not passive interactions are on. Allows passive interaction by users, ie: tooltips
- select boolean
Whether or not select interactions are on. Allows selection actions. Implied when active is false.
-
- boolean
- language string
-
navigation properties
- functionRequiredExperimentalAvailable since: 5.4.0
Return the current sheet id
Returns- string | falseRequired
The current sheet Id. false means there is no current sheet.
-
- functionRequiredExperimentalAvailable since: 5.4.0
Navigate to the supplied sheet and emit 'sheetChanged' event if the target sheet Id is valid. This allows a navigation object to synchronize its current sheet item with the active sheet.
Parameters- stringRequired
Id of the sheet to navigate to
-
-
- theme string
-
Returns
- Promise < undefined >Required
context
// change themen.context({ theme: 'dark'});// change interactionsn.context({ interactions: { select: false } });Creates a visualization model
Parameters
- cfg CreateConfigRequired
The create configuration.
cfg properties
- type stringRequired
- fields Array< Field >
- properties qix.GenericObjectProperties
- version string
-
Returns
- Promise < qix.GenericObject >Required
An engima model
create
// create a barchart in the app and return the modelconst model = await n.create({ type: 'barchart', fields: ['Product', { qLibraryId: 'u378hn', type: 'measure' }], properties: { showTitle: true } });Gets the listbox instance of the specified field
Parameters
- fieldIdentifier string | LibraryField | QInfoRequired
Fieldname as a string, a Library dimension or an object id
Returns
- Promise < FieldInstance >Required
field
const fieldInstance = await n.field("MyField");fieldInstance.mount(element, { title: "Hello Field"});Generates properties for a visualization object
Parameters
- cfg CreateConfigRequired
The create configuration.
cfg properties
- type stringRequired
- fields Array< Field >
- properties qix.GenericObjectProperties
- version string
-
Returns
- Promise < object >Required
The objects properties
generateProperties
// generate properties for a barchartconst properties = await n.generateProperties({ type: 'barchart', fields: ['Product', { qLibraryId: 'u378hn', type: 'measure' }], properties: { showTitle: true } },);Gets a list of registered visualization types and versions
Returns
- Array< Object >Required
types
getRegisteredTypes
const types = n.getRegisteredTypes();// Contains//[// {// name: "barchart"// versions:[undefined, "1.2.0"]// }//]Renders a visualization or sheet into an HTMLElement. Visualizations can either be existing objects or created on the fly. Support for sense sheets is experimental.
Parameters
- cfg RenderConfigRequired
The render configuration.
cfg properties
- element HTMLElementRequired
Target html element to render in to
- extendProperties boolean
For creating objects: Whether to deeply extend properties or not. If false then subtrees will be overwritten.
- fields Array< Field >
For creating objects: Data fields to use
- id string
For existing objects: Engine identifier of object to render
- onError() function
Callback function called if an error occurs. Also called with AbortError when signal aborts.
Parameters- Required
properties
- originalError ErrorRequired
-
-
- onRender() function
Callback function called after rendering successfully
- options object
Options passed into the visualisation
- plugins Array< Plugin >
plugins passed into the visualisation
- properties qix.GenericObjectProperties
For creating objects: Explicit properties to set
- signal AbortSignal
Optional AbortSignal to cancel the render operation. When aborted, destroy() is called for cleanup before onError() is called with the AbortError.
- type string
For creating objects: Type of visualisation to render
- version string
For creating objects: Version of visualization to render
-
render
// render from existing objectn.render({ element: el, id: 'abcdef'});// render on the flyn.render({ element: el, type: 'barchart', fields: ['Product', { qLibraryId: 'u378hn', type: 'measure' }]});// with AbortSignalconst controller = new AbortController();n.render({ element: el, type: 'barchart', fields: ['Product', '=Sum(Sales)'], signal: controller.signal});// Later: cancel the rendercontroller.abort();Gets the app selections of this instance.
Returns
- Promise < AppSelections >Required
selections
const selections = await n.selections();selections.mount(element);The emitter instance. Implements https://nodejs.org/api/events.html#class-eventemitter.
Options for Enigma Mocker
Properties
- delay numberRequired
Simulate delay (in ms) for calls in enigma-mocker.
- appMethods object
Object with methods to add to the mocked app.
Properties
- dimensions Array< qix.NxDimension >Required
- excludedDimensions Array< qix.NxDimension >Required
- excludedMeasures Array< qix.NxMeasure >Required
- interColumnSortOrder Array< number >Required
- measures Array< qix.NxMeasure >Required
Used for exporting and importing properties between backend models. An object that exports to ExportFormat should put dimensions and measures inside one data group. If an object has two hypercubes, each of the cubes should export dimensions and measures in two separate data groups. An object that imports from this structure is responsible for putting the existing properties where they should be in the new model.
Properties
- data Array< ExportDataDef >
- properties object
Exports properties for a chart with a hypercube.
Parameters
- args objectRequired
args properties
- hypercubePath stringRequired
Reference to the qHyperCubeDef.
- propertyTree ObjectRequired
-
Returns
- Required
properties
- data Array< ExportDataDef >
- properties object
-
Field string | qix.NxDimension | qix.NxMeasure | LibraryField
Mounts the field as a listbox into the provided HTMLElement.
Parameters
- element HTMLElementRequired
- options object
Settings for the embedded listbox
options properties
- checkboxes boolean
Show values as checkboxes instead of as fields (not applicable for existing objects)
- components Array< Component >
Override individual components' styling, otherwise set by the theme or the default style.
- dense boolean
Reduces padding and text size (not applicable for existing objects)
- direction Direction
Direction setting ltr|rtl.
direction properties
- Direction 'ltr' | 'rtl'Required
-
- frequencyMode FrequencyMode
Show frequency none|value|percent|relative
frequencyMode properties
- FrequencyMode 'none' | 'value' | 'percent' | 'relative'Required
-
- histogram boolean
Show histogram bar (not applicable for existing objects)
- listLayout ListLayout
Layout direction vertical|horizontal (not applicable for existing objects)
listLayout properties
- ListLayout 'vertical' | 'horizontal'Required
-
- properties object
Properties object to extend default properties with
- search SearchMode
Show the search bar permanently, using the toggle button or when in selection: false|true|toggle
search properties
- SearchMode boolean | 'toggle'Required
-
- showLock boolean
Show the button for toggling locked state.
- stateName string
Sets the state to make selections in (not applicable for existing objects)
- title string
Custom title, defaults to fieldname (not applicable for existing objects)
- toolbar boolean
Show the toolbar
- toolbarMode ToolbarMode
Toolbar placement mode: attach, detach, or auto.
toolbarMode properties
- ToolbarMode 'attach' | 'detach' | 'auto'Required
-
-
Returns
- Promise < void >Required
A promise that resolves when the data is fetched.
mount
fieldInstance.mount(element);Event listener function on instance
Parameters
- eventType FieldEventTypesRequired
event type that function needs to listen
eventType properties
- FieldEventTypes 'selectionActivated' | 'selectionDeactivated'Required
-
- callback() functionRequired
a callback function to run when event emits
on
const handleSomeEvent () => {...};fieldInstance.on('someEvent', handleSomeEvent);...fieldInstance.removeListener('someEvent', handleSomeEvent);Remove listener on instance
Parameters
- eventType FieldEventTypesRequired
event type
eventType properties
- FieldEventTypes 'selectionActivated' | 'selectionDeactivated'Required
-
- callback() functionRequired
handler
unmount
listbox.unmount();Properties
- added fieldTargetAddedCallback
added properties
- fieldTargetAddedCallback() functionRequiredParameters
- field TRequired
- properties qix.GenericObjectPropertiesRequired
-
-
- max function | number
Number or function that returns the maximum number of fields
- min function | number
Number or function that returns the minimum number of fields
- removed fieldTargetRemovedCallback
removed properties
- fieldTargetRemovedCallback() functionRequiredParameters
- field TRequired
- properties qix.GenericObjectPropertiesRequired
- index numberRequired
-
-
Parameters
- field TRequired
- properties qix.GenericObjectPropertiesRequired
Parameters
- field TRequired
- properties qix.GenericObjectPropertiesRequired
- index numberRequired
Checks whether the specified flag is enabled.
Parameters
- flag stringRequired
The value flag to check.
Returns
- booleanRequired
True if the specified flag is enabled, false otherwise.
Properties
- anything objectRequired
- deviceType stringRequired
- flags FlagsRequired
flags properties
- isEnabled() functionRequired
Checks whether the specified flag is enabled.
Parameters- flag stringRequired
The value flag to check.
Returns- booleanRequired
True if the specified flag is enabled, false otherwise.
-
-
- hostConfig objectRequired
- theme ThemeRequired
theme properties
- getColorPickerColor() functionRequired
Resolve a color object using the color picker palette from the provided JSON theme.
Parameters- c objectRequired
c properties
- color string
- index number
-
Returns- stringRequired
The resolved color.
-
- getContrastingColorTo() functionRequired
Get the best contrasting color against the specified
color. This is typically used to find a suitable text color for a label placed on an arbitrarily colored background.The returned colors are derived from the theme.
Parameters- color stringRequired
A color to measure the contrast against
Returns- stringRequired
- The color that has the best contrast against the specified
color.
- The color that has the best contrast against the specified
-
- getDataColorPalettes() functionRequiredReturns
- Array< DataPalette >Required
-
- getDataColorPickerPalettes() functionRequiredReturns
- Array< ColorPickerPalette >Required
-
- getDataColorScales() functionRequiredReturns
- Array< ScalePalette >Required
-
- getDataColorSpecials() functionRequiredReturns
- Required
properties
- nil stringRequired
- others stringRequired
- primary stringRequired
-
-
- getStyle() functionRequired
Get the value of a style attribute in the theme by searching in the theme's JSON structure. The search starts at the specified base path and continues upwards until the value is found. If possible it will get the attribute's value using the given path. When attributes separated by dots are provided, such as 'hover.color', they are required in the theme JSON file
Parameters- basePath stringRequired
Base path in the theme's JSON structure to start the search in (specified as a name path separated by dots).
- path stringRequired
Expected path for the attribute (specified as a name path separated by dots).
- attribute stringRequired
Name of the style attribute. (specified as a name attribute separated by dots).
Returns- string | undefinedRequired
The style value or undefined if not found
-
- name() functionRequired
Returns theme name
Returns- stringRequired
Current theme.
-
-
- translator TranslatorRequired
translator properties
- add() functionRequired
Registers a string in multiple locales
Parameters- item objectRequired
item properties
- id stringRequired
- locale objectRequired
-
-
- get() functionRequired
Translates a string for current locale.
Parameters- str stringRequired
ID of the registered string.
- args Array< string >
Values passed down for string interpolation.
Returns- stringRequired
The translated string.
-
- language() functionRequired
Returns current locale.
Parameters- lang string
language Locale to updated the currentLocale value
Returns- stringRequired
current locale.
-
-
Imports properties for a chart with a hypercube.
Parameters
- args objectRequired
args properties
- exportFormat ExportFormatRequired
The export object which is the output of exportProperties.
exportFormat properties
- data Array< ExportDataDef >
- properties object
-
- hypercubePath stringRequired
Reference to the qHyperCubeDef.
- dataDefinition Object
Data definition of the target chart.
- defaultPropertyValues Object
Default values for a number of properties of the target chart.
- initialProperties Object
Initial properties of the target chart.
-
Returns
- ObjectRequired
A properties tree
Properties
- active boolean
Whether or not active interactions are on. Allows active interaction by users, ie: scroll, click
- edit boolean
Whether or not edit actions are on. Allows edit actions.
- passive boolean
Whether or not passive interactions are on. Allows passive interaction by users, ie: tooltips
- select boolean
Whether or not select interactions are on. Allows selection actions. Implied when active is false.
Properties
- active booleanRequired
Set to true when the chart is activated, ie a user tabs to the chart and presses Enter or Space.
- enabled booleanRequired
Whether or not Nebula handles keyboard navigation or not.
Function used by the visualization to tell Nebula it wants to relinquish focus
Parameters
- booleanRequired
Function used by the visualization to tell Nebula that focus the selection toolbar
Parameters
- booleanRequired
Fallback load function for missing types
Parameters
- Required
properties
- LoadType interfaceRequiredParameters
- type objectRequired
type properties
- name stringRequired
- version stringRequired
-
Returns- Promise < Visualization >Required
-
-
Returns
- Promise < Visualization >Required
Parameters
- type objectRequired
type properties
- name stringRequired
- version stringRequired
-
Returns
- Promise < Visualization >Required
Move an element from position old_index to position new_index in the array.
Parameters
- array anyRequired
- oldIndex anyRequired
- newIndex anyRequired
Navigation
const navigation = useNavigation();//...useEffect(() => { const onSheetChanged = () => { // do something }; if (navigation?.addListener) { navigation.addListener("sheetChanged", onSheetChanged); } return () => { if (navigation?.removeListener) { navigation.removeListener("sheetChanged", onSheetChanged); } };}, [navigation]);
const onSheetClick = (sheetId: string) => { navigation?.goToSheet(sheetId);};Return the current sheet id
Returns
- string | falseRequired
The current sheet Id. false means there is no current sheet.
Navigate to the supplied sheet and emit 'sheetChanged' event if the target sheet Id is valid. This allows a navigation object to synchronize its current sheet item with the active sheet.
Parameters
- stringRequired
Id of the sheet to navigate to
Event listener function on instance
Parameters
- eventType stringRequired
event type that function needs to listen
- callback() functionRequired
a callback function to run when event emits
addListener
api.addListener('someEvent', () => {...});Parameters
- paths Array< string >Required
Returns
- Promise < undefined >Required
Parameters
- paths Array< string >Required
Returns
- Promise < undefined >Required
Parameters
- accept boolean
Returns
- Promise < undefined >Required
Remove listener function on instance
Parameters
- eventType stringRequired
event type that function needs to listen
- callback() functionRequired
a callback function to run when event emits
removeListener
api.removeListener('someEvent', () => {...});Parameters
- s objectRequired
s properties
- method stringRequired
- params Array< any >Required
-
Returns
- Promise < boolean >Required
An object literal containing meta information about the plugin and a function containing the plugin implementation.
Properties
- fn functionRequired
The implementation of the plugin. Input and return value is up to the plugin implementation to decide based on its purpose.
- info objectRequired
Object that can hold various meta info about the plugin
info properties
- name stringRequired
The name of the plugin
-
Plugin
const plugin = { info: { name: "example-plugin", type: "meta-type", }, fn: () => { // Plugin implementation goes here }};Properties
- data object
data properties
- targets Array< DataTarget >Required
-
- exportProperties exportProperties
exportProperties properties
- exportProperties() functionRequiredAvailable since: 1.1.0
Exports properties for a chart with a hypercube.
Parameters- args objectRequired
args properties
- hypercubePath stringRequired
Reference to the qHyperCubeDef.
- propertyTree ObjectRequired
-
Returns- Required
properties
- data Array< ExportDataDef >
- properties object
-
-
-
- importProperties importProperties
importProperties properties
- importProperties() functionRequiredAvailable since: 1.1.0
Imports properties for a chart with a hypercube.
Parameters- args objectRequired
args properties
- exportFormat ExportFormatRequired
The export object which is the output of exportProperties.
- hypercubePath stringRequired
Reference to the qHyperCubeDef.
- dataDefinition Object
Data definition of the target chart.
- defaultPropertyValues Object
Default values for a number of properties of the target chart.
- initialProperties Object
Initial properties of the target chart.
-
Returns- ObjectRequired
A properties tree
-
-
- properties QAEProperties | qix.GenericObjectProperties
Properties
- initial qix.GenericObjectProperties
- onChange onPropertyChange
onChange properties
- onPropertyChange() functionRequiredParameters
- properties qix.GenericObjectPropertiesRequired
-
-
Properties
- height numberRequired
- left numberRequired
- top numberRequired
- width numberRequired
Configuration for rendering a visualisation, either creating or fetching an existing object.
Properties
- element HTMLElementRequired
Target html element to render in to
- extendProperties boolean
For creating objects: Whether to deeply extend properties or not. If false then subtrees will be overwritten.
- fields Array< Field >
For creating objects: Data fields to use
- id string
For existing objects: Engine identifier of object to render
- options object
Options passed into the visualisation
- plugins Array< Plugin >
plugins passed into the visualisation
- properties qix.GenericObjectProperties
For creating objects: Explicit properties to set
- signal AbortSignal
Optional AbortSignal to cancel the render operation. When aborted, destroy() is called for cleanup before onError() is called with the AbortError.
- type string
For creating objects: Type of visualisation to render
- version string
For creating objects: Version of visualization to render
RenderConfig
// A config for Creating objects:const createConfig = { type: 'bar', element: document.querySelector('.bar'), extendProperties: true, fields: ['[Country names]', '=Sum(Sales)'], properties: { legend: { show: false, }, }};nebbie.render(createConfig);// A config for rendering an existing object:const renderConfig = { id: 'jG5LP', element: document.querySelector('.line'),};nebbie.render(renderConfig);// Using AbortSignal to cancel rendering:const controller = new AbortController();const abortConfig = { type: 'bar', element: document.querySelector('.bar'), fields: ['Country', '=Sum(Sales)'], signal: controller.signal, onError: (err) => { if (err.name === 'AbortError') { console.log('Render was cancelled'); } else { console.error('Render failed:', err); } }};const vizPromise = nebbie.render(abortConfig);// Cancel the render operationcontroller.abort();Callback function called if an error occurs. Also called with AbortError when signal aborts.
Parameters
- Required
properties
- originalError ErrorRequired
-
A controller to further modify a visualization after it has been rendered.
Properties
- id stringRequired
The id of this sheets's generic object.
- model stringRequired
This sheets Enigma model, a representation of the generic object.
- RequiredExperimentalAvailable since: 5.4.0
The navigation api to control sheet navigation.
navigation properties
- functionRequiredExperimentalAvailable since: 5.4.0
Return the current sheet id
Returns- string | falseRequired
The current sheet Id. false means there is no current sheet.
-
- functionRequiredExperimentalAvailable since: 5.4.0
Navigate to the supplied sheet and emit 'sheetChanged' event if the target sheet Id is valid. This allows a navigation object to synchronize its current sheet item with the active sheet.
Parameters- stringRequired
Id of the sheet to navigate to
-
-
Sheet
const sheet = await embed(app).render({ element, id: "jD5Gd"});sheet.destroy();destroy
const sheet = await embed(app).render({ element, id: "jD5Gd"});sheet.destroy();Properties
- className 'njs-sheet'Required
Resolve a color object using the color picker palette from the provided JSON theme.
Parameters
- c objectRequired
c properties
- color string
- index number
-
Returns
- stringRequired
The resolved color.
getColorPickerColor
theme.getColorPickerColor({ index: 1 });theme.getColorPickerColor({ color: 'red' });Get the best contrasting color against the specified color.
This is typically used to find a suitable text color for a label placed on an arbitrarily colored background.
The returned colors are derived from the theme.
Parameters
- color stringRequired
A color to measure the contrast against
Returns
- stringRequired
- The color that has the best contrast against the specified
color.
- The color that has the best contrast against the specified
getContrastingColorTo
theme.getContrastingColorTo('#400');Returns
- Array< DataPalette >Required
Returns
- Array< ColorPickerPalette >Required
Returns
- Array< ScalePalette >Required
Returns
- Required
properties
- nil stringRequired
- others stringRequired
- primary stringRequired
-
Get the value of a style attribute in the theme by searching in the theme's JSON structure. The search starts at the specified base path and continues upwards until the value is found. If possible it will get the attribute's value using the given path. When attributes separated by dots are provided, such as 'hover.color', they are required in the theme JSON file
Parameters
- basePath stringRequired
Base path in the theme's JSON structure to start the search in (specified as a name path separated by dots).
- path stringRequired
Expected path for the attribute (specified as a name path separated by dots).
- attribute stringRequired
Name of the style attribute. (specified as a name attribute separated by dots).
Returns
- string | undefinedRequired
The style value or undefined if not found
getStyle
theme.getStyle('object', 'title.main', 'fontSize');theme.getStyle('object', 'title', 'main.fontSize');theme.getStyle('object', '', 'title.main.fontSize');theme.getStyle('', '', 'fontSize');name
theme.name();A function that should return a Promise that resolves to a raw JSON theme.
Returns
- Promise < ThemeJSON >Required
Registers a string in multiple locales
Parameters
- item objectRequired
item properties
- id stringRequired
- locale objectRequired
-
add
translator.add({ id: 'company.hello_user', locale: { 'en-US': 'Hello {0}', 'sv-SE': 'Hej {0}' }});translator.get('company.hello_user', ['John']); // Hello JohnTranslates a string for current locale.
Parameters
- str stringRequired
ID of the registered string.
- args Array< string >
Values passed down for string interpolation.
Returns
- stringRequired
The translated string.
Returns current locale.
Parameters
- lang string
language Locale to updated the currentLocale value
Returns
- stringRequired
current locale.
Properties
- load LoadTypeRequired
load properties
- LoadType interfaceRequiredParameters
- type objectRequired
type properties
- name stringRequired
- version stringRequired
-
Returns- Promise < Visualization >Required
-
-
- name stringRequired
- meta object
- version string
The entry point for defining a visualization.
Parameters
- galaxy GalaxyRequired
galaxy properties
- anything objectRequired
- deviceType stringRequired
- flags FlagsRequired
flags properties
- isEnabled() functionRequired
Checks whether the specified flag is enabled.
Parameters- flag stringRequired
The value flag to check.
Returns- booleanRequired
True if the specified flag is enabled, false otherwise.
-
-
- hostConfig objectRequired
- theme ThemeRequired
theme properties
- getColorPickerColor() functionRequired
Resolve a color object using the color picker palette from the provided JSON theme.
Parameters- c objectRequired
c properties
- color string
- index number
-
Returns- stringRequired
The resolved color.
-
- getContrastingColorTo() functionRequired
Get the best contrasting color against the specified
color. This is typically used to find a suitable text color for a label placed on an arbitrarily colored background.The returned colors are derived from the theme.
Parameters- color stringRequired
A color to measure the contrast against
Returns- stringRequired
- The color that has the best contrast against the specified
color.
- The color that has the best contrast against the specified
-
- getDataColorPalettes() functionRequiredReturns
- Array< DataPalette >Required
-
- getDataColorPickerPalettes() functionRequiredReturns
- Array< ColorPickerPalette >Required
-
- getDataColorScales() functionRequiredReturns
- Array< ScalePalette >Required
-
- getDataColorSpecials() functionRequiredReturns
- Required
properties
- nil stringRequired
- others stringRequired
- primary stringRequired
-
-
- getStyle() functionRequired
Get the value of a style attribute in the theme by searching in the theme's JSON structure. The search starts at the specified base path and continues upwards until the value is found. If possible it will get the attribute's value using the given path. When attributes separated by dots are provided, such as 'hover.color', they are required in the theme JSON file
Parameters- basePath stringRequired
Base path in the theme's JSON structure to start the search in (specified as a name path separated by dots).
- path stringRequired
Expected path for the attribute (specified as a name path separated by dots).
- attribute stringRequired
Name of the style attribute. (specified as a name attribute separated by dots).
Returns- string | undefinedRequired
The style value or undefined if not found
-
- name() functionRequired
Returns theme name
Returns- stringRequired
Current theme.
-
-
- translator TranslatorRequired
translator properties
- add() functionRequired
Registers a string in multiple locales
Parameters- item objectRequired
item properties
- id stringRequired
- locale objectRequired
-
-
- get() functionRequired
Translates a string for current locale.
Parameters- str stringRequired
ID of the registered string.
- args Array< string >
Values passed down for string interpolation.
Returns- stringRequired
The translated string.
-
- language() functionRequired
Returns current locale.
Parameters- lang string
language Locale to updated the currentLocale value
Returns- stringRequired
current locale.
-
-
-
Returns
- Required
properties
- component() functionRequiredReturns
- voidRequired
-
- qae QAEDefinitionRequired
qae properties
- data object
data properties
- targets Array< DataTarget >Required
-
- exportProperties exportProperties
exportProperties properties
- exportProperties() functionRequiredAvailable since: 1.1.0
Exports properties for a chart with a hypercube.
Parameters- args objectRequired
args properties
- hypercubePath stringRequired
Reference to the qHyperCubeDef.
- propertyTree ObjectRequired
-
Returns- Required
properties
- data Array< ExportDataDef >
- properties object
-
-
-
- importProperties importProperties
importProperties properties
- importProperties() functionRequiredAvailable since: 1.1.0
Imports properties for a chart with a hypercube.
Parameters- args objectRequired
args properties
- exportFormat ExportFormatRequired
The export object which is the output of exportProperties.
- hypercubePath stringRequired
Reference to the qHyperCubeDef.
- dataDefinition Object
Data definition of the target chart.
- defaultPropertyValues Object
Default values for a number of properties of the target chart.
- initialProperties Object
Initial properties of the target chart.
-
Returns- ObjectRequired
A properties tree
-
-
- properties QAEProperties | qix.GenericObjectProperties
-
-
Visualization
import { useElement, useLayout } from '@nebula.js/stardust';
export default function() { return { qae: { properties: { dude: 'Heisenberg', } }, component() { const el = useElement(); const layout = useLayout(); el.innerHTML = `What's my name? ${layout.dude}!!!`; } };}Properties
- qae QAEDefinitionRequired
qae properties
- data object
data properties
- targets Array< DataTarget >Required
-
- exportProperties exportProperties
exportProperties properties
- exportProperties() functionRequiredAvailable since: 1.1.0
Exports properties for a chart with a hypercube.
Parameters- args objectRequired
args properties
- hypercubePath stringRequired
Reference to the qHyperCubeDef.
- propertyTree ObjectRequired
-
Returns- Required
properties
- data Array< ExportDataDef >
- properties object
-
-
-
- importProperties importProperties
importProperties properties
- importProperties() functionRequiredAvailable since: 1.1.0
Imports properties for a chart with a hypercube.
Parameters- args objectRequired
args properties
- exportFormat ExportFormatRequired
The export object which is the output of exportProperties.
- hypercubePath stringRequired
Reference to the qHyperCubeDef.
- dataDefinition Object
Data definition of the target chart.
- defaultPropertyValues Object
Default values for a number of properties of the target chart.
- initialProperties Object
Initial properties of the target chart.
-
Returns- ObjectRequired
A properties tree
-
-
- properties QAEProperties | qix.GenericObjectProperties
-
A controller to further modify a visualization after it has been rendered.
Properties
- id stringRequired
The id of this visualization's generic object.
- model qix.GenericObjectRequired
This visualizations Enigma model, a representation of the generic object.
- viewDataToggled booleanRequired
Whether or not the chart has the data view toggled on.
Viz
const viz = await embed(app).render({ element, type: 'barchart'});viz.destroy();Listens to custom events from inside the visualization. See useEmitter
Parameters
- eventName stringRequired
Event name to listen to
- listener() functionRequired
Callback function to invoke
Converts the visualization to a different registered type.
Will update properties if permissions allow, else will patch (can be forced with forcePatch parameter)
Not all chart types are compatible, similar structures are required.
Parameters
- newType stringRequired
Which registered type to convert to.
- forceUpdate boolean
Whether to apply the change or not, else simply returns the resulting properties, defaults to true.
- forcePatch boolean
Whether to always patch the change instead of making a permanent change
Returns
- Promise < object >Required
Promise object that resolves to the full property tree of the converted visualization.
convertTo
const viz = await embed(app).render({ element, id: 'abc'});await viz.convertTo('barChart');// Change the barchart to a linechart, only in the current sessionconst newProperties = await viz.convertTo('lineChart', false, true);// Remove the conversion by clearing the patchesawait viz.model.clearSoftPatches();Destroys the visualization and removes it from the the DOM.
Returns
- Promise < void >Required
destroy
const viz = await embed(app).render({ element, id: 'abc'});viz.destroy();Gets the specific api that a Viz exposes.
Returns
- Promise < object >Required
object that contains the internal Viz api.
Removes a listener
Parameters
- eventName stringRequired
Event name to remove from
- listener() functionRequired
Callback function to remove
Toggles the chart to a data view of the chart.
The chart will be toggled to the type defined in the nebula context (dataViewType).
The default dataViewType for nebula is sn-table. The specified chart type needs to be registered as well, in order to make it possible to render the data view.
Parameters
- showDataView boolean
If included, forces the chart into a specific state. True will show data view, and false will show the original chart. If not included it will always toggle between the two views.
Properties
- attributes VizElementAttributesRequired
attributes properties
- data-render-count stringRequired
-
- className 'njs-viz'Required
Properties
- nil stringRequired
- others stringRequired
- primary stringRequired
Properties
- colors Array< string > | Array< Array< string > >Required
- key stringRequired
- type 'pyramid' | 'row'Required
Properties
- colors Array< string > | Array< Array< string > >Required
- key stringRequired
- type 'gradient' | 'class-pyramid'Required