Guides
Visit our websiteDeveloper Docs
  • Getting Started with Databrain
    • What is Databrain?
  • ❄️Onboarding & Configuration
    • πŸ“Sign-Up
    • ✍️Sign-In
    • ✏️Google Sign In Setup for Self-hosted app
    • πŸ€”Forgot password? Recover your Databrain Account
    • 🌟Onboarding
    • πŸ’ΎAdd a Data Source
    • πŸ§‘Configure Tenants
    • πŸ†•Create a Workspace
    • πŸ”“Create a Private Workspace
    • πŸ†•Create a Dashboard
    • πŸ’ Create a Metric
      • Create Custom Columns
      • Create a Metric using Chat Mode
      • Create a Metric using Custom SQL
    • Workspace Settings
      • General Settings
      • Access Control Settings
      • Cache Settings
      • Download Settings
    • πŸ—„οΈExplore Data
  • πŸ›’οΈDatasources
    • Connecting Data Sources to Databrain
      • Amazon Redshift
      • Snowflake
      • BigQuery
      • MySQL
      • Postgres
      • MongoDB
      • ElasticSearch
      • DataBricks
      • ClickHouse
      • MSSQL
      • Amazon S3
      • CSV
      • Firebolt
      • SingleStore
      • Athena
    • Allow Access to our IP
    • Add a Data Source
    • Configure Tenants
    • How to Sync a Data Source
    • Edit Tenancy
    • Create a Datamart
    • Semantic Layer
    • Create a Data App
    • Creating a Custom Dataset/View in a Multi-Datasource Environment
  • Workspace
    • Multi Datasource Workspace
  • πŸ”DASHBOARDS
    • Edit a Dashboard
    • Share Dashboard
    • Dashboard Settings
    • Create/Modify Dashboard Filter
      • Dashboard Filter - Variable Apply On
      • Add LHS and RHS custom sql support for dashboard filter
    • Customize Layout
    • Adding Elements to Dashboard
    • Import/Export Dashboard
    • Report Scheduler
  • πŸ“‰METRIC
    • Edit a Metric
    • Joins , Filter, Sort, Group By
    • Complex Filter
    • Apply Metric Filter
      • Metric Filter - Variable
      • Metric Filter - Custom
    • Switch X axis and Switch Y axis
    • Group By
    • Footnote and Long Description
    • Dynamic Property
    • Archive/Unarchive Metric Card
    • Download Metric Card
    • Download Underlying Data
    • Metric Summary
    • Metric Expression for Single Value Card
    • AI Summary
    • Merge Metrics
    • Section Filters
    • View Unpublished Metrics
  • πŸ“ŠVISUALIZATIONS - ACTIONS & APPEARANCE
    • Chart Actions
      • Chart Click Action
      • Chart Click Action with Metric
      • Card Click Action
      • Drill Down
      • Cross Dashboard Drill Down
    • Chart Appearance
      • Chart-Specific Appearance Options
  • πŸ›’οΈPREVIEW OF DASHBOARDS
    • Email Settings for Scheduled Reports
    • Scheduled Reports for End User
  • πŸ”FILTERS
    • Dashboard Filter
    • Metric Filter
    • App filter
  • πŸ’‘Features
    • Python Editor Console
    • Custom SQL Console
    • Custom SQL Query Guidelines
  • 🏒Integrating Plugin
    • ✳️Get an auth token
    • πŸ™Get a guest token
  • πŸ›ƒTHEMEING & CUSTOMIZATION
    • 🎨Creating a theme
    • πŸ–ΌοΈView the theme in action
    • βš™οΈReset a saved theme
  • πŸ“ŠMetric Component (upto version v0.11.15)
    • ✨Quick start
  • πŸ•ΈοΈWeb Components
    • ✨Quick start
    • βš›οΈFramework Specific Guide
  • πŸš€Product Changelog
  • 🀳Self Hosted Changelog
Powered by GitBook
On this page
  • @databrainhq/plugin
  • Install
  • Usage
  1. Web Components

Framework Specific Guide

This article will guide you integrate databrain plugin in your respective UI frameworks/libraries.

PreviousQuick startNextProduct Changelog

Last updated 1 year ago

@databrainhq/plugin

Databrain app ui web component plugin.

Install

npm install @databrainhq/plugin

Usage

React/Solidjs

Import in main/index/App

import '@databrainhq/plugin/web';

Then use it anywhere in your app

Integrating Dashboard

const Example = () => {
  return (
    <dbn-dashboard
      token="Your Guest Token"
      dashboard-id="Your Dashboard Id"
      options={{
        disableMetricCreation: false,
        disableMetricUpdation: false,
        disableMetricDeletion: false,
        disableLayoutCustomization: false,
        chartColors: [
          'violet',
          'indigo',
          'blue',
          'green',
          'yellow',
          'orange',
          'red',
          'pink',
          'gray',
        ],
      }}
      theme={YOUR_THEME}
    />
  );
};

Integrating Metric

const Example = () => {
  return (
    <dbn-metric
      token="Your Guest Token"
      metric-id="Your Metric Id"
      width="500px"
      height="300px"
      chart-renderer-type="canvas"
      chart-colors={[
        'violet',
        'indigo',
        'blue',
        'green',
        'yellow',
        'orange',
        'red',
        'pink',
        'gray',
      ]}
      theme={YOUR_THEME}
    />
  );
};

Vue

Import in main/index/App

<script setup lang="ts">
import '@databrainhq/plugin/web';
</script>

Then use it anywhere in your app

Integrating Dashboard

<script setup lang="ts">
  // your component logic
</script>
<template>
  <dbn-dashboard
    :token="/*YOUR GUEST TOKEN*/"
    :options="/*YOUR ACCESS PERMISSION OPTIONS*/"
    :theme="/*YOUR THEME*/"
    :dashboard-id="/*YOUR DASHBORD ID*/"
  ></dbn-dashboard>
</template>

Integrating Metric

<script setup lang="ts">
  // your component logic
</script>
<template>
  <dbn-metric
    :token="/*YOUR GUEST TOKEN*/"
    chart-renderer-type="canvas"
    :theme="/*YOUR THEME*/"
    :dashboard-id="/*YOUR DASHBORD ID*/"
    width="500"
    height="400"
    :style="/* YOUR STYLEs */"
    class-name="YOUR CLASS"
  ></dbn-metric>
</template>

Svelte

Import in main/index/App

<script lang="ts">
import '@databrainhq/plugin/web';
</script>

Then use it anywhere in your app

Integrating Dashboard

<script lang="ts">
  // your component logic
</script>
<main>
  <dbn-dashboard
    token={/*YOUR GUEST TOKEN*/}
    options={/*YOUR ACCESS PERMISSION OPTIONS*/}
    theme={/*YOUR THEME*/}
    dashboard-id={/*YOUR DASHBORD ID*/}
  ></dbn-dashboard>
</main>

Integrating Metric

<script lang="ts">
// your component logic
</script>
<main>
  <dbn-metric
    token={/*YOUR GUEST TOKEN*/}
    chart-renderer-type="canvas"
    theme={/*YOUR THEME*/}
    dashboard-id="/*YOUR DASHBORD ID*/"
    width="500"
    height="400"
    style={/* YOUR STYLEs */}
    class-name="YOUR CLASS"
  ></dbn-metric>
</main>

Angular

Add suport for custom elements/web components in app.module.ts

// app.module.ts
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule],
  providers: [],
  bootstrap: [AppComponent],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
})

export class AppModule {}

Import in app.component.ts

import '@databrainhq/plugin/web';

Then use it anywhere in your app

Integrating Dashboard

<dbn-dashboard
  token="YOUR GUEST TOKEN"
  options="YOUR ACCESS PERMISSION OPTIONS"
  theme="YOUR THEME"
  dashboard-id="YOUR DASHBORD ID"
></dbn-dashboard>

Integrating Metric

<dbn-metric
  token="YOUR GUEST TOKEN"
  chart-renderer-type="canvas"
  theme="YOUR THEME"
  dashboard-id="YOUR DASHBORD ID"
  width="500"
  height="400"
  style="YOUR STYLE"
  class-name="YOUR CLASS"
></dbn-metric>

πŸ•ΈοΈ
βš›οΈ
NPM
JavaScript Style Guide