Skip to content

Commit

Permalink
update sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
Tan Phat VO authored and Tan Phat VO committed Dec 5, 2024
1 parent 7871266 commit 7aab4b4
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
72 changes: 72 additions & 0 deletions e2e/Sandbox/DashboardCreators/MySqlDataSourceDashboards.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using Reveal.Sdk.Dom;
using Reveal.Sdk.Dom.Data;
using Reveal.Sdk.Dom.Filters;
using Reveal.Sdk.Dom.Visualizations;
using Sandbox.DashboardFactories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sandbox.DashboardCreators
{
public class MySqlDataSourceDashboards : IDashboardCreator
{
public string Name => "MySql Data Source";

public RdashDocument CreateDashboard()
{
var mysqlDS = new MySQLDataSource
{
Id = "mysqlDS",
Title = "MySQL DS",
Subtitle = "My SQL Datasource",
Host = "revealdb01.infragistics.local",
Database = "northwind",
Port = "3306",
};

var mysqlDSItem = new MySqlDataSourceItem("employees report to ID", mysqlDS)
{
Id = "mysqlDSItem",
Title = "MySQL DSItem",
Subtitle = "My SQL Datasource order table",
Database = "northwind",
Table = "employees",
Fields = new List<IField>
{
new NumberField("ReportsTo"),
new NumberField("EmployeeID"),
new TextField("Country"),
}
};

var document = new RdashDocument()
{
Title = "MySql",
Description = "Example for MySql",
UseAutoLayout = false,
};

var dateFilter = new DashboardDateFilter("My Date Filter");
document.Filters.Add(dateFilter);

var countryFilter = new DashboardDataFilter("Country", mysqlDSItem);
document.Filters.Add(countryFilter);

document.Visualizations.Add(CreateEmployeeReportColumnVisualization(mysqlDSItem, countryFilter));

return document;
}

private static Visualization CreateEmployeeReportColumnVisualization(DataSourceItem mysql, params DashboardFilter[] filters)
{
return new ColumnChartVisualization("Employees report", mysql)
.SetLabel("ReportsTo")
.SetValue("EmployeeID")
.ConnectDashboardFilters(filters)
.SetPosition(20, 11);
}
}
}
3 changes: 3 additions & 0 deletions e2e/Sandbox/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Reveal.Sdk.Data.Rest;
using Reveal.Sdk.Data.Snowflake;
using Reveal.Sdk.Dom;
using Sandbox.DashboardCreators;
using Sandbox.DashboardFactories;
using Sandbox.RevealSDK;
using System;
Expand Down Expand Up @@ -51,6 +52,7 @@ public partial class MainWindow : Window
new RestDataSourceDashboard(),
new SalesDashboard(),
new SqlServerDataSourceDashboards(),
new MySqlDataSourceDashboards()
};

public MainWindow()
Expand All @@ -62,6 +64,7 @@ public MainWindow()
RevealSdkSettings.DataSources.RegisterMicrosoftSqlServer().RegisterMicrosoftAnalysisServices();
RevealSdkSettings.DataSources.RegisterMySql();


LoadDashboards();

_revealView.LinkedDashboardProvider = (string dashboardId, string linkTitle) =>
Expand Down

0 comments on commit 7aab4b4

Please sign in to comment.