### Run Development Server for Documentation (English)
Source: https://github.com/revealbi/documentation/blob/master/README.md
Starts the development server for the documentation in English. This command is used to preview the documentation locally during development.
```bash
npm start
```
--------------------------------
### Run Development Server for Documentation (Japanese)
Source: https://github.com/revealbi/documentation/blob/master/README.md
Starts the development server for the documentation in Japanese. This command allows viewing the localized version of the documentation locally.
```bash
npm run start:ja
```
--------------------------------
### Complete Program.cs Example with Reveal AI and OpenAI (C#)
Source: https://github.com/revealbi/documentation/blob/master/docs/web/ai/install-server-sdk.md
A comprehensive example of `Program.cs` demonstrating the configuration of CORS, base Reveal SDK, and Reveal AI with the OpenAI provider. Includes settings for local file storage.
```csharp
using Reveal.Sdk;
using Reveal.Sdk.AI;
var builder = WebApplication.CreateBuilder(args);
// Add CORS for cross-origin requests
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
policy.WithOrigins("http://localhost:4200")
.AllowAnyMethod()
.AllowAnyHeader();
});
});
// Add base Reveal SDK
builder.Services.AddControllers().AddReveal(revealBuilder =>
{
revealBuilder.AddSettings(settings =>
{
settings.LocalFileStoragePath = "Data";
});
});
// Add Reveal AI with OpenAI provider
builder.Services.AddRevealAI()
.ConfigureOpenAI(options =>
{
options.ApiKey = builder.Configuration["OpenAI:ApiKey"];
options.ModelId = "gpt-4.1";
});
var app = builder.Build();
app.UseCors();
app.MapControllers();
app.Run();
```
--------------------------------
### Initialize Node.js Project and Install Dependencies
Source: https://github.com/revealbi/documentation/blob/master/docs/web/getting-started-server-node-typescript.md
This snippet covers the initial setup of a Node.js project, including creating a directory, initializing npm, and installing essential packages like express, TypeScript, nodemon, and ts-node. It also includes configuring TypeScript.
```bash
mkdir reveal-server-node
cd reveal-server-node
npm init -y
npm install express
npm install typescript @types/node @types/express @types/cors --save-dev
npm install nodemon ts-node --save-dev
npx tsc --init --rootDir src --outDir dist
```
--------------------------------
### Install Project Dependencies with npm
Source: https://github.com/revealbi/documentation/blob/master/README.md
Installs all necessary project dependencies using npm. This command should be run after cloning or forking the repository.
```bash
npm install
```
--------------------------------
### Navigate to Angular App Directory and Open in VS Code
Source: https://github.com/revealbi/documentation/blob/master/docs/web/getting-started-angular.md
These commands change the current directory to the newly created 'getting-started' Angular application and then open the project in Visual Studio Code. This is a common workflow for starting development.
```bash
cd getting-started
code .
```
--------------------------------
### Run ASP.NET Core Application
Source: https://github.com/revealbi/documentation/blob/master/docs/web/ai/install-server-sdk.md
Command to run the ASP.NET Core application after installation and configuration of the Reveal AI Server SDK. This starts the backend services.
```bash
dotnet run
```
--------------------------------
### Build Documentation for Production
Source: https://github.com/revealbi/documentation/blob/master/README.md
Builds the documentation for production deployment. This command generates the static assets required to serve the documentation.
```bash
npm run build
```
--------------------------------
### Start Node.js Reveal SDK Server
Source: https://github.com/revealbi/documentation/blob/master/docs/web/getting-started-server-node.md
This command initiates the Node.js server that hosts the Reveal SDK. Ensure all dependencies are installed and the server code is correctly configured before running this command.
```bash
node main.js
```
--------------------------------
### Create React App with TypeScript
Source: https://github.com/revealbi/documentation/blob/master/docs/web/getting-started-react.md
This command uses npx to create a new React application with the name 'getting-started' and applies the 'typescript' template. This sets up a basic project structure for a React application using TypeScript.
```bash
npx create-react-app getting-started --template typescript
```
--------------------------------
### Create New Angular App using Angular CLI
Source: https://github.com/revealbi/documentation/blob/master/docs/web/getting-started-angular.md
This command creates a new Angular project named 'getting-started' using the Angular CLI. It sets up the basic structure for an Angular application.
```bash
ng new getting-started
```
--------------------------------
### Complete index.html with Reveal SDK and Dependencies
Source: https://github.com/revealbi/documentation/blob/master/docs/web/install-client-sdk.md
This is a complete example of an index.html file that includes the necessary dependencies (Jquery, Day.js) and the Reveal SDK script, all loaded from CDNs or local assets. This serves as a reference for integrating the SDK.
```html
Reveal Sdk - HTML/JavaScript
```
--------------------------------
### Create Project Folders (Bash)
Source: https://github.com/revealbi/documentation/blob/master/docs/web/ai/getting-started-html.md
Creates the necessary 'Dashboards' and 'Data' folders in the project root for organizing dashboard and data files.
```bash
mkdir Dashboards
mkdir Data
```
--------------------------------
### Initialize Reveal AI Client SDK in Vanilla JavaScript (UMD Bundle)
Source: https://github.com/revealbi/documentation/blob/master/docs/web/ai/install-client-sdk.md
Initializes the Reveal AI Client SDK using a UMD bundle in Vanilla JavaScript. This example shows how to include the script via CDN and then access the client to initialize it with a host URL.
```html
Reveal AI
```
--------------------------------
### Initialize Reveal AI Client SDK in Vanilla JavaScript (ES Modules)
Source: https://github.com/revealbi/documentation/blob/master/docs/web/ai/install-client-sdk.md
Initializes the Reveal AI Client SDK using ES Modules in a Vanilla JavaScript application. This example demonstrates how to import the client and initialize it with a host URL within an HTML file.
```html
Reveal AI
```
--------------------------------
### Initialize Reveal AI Client SDK in Angular
Source: https://github.com/revealbi/documentation/blob/master/docs/web/ai/install-client-sdk.md
Initializes the Reveal AI Client SDK before bootstrapping the Angular application. This code snippet should be placed in your `main.ts` file to ensure the SDK is ready when the app starts.
```typescript
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { RevealSdkClient } from '@revealbi/api';
import { AppModule } from './app/app.module';
RevealSdkClient.initialize({
hostUrl: 'https://your-server.com'
});
platformBrowserDynamic()
.bootstrapModule(AppModule)
.catch(err => console.error(err));
```
--------------------------------
### Create ASP.NET Core Web API Project
Source: https://github.com/revealbi/documentation/blob/master/docs/web/ai/getting-started-html.md
This snippet demonstrates how to create a new ASP.NET Core Web API project using the .NET CLI. This project will serve as the backend for the Reveal SDK AI application.
```bash
dotnet new webapi -n RevealAiServer
cd RevealAiServer
```
--------------------------------
### Install Reveal AI Client SDK using npm
Source: https://github.com/revealbi/documentation/blob/master/docs/web/ai/install-client-sdk.md
Installs the Reveal AI Client SDK package using npm. This is the recommended method for most projects. Ensure Node.js and npm are installed.
```bash
npm install @revealbi/api
```
--------------------------------
### Store LLM API Keys in appsettings.json
Source: https://github.com/revealbi/documentation/blob/master/docs/web/ai/install-server-sdk.md
Example of storing LLM provider API keys securely in the `appsettings.json` file. It's crucial to never commit these keys to source control.
```json
{
"OpenAI": {
"ApiKey": "sk-your-api-key-here"
},
"Anthropic": {
"ApiKey": "sk-ant-your-api-key-here"
}
}
```
--------------------------------
### Initialize Reveal AI Client SDK in Vue
Source: https://github.com/revealbi/documentation/blob/master/docs/web/ai/install-client-sdk.md
Initializes the Reveal AI Client SDK before mounting the Vue application. This setup should be done in your `main.ts` file to ensure the SDK is configured before the Vue app is initialized.
```typescript
import { createApp } from 'vue';
import { RevealSdkClient } from '@revealbi/api';
import App from './App.vue';
RevealSdkClient.initialize({
hostUrl: 'https://your-server.com'
});
createApp(App).mount('#app');
```
--------------------------------
### Run NestJS Server
Source: https://github.com/revealbi/documentation/blob/master/docs/web/getting-started-server-nest.md
Starts the NestJS server. The `npm run start` command runs the application in production mode, while `npm run start:dev` enables live-reload for development.
```bash
npm run start
```
```bash
npm run start:dev
```
--------------------------------
### Create Basic HTML Structure for Reveal SDK
Source: https://github.com/revealbi/documentation/blob/master/docs/web/getting-started-javascript.md
This snippet provides the fundamental HTML structure required for a Reveal SDK application. It includes the necessary meta tags and a title, serving as the base for embedding the SDK.
```html
Reveal Sdk - HTML/JavaScript
```
--------------------------------
### Install Reveal SDK for Node.js
Source: https://github.com/revealbi/documentation/blob/master/docs/web/install-server-sdk.md
Installs the reveal-sdk-node package using npm and integrates the Reveal SDK into an Express.js application by adding `app.use('/', reveal());` to the main server file.
```bash
npm install reveal-sdk-node
```
```javascript
var express = require('express');
// highlight-next-line
var reveal = require('reveal-sdk-node');
const app = express();
// highlight-next-line
app.use('/', reveal());
app.listen(8080, () => {
console.log(`Reveal server accepting http requests`);
});
```
--------------------------------
### Initialize Node.js Project and Install Express
Source: https://github.com/revealbi/documentation/blob/master/docs/web/getting-started-server-node.md
This snippet demonstrates the initial steps to set up a Node.js project. It includes creating a project directory, initializing npm, and installing the express framework, which is essential for building web servers.
```bash
mkdir reveal-server-node
cd reveal-server-node
npm init -y
npm install express
code .
```
--------------------------------
### Configure API Key using User Secrets
Source: https://github.com/revealbi/documentation/blob/master/docs/web/ai/getting-started-html.md
This example demonstrates how to securely manage your OpenAI API key during development using the .NET User Secrets feature. It involves initializing user secrets and then setting the API key as a secret.
```bash
dotnet user-secrets init
dotnet user-secrets set "RevealAI:OpenAI:ApiKey" "sk-your-openai-api-key-here"
```
--------------------------------
### Get AI Insights (Await Mode) - JavaScript
Source: https://github.com/revealbi/documentation/blob/master/docs/web/ai/getting-started-html.md
Retrieves AI insights from a dashboard using await mode. This method waits for the complete response before returning. It requires the dashboard object and specifies the insight type.
```javascript
const result = await client.ai.insights.get({
dashboard: dashboard,
insightType: rv.InsightType.Summary
});
console.log(result.explanation);
```
--------------------------------
### Declare jQuery and Initialize RevealView in AppComponent TS
Source: https://github.com/revealbi/documentation/blob/master/docs/web/getting-started-angular.md
This TypeScript code demonstrates how to declare the global jQuery variable `$` for TypeScript compatibility and initializes the Reveal SDK's `RevealView` within the `ngAfterViewInit` lifecycle hook. It uses a `ViewChild` to get a reference to the HTML container.
```typescript
import { AfterViewInit, Component, ElementRef, ViewChild } from '@angular/core';
declare let $: any;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements AfterViewInit {
@ViewChild('revealView') el!: ElementRef;
ngAfterViewInit(): void {
var revealView = new $.ig.RevealView(this.el.nativeElement);
}
}
```
--------------------------------
### Start Node.js Development Server
Source: https://github.com/revealbi/documentation/blob/master/docs/web/getting-started-server-node-typescript.md
This command initiates the Node.js development server using Nodemon. Nodemon monitors the source files and automatically restarts the server when changes are detected, facilitating a rapid development workflow.
```bash
npx nodemon src/app.ts
```
--------------------------------
### Get AI Insights (Streaming Mode) - JavaScript
Source: https://github.com/revealbi/documentation/blob/master/docs/web/ai/getting-started-html.md
Retrieves AI insights from a dashboard using streaming mode for a real-time experience. This method allows for progressive updates via callbacks like onTextChunk and onComplete. It requires the dashboard object, insight type, and stream options.
```javascript
const result = await client.ai.insights.get(
{
dashboard: dashboard,
insightType: rv.InsightType.Summary
},
{
onTextChunk: (text) => {
// Append each chunk as it arrives
displayInsight(text, true);
},
onComplete: () => {
console.log('Done!');
}
},
{ streamExplanation: true }
);
```
--------------------------------
### Get AI Insights with Streaming and Await Modes (JavaScript)
Source: https://github.com/revealbi/documentation/blob/master/docs/web/ai/getting-started-html.md
This snippet demonstrates how to fetch AI insights using the RevealBI client. It supports both real-time streaming responses and waiting for a complete response. Error handling is included for both modes. Dependencies include the RevealBI client library.
```javascript
options.visualizationId = visualizationId;
}
try {
if (streamingEnabled) {
// Streaming mode - responses arrive in real-time
const result = await client.ai.insights.get(
options,
{
onProgress: (message) => {
console.log('Progress:', message);
displayInsight(`*${message}*\n\n`, true);
},
onTextChunk: (text) => {
console.log('Text chunk:', text);
displayInsight(text, true);
},
onComplete: () => {
console.log('Insight complete');
},
onError: (error, details) => {
console.error('Error:', error, details);
displayInsight(`**Error:** ${error}`);
}
},
{
streamExplanation: true
}
);
} else {
// Await mode - wait for complete response
const result = await client.ai.insights.get(options);
displayInsight(result.explanation);
}
} catch (error) {
console.error('Error getting insight:', error);
displayInsight(`**Error:** ${error.message || error}`);
}
});
}
// Load dashboard and configure menu items
$.ig.RVDashboard.loadDashboard("Accounts", (dashboard) => {
revealView = new $.ig.RevealView("#revealView");
revealView.canEdit = false;
revealView.canSaveAs = false;
revealView.dashboard = dashboard;
// Add AI insights to context menus
revealView.onMenuOpening = function (visualization, args) {
// Dashboard-level insights
if (args.menuLocation === $.ig.RVMenuLocation.Dashboard) {
args.menuItems.push(createInsightMenuItem(
"Dashboard Summary", dashboard, rv.InsightType.Summary));
args.menuItems.push(createInsightMenuItem(
"Dashboard Analysis", dashboard, rv.InsightType.Analysis));
args.menuItems.push(createInsightMenuItem(
"Dashboard Forecast", dashboard, rv.InsightType.Forecast));
}
// Visualization-level insights
if (args.menuLocation === $.ig.RVMenuLocation.Visualization) {
args.menuItems.push(createInsightMenuItem(
"Visualization Summary", dashboard, rv.InsightType.Summary, visualization.id));
args.menuItems.push(createInsightMenuItem(
"Visualization Analysis", dashboard, rv.InsightType.Analysis, visualization.id));
args.menuItems.push(createInsightMenuItem(
"Visualization Forecast", dashboard, rv.InsightType.Forecast, visualization.id));
}
};
});