@luzmo/dashboard-contents-types v1.0.3
Types and JSON schemas for Luzmo dashboard contents
This packages contains different dashboard contents' types and JSON schemas for Luzmo dashboard contents.
Content Item Types
Here is the list of some types for content items. There are more types available in the package.
Type | Description |
---|---|
AreaChart | An Area Chart type. |
AreaChartViewOptions | An Area Chart options type. |
AreaChartSlots | An Area Chart slots type. |
BarChart | A Bar Chart type. |
BarChartViewOptions | A Bar Chart options type. |
BarChartSlots | A Bar Chart slots type. |
BoxPlot | A Box Plot type. |
BoxPlotViewOptions | A Box Plot options type. |
BoxPlotSlots | A Box Plot slots type. |
BubbleChart | A Bubble Chart type. |
BubbleChartViewOptions | A Bubble Chart options type. |
BubbleChartSlots | A Bubble Chart slots type. |
BulletChart | A Bullet Chart type. |
BulletChartViewOptions | A Bullet Chart options type. |
BulletChartSlots | A Bullet Chart slots type. |
ChoroplethMap | A Choropleth Map type. |
ChoroplethMapViewOptions | A Choropleth Map options type. |
ChoroplethMapSlots | A Choropleth Map slots type. |
CircularGauge | A Circular Gauge type. |
CircularGaugeViewOptions | A Circular Gauge options type. |
CircularGaugeSlots | A Circular Gauge slots type. |
ColumnChart | A Column Chart type. |
ColumnChartViewOptions | A Column Chart options type. |
ColumnChartSlots | A Column Chart slots type. |
CombinationChart | A Combination Chart type. |
CombinationChartViewOptions | A Combination Chart options type. |
CombinationChartSlots | A Combination Chart slots type. |
ConditionalNumber | A Conditional Number type. |
ConditionalNumberViewOptions | A Conditional Number options type. |
ConditionalNumberSlots | A Conditional Number slots type. |
DateFilter | A Date Filter type. |
DateFilterViewOptions | A Date Filter options type. |
DateFilterSlots | A Date Filter slots type. |
DonutChart | A Donut Chart type. |
DonutChartViewOptions | A Donut Chart options type. |
DonutChartSlots | A Donut Chart slots type. |
DropdownFilter | A Dropdown Filter type. |
DropdownFilterViewOptions | A Dropdown Filter options type. |
DropdownFilterSlots | A Dropdown Filter slots type. |
EvolutionNumber | An Evolution Number type. |
EvolutionNumberViewOptions | An Evolution Number options type. |
EvolutionNumberSlots | An Evolution Number slots type. |
FunnelChart | A Funnel Chart type. |
FunnelChartViewOptions | A Funnel Chart options type. |
FunnelChartSlots | A Funnel Chart slots type. |
Image | An Image type. |
ImageViewOptions | An Image options type. |
LineChart | A Line Chart type. |
LineChartViewOptions | A Line Chart options type. |
LineChartSlots | A Line Chart slots type. |
PivotTable | A Pivot Table type. |
PivotTableViewOptions | A Pivot Table options type. |
PivotTableSlots | A Pivot Table slots type. |
RegularTable | A Regular Table type. |
RegularTableViewOptions | A Regular Table options type. |
RegularTableSlots | A Regular Table slots type. |
SankeyDiagram | A ScatterPlot type. |
SankeyDiagramViewOptions | A Sankey Diagram options type. |
SankeyDiagramSlots | A Sankey Diagram slots type. |
ScatterPlot | A Scatter Plot type. |
ScatterPlotViewOptions | A Scatter Plot options type. |
ScatterPlotSlots | A Scatter Plot slots type. |
SlicerFilter | A Slicer Filter type. |
SlicerFilterViewOptions | A Slicer Filter options type. |
SlicerFilterSlots | A Slicer Filter slots type. |
SliderFilter | A Slider Filter type. |
SliderFilterViewOptions | A Slider Filter options type. |
SliderFilterSlots | A Slider Filter slots type. |
Text | A Text type. |
TextViewOptions | A Text options type. |
VizItemType | A union type for content item types. |
Options | A union type for all the options from all the charts. |
Slots | A union type for all the slots from all the charts. |
JSON Schemas
The library also provides JSON schemas for the content items. The schemas are provided as an object with the schema name as the key and the schema as the value.
import { JSON_SCHEMAS } from '@luzmo/dashboard-contents-types';
console.log(JSON_SCHEMAS);
console.log(JSON_SCHEMAS['text-options.schema.json']);
The JSON schemas are not dereferenced. You can use a library like json-schema-ref-parser to dereference the schemas. json-schema-ref-parser
is a Node library so to use it in a browser environment you should add a configuration for that.
import * as refParser from '@apidevtools/json-schema-ref-parser';
import { JSON_SCHEMAS } from '@luzmo/dashboard-contents-types';
const refParserResolver = {
order: 101,
canRead: /^https:\/\/developer\.luzmo\.com/,
read: (file, callback) => {
const name = file.url.split('/').pop();
const schema = JSON_SCHEMAS[name];
if (schema) {
callback(null, JSON.stringify(schema));
} else {
callback(new Error('Schema not found'));
}
}
};
const refParserOptions = {
mutateInputSchema: false,
resolve: {
http: refParserResolver,
external: true
}
};
refParser.dereference(JSON_SCHEMAS['area-chart-slots.schema.json'], refParserOptions)
.then((dereferencedSchema) => {
console.log(dereferencedSchema);
})
.catch((err) => {
console.error(err);
});
To validate a content item against a schema, you can use a library like ajv.
import Ajv from "ajv";
import ajvAddFormats from 'ajv-formats';
import { JSON_SCHEMAS } from '@luzmo/dashboard-contents-types';
const ajv = new Ajv({
schemas: Object.keys(JSON_SCHEMAS).map(key => JSON_SCHEMAS[key]),
allowUnionTypes: true,
strictTuples: false
});
ajvAddFormats(ajv);
const schemaId = 'https://developer.luzmo.com/assets/json-schemas/0.1.89/text-options.schema.json';
const validate = ajv.getSchema(schemaId);
const isValid = validate('VALUE TO VALIDATE');
console.log(isValid);
9 months ago
9 months ago
9 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago