-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tan Phat VO
authored and
Tan Phat VO
committed
Dec 5, 2024
1 parent
7871266
commit 7aab4b4
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
e2e/Sandbox/DashboardCreators/MySqlDataSourceDashboards.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters