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
  1. Web Components

Quick start

This will explain you how to use the databrain plugin and customization.

Step 1: install databrain package

npm install @databrainhq/plugin

Step 2: import in top level of your application e.g. main/index/app

import '@databrainhq/plugin/web';

Step 3: Then use it anywhere in your app.

<dbn-metric token="token" metric-id="metricId" />
<dbn-dashboard token="token" dashboard-id="dashboardId" />

Step 4: Customization.

<dbn-dashboard
  token="token"
  dashboard-id="dashboardId"
  options={{
      disableMetricCreation: false, // optional - false by default
      disableMetricUpdationtion: false, // optional - false by default
      disableMetricDeletion: false, // optional - false by default
      disableLayoutCustomization: false, // optional - false by default
      chartColors: ["red", "blue", "orange", "..."], // array of color strings - by default recharts default colors
      hideDashboardName: true  // optional - false by default
  }}
  theme={JSON.stringify({
      colors: {
          background: "",
          primary: "",
          primaryLight: "",
          primaryDark: "",
          secondary: "",
          secondaryLight: "",
          secondaryDark: "",
          tertiary: "",
          tertiaryLight: "",
          tertiaryDark: "",
          error: "",
          errorLight: "",
          errorDark: "",
          warning: "",
          warningLight: "",
          warningDark: "",
          dark: "",
          light: "",
          gray50: "",
          gray100: "",
          gray200: "",
          gray300: "",
          gray400: "",
          gray500: "",
          gray600: "",
          gray700: "",
          gray800: "",
          gray900: "",
      },
      border: {
          radiusNone: "0",
          radiusDefault: "5px",
          radiusSm: "2px",
          radiusMd: "10px",
          radiusLg: "16px",
          radiusXl: "20px",
          radius2xl: "24px",
          radius3xl: "30px",
          radiusFull: "50%",
      },
      typography: {
          fontSize: "9px",
          fontFamily: "Inter",
          fontWeightThin: 200,
          fontWeightLight: 300,
          fontWeightRegular: 400,
          fontWeightSemibold: 500,
          fontWeightBold: 600,
          colorPrimary: "",
          colorSecondary: "",
          colorTertiary: "",
      },
      breakpoint: {
          xs: 360,
          sm: 512,
          md: 720,
          lg: 990,
          xl: 1280,
      },
      metricLayoutCols: { 
          lg: 12, 
          md: 10, 
          sm: 6, 
          xs: 4, 
          xxs: 2,
      },
      shadow: {
          primary: "",
          secondary: "",
          tertiary: ""
      }
   })}
/>
<dbn-metric
  token={token}
  metric-id={metricId}
  width={500}
  height={300}
  style={style}
  class-name={className}
  chart-colors={["red", "blue", "orange", "..."]} // array of color strings - by default recharts default colors
  theme={JSON.stringify({
      colors: {
          background: "",
          primary: "",
          primaryLight: "",
          primaryDark: "",
          secondary: "",
          secondaryLight: "",
          secondaryDark: "",
          tertiary: "",
          tertiaryLight: "",
          tertiaryDark: "",
          error: "",
          errorLight: "",
          errorDark: "",
          warning: "",
          warningLight: "",
          warningDark: "",
          dark: "",
          light: "",
          gray50: "",
          gray100: "",
          gray200: "",
          gray300: "",
          gray400: "",
          gray500: "",
          gray600: "",
          gray700: "",
          gray800: "",
          gray900: "",
      },
      border: {
          radiusNone: "0",
          radiusDefault: "5px",
          radiusSm: "2px",
          radiusMd: "10px",
          radiusLg: "16px",
          radiusXl: "20px",
          radius2xl: "24px",
          radius3xl: "30px",
          radiusFull: "50%",
      },
      typography: {
          fontSize: "9px",
          fontFamily: "Inter",
          fontWeightThin: 200,
          fontWeightLight: 300,
          fontWeightRegular: 400,
          fontWeightSemibold: 500,
          fontWeightBold: 600,
          colorPrimary: "",
          colorSecondary: "",
          colorTertiary: "",
      },
      breakpoint: {
          xs: 360,
          sm: 512,
          md: 720,
          lg: 990,
          xl: 1280,
      },
      metricLayoutCols: { 
          lg: 12, 
          md: 10, 
          sm: 6, 
          xs: 4, 
          xxs: 2,
      },
      shadow: {
          primary: "",
          secondary: "",
          tertiary: ""
      }
   })}
/>

Note: If you are getting Property 'dbn-dashboard' does not exist on type 'JSX.IntrinsicElements'. or Property 'dbn-metric' does not exist on type 'JSX.IntrinsicElements'.

Create a dbn.d.ts file in your src folder or in your global types.d.ts file add these following lines.

```typescript
declare namespace JSX {
  interface IntrinsicElements {
    "dbn-dashboard": any;
    "dbn-metric": any;
  }
}
```
PreviousQuick startNextFramework Specific Guide

Last updated 11 months ago

For more information please refer to this issue

πŸ•ΈοΈ
✨
https://github.com/microsoft/TypeScript/issues/48310