Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added data source item factory #49

Merged
merged 8 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
618 changes: 314 additions & 304 deletions e2e/Sandbox/Factories/CustomDashboard.cs

Large diffs are not rendered by default.

142 changes: 82 additions & 60 deletions e2e/Sandbox/Factories/RestDataSourceDashboards.cs
Original file line number Diff line number Diff line change
@@ -1,60 +1,82 @@
using Reveal.Sdk.Dom;
using Reveal.Sdk.Dom.Data;
using Reveal.Sdk.Dom.Visualizations;
using Sandbox.Helpers;
using DataSourceFactory = Sandbox.Helpers.DataSourceFactory;

namespace Sandbox.Factories
{
internal class RestDataSourceDashboards
{
internal static RdashDocument CreateDashboard()
{
var document = new RdashDocument("My Dashboard");

//json - default
var jsonDataSourceItem = new RestServiceBuilder("https://excel2json.io/api/share/6e0f06b3-72d3-4fec-7984-08da43f56bb9")
.SetTitle("JSON Data Source")
.SetSubtitle("Sales by Category")
.SetFields(DataSourceFactory.GetSalesByCategoryFields())
.Build();

document.Visualizations.Add(new PieChartVisualization("JSON", jsonDataSourceItem)
.SetLabel("CategoryName").SetValue("ProductSales"));

//excel
var excelDataSourceItem = new RestServiceBuilder("http://dl.infragistics.com/reportplus/reveal/samples/Samples.xlsx")
.UseExcel()
.SetTitle("Excel Data Source")
.SetSubtitle("Marketing")
.SetFields(DataSourceFactory.GetMarketingDataSourceFields())
.Build();

document.Visualizations.Add(new PieChartVisualization("Excel", excelDataSourceItem)
.SetLabel("Territory").SetValue("Conversions"));

//csv
var csvDataSourceItem = new RestServiceBuilder("https://query.data.world/s/y32gtgblzpemyyvtig47dz7tedgkto")
.UseCsv()
.SetTitle("CSV Data Source")
.SetSubtitle("Illinois School Info")
.SetFields(DataSourceFactory.GetCsvDataSourceFields())
.Build();

document.Visualizations.Add(new ScatterMapVisualization("Scatter", csvDataSourceItem)
.SetMap(Maps.NorthAmerica.UnitedStates.States.Illinois)
.SetLongitude("X")
.SetLatitude("Y")
.SetLabel("School_Nm")
.ConfigureSettings(settings =>
{
settings.Zoom.Longitude = 1.38;
settings.Zoom.Latitude = 41.65;
settings.Zoom.DegreesLongitude = 1.04;
settings.Zoom.DegreesLatitude = 0.39;
}));

return document;
}
}
}
using Reveal.Sdk.Dom;
using Reveal.Sdk.Dom.Data;
using Reveal.Sdk.Dom.Visualizations;
using Sandbox.Helpers;

namespace Sandbox.Factories
{
internal class RestDataSourceDashboards
{
static IDataSourceItemFactory _factory = new DataSourceItemFactory();

internal static RdashDocument CreateDashboard()
{
var document = new RdashDocument("My Dashboard");

//json - default
var jsonDataSourceItem = _factory.Create(DataSourceType.REST, "Sales by Category")
.Subtitle("JSON Data Source Item")
.Fields(DataSourceFactory.GetSalesByCategoryFields())
.As<IRestDataSourceItemBuilder>()
.Uri("https://excel2json.io/api/share/6e0f06b3-72d3-4fec-7984-08da43f56bb9")
.IsAnonymous(true)
.ConfigureDataSource(d =>
{
d.Title = "JSON DS";
d.Subtitle = "JSON DS Subtitle";
})
.Build();

document.Visualizations.Add(new PieChartVisualization("JSON", jsonDataSourceItem)
.SetLabel("CategoryName").SetValue("ProductSales"));

//excel
var excelDataSourceItem = _factory.Create(DataSourceType.REST, "Marketing")
.Subtitle("Excel Data Source Item")
.Fields(DataSourceFactory.GetMarketingDataSourceFields())
.As<IRestDataSourceItemBuilder>()
.Uri("http://dl.infragistics.com/reportplus/reveal/samples/Samples.xlsx")
.IsAnonymous(true)
.UseExcel("Marketing")
.ConfigureDataSource(d =>
{
d.Title = "Excel DS";
d.Subtitle = "Excel DS Subtitle";
})
.Build();

document.Visualizations.Add(new PieChartVisualization("Excel", excelDataSourceItem)
.SetLabel("Territory").SetValue("Conversions"));

//csv
var csvDataSourceItem = _factory.Create(DataSourceType.REST, "Illinois School Info")
.Subtitle("CSV Data Source Item")
.Fields(DataSourceFactory.GetCsvDataSourceFields())
.As<IRestDataSourceItemBuilder>()
.Uri("https://query.data.world/s/y32gtgblzpemyyvtig47dz7tedgkto")
.IsAnonymous(true)
.UseCsv()
.ConfigureDataSource(d =>
{
d.Title = "CSV DS";
d.Subtitle = "CSV DS Subtitle";
})
.Build();

document.Visualizations.Add(new ScatterMapVisualization("Scatter", csvDataSourceItem)
.SetMap(Maps.NorthAmerica.UnitedStates.States.Illinois)
.SetLongitude("X")
.SetLatitude("Y")
.SetLabel("School_Nm")
.ConfigureSettings(settings =>
{
settings.Zoom.Longitude = 1.38;
settings.Zoom.Latitude = 41.65;
settings.Zoom.DegreesLongitude = 1.04;
settings.Zoom.DegreesLatitude = 0.39;
}));

return document;
}
}
}
63 changes: 33 additions & 30 deletions e2e/Sandbox/Factories/SqlServerDataSourceDashboards.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
using Reveal.Sdk.Dom;
using Reveal.Sdk.Dom.Data;
using Reveal.Sdk.Dom.Visualizations;
using System.Collections.Generic;

namespace Sandbox.Factories
{
internal class SqlServerDataSourceDashboards
{
internal static RdashDocument CreateDashboard()
{
var document = new RdashDocument("My Dashboard");

var sqlServerDataSourceItem = new SqlServerBuilder("host", "database", "table")
.SetTitle("SQL Server")
.SetSubtitle("Orders")
.SetFields(new List<IField>()
{
new TextField("CustomerID"),
new NumberField("OrderID"),
})
.Build();

document.Visualizations.Add(new BarChartVisualization("SQL Server Bar Chart", sqlServerDataSourceItem)
.SetLabel("CustomerID").SetValue(new NumberDataField("OrderID") { AggregationType = AggregationType.CountRows }));

return document;
}
}
}
using Reveal.Sdk.Dom;
using Reveal.Sdk.Dom.Data;
using Reveal.Sdk.Dom.Visualizations;
using System.Collections.Generic;

namespace Sandbox.Factories
{
internal class SqlServerDataSourceDashboards
{
internal static RdashDocument CreateDashboard()
{
var document = new RdashDocument("My Dashboard");

var sqlServerDataSourceItem = new DataSourceItemFactory().Create(DataSourceType.MicrosoftSqlServer, "Customers")
.Subtitle("SQL Server Data Source Item")
.Fields(new List<IField>
{
new TextField("ContactName"),
new TextField("ContactTitle"),
new TextField("City")
})
.As<ISqlDataSourceItemBuilder>()
.Host(@"Brian-Desktop\SQLEXPRESS")
.Database("Northwind")
.Table("Customers")
.Build();

document.Visualizations.Add(new GridVisualization("Customer List", sqlServerDataSourceItem).SetColumns("ContactName", "ContactTitle", "City"));

return document;
}
}
}
Loading
Loading