Import the library main or index or App or layout file
import'@databrainhq/plugin/web';
Once the library is imported, the web-components dbn-dashboard, dbn-metrics are available to use anywhere inside your app. And you use it anywhere in your app like:
constExample= () => {return ( <dbn-dashboardtoken="Your Guest Token"dashboard-id="Your Dashboard Id"is-hide-table-preview// in full screen view defaults to falseis-hide-chart-settings// in full screen view defaults to falseenable-download-csv// in metric card more icon actions defaults to falseenable-email-csv// in metric card more icon actions defaults to falseoptions-icon="kebab-menu-vertical | download"// one of the options defaults to kebab-menu-verticalenable-multi-metric-filters// in metric card allow multiple metric filtersdisable-fullscreen// to disable fullscreen viewtheme-name="Name of the theme you want to apply from app settings ui theming"custom-messages={JSON.stringify({ tokenExpiry:"Some custom message you want to show here." })} // optional all keys as welloptions={JSON.stringify({ disableMetricCreation:false, disableMetricUpdation:false, disableMetricDeletion:false, disableLayoutCustomization:false, hideDashboardName:false, chartColors: ['violet','indigo','blue','green','yellow','orange','red','pink','gray', ], })}theme={YOUR_THEME} /> );};
Integrating Metric
constExample= () => {return ( <dbn-metrictoken="Your Guest Token"metric-id="Your Metric Id"width="500"height="300"is-hide-chart-settings// in full screen view defaults to falseis-hide-table-preview// in full screen view defaults to falseenable-download-csv// in metric card more icon actions defaults to falseenable-email-csv// in metric card more icon actions defaults to falseenable-multi-metric-filters// in metric card allow multiple metric filtersoptions-icon="kebab-menu-vertical | download"// one of the options defaults to kebab-menu-vertical metric-filter-position="outside | inside" // one of the option defaults to outside (from beta version 0.13.0-beta.8 only)
chart-renderer-type="canvas"disable-fullscreen// to disable fullscreen viewtheme-name="Name of the theme you want to apply from app settings ui theming"custom-messages={JSON.stringify({ tokenExpiry:"Some custom message you want to show here." })} // optional all keys as wellchart-colors={JSON.stringify(['violet','indigo','blue','green','yellow','orange','red','pink','gray', ])}metric-filter-options={JSON.stringify({ // note that invalid options will be filtered out"Filter name for a string datatype": { options: ['hello','hi'],// should have unique elements defaultOption:'hello',// name of the option },"Filter name for a number datatype": { options: [9,19,23],// should have unique elements defaultOption:19,// name of the option },"Filter name for a date datatype": { options: [{ range:'Last|This|Custom',// one of the three option time:'Day|Week|Month|Quarter|Year',// one of the five option ignored for range = "Custom" name:'Last 10 Years',// will be shown in the list count:10,// required for range = "Last" else ignored fromDate:newDate(),// optional if you don't want date picker for custom range else ignored toDate:newDate(),// optional if you don't want date picker for custom range else ignored minDate:newDate(),// optional for custom range else ignored maxDate:newDate(),// optional for custom range else ignored },{ range:'Last|This|Custom',// one of the three option time:'Day|Week|Month|Quarter|Year',// one of the five option for range "Custom" nit required name:'This Year',// will be shown in the list count:0,// required for range "Last" else not required minDate:newDate(),// optional for custom range maxDate:newDate(),// optional for custom range }], defaultOption:'Last 10 Years',// name of the option }, })}theme={YOUR_THEME}appearance-options={JSON.stringify({ appearanceOptionsPosition: 'top-left|top-right|bottom-left|bottom-right', // one of the four options, by default it is bottom-right
cumulativeBar: { isEnabled:true|false,// can be used with bar and time series charts (if series type is bar) label:'Cumulative'// change the label for the property }, stackedBars: { isEnabled:true|false,// can be used with stack chart only label:'100% stacked bars',// change the label for the property }, dynamicBehaviour: { isEnabled:true|false,// can be used with bar, line, area, stacked area and time series charts label:'Dynamic'//change the label for the property }, })} /> );};