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

Removed builders and moved to DataSourceItems #50

Merged
merged 2 commits into from
May 15, 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
100 changes: 67 additions & 33 deletions e2e/Sandbox/Factories/CustomDashboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,73 @@ internal static RdashDocument CreateDashboard()
{
var factory = new DataSourceItemFactory();

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

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()
.Build();

var financialDataSourceItem = factory.Create(DataSourceType.REST, "OHLC")
.Subtitle("Financial Data Source Item")
.Fields(DataSourceFactory.GetOHLCDataSourceFields())
.As<IRestDataSourceItemBuilder>()
.Uri("https://excel2json.io/api/share/8bb2cd78-1b87-4142-00a2-08da188ec9ab")
.IsAnonymous(true)
.Build();

var revenueDataSourceItem = factory.Create(DataSourceType.REST, "Revenue")
.Subtitle("Choropleth Data Source Item")
.Fields(DataSourceFactory.GetRevenueDataSourceFields())
.As<IRestDataSourceItemBuilder>()
.Uri("https://excel2json.io/api/share/818e7b9a-f463-4565-435d-08da496bf5f2")
.IsAnonymous(true)
.Build();
//var excelDataSourceItem = factory.Create(DataSourceType.REST, "Marketing Sheet")
// .SetSubtitle("Excel Data Source Item")
// .SetFields(DataSourceFactory.GetMarketingDataSourceFields())
// .As<RestDataSourceItem>()
// .Uri("http://dl.infragistics.com/reportplus/reveal/samples/Samples.xlsx")
// .IsAnonymous(true)
// .UseExcel("Marketing")
// .Build();

var excelDataSourceItem = new RestDataSourceItem("Marketing Sheet")
{
Subtitle = "Excel Data Source Item",
Uri = "http://dl.infragistics.com/reportplus/reveal/samples/Samples.xlsx",
IsAnonymous = true,
Fields = DataSourceFactory.GetMarketingDataSourceFields(),
};
excelDataSourceItem.UseExcel("Marketing");

//var csvDataSourceItem = factory.Create(DataSourceType.REST, "Illinois School Info")
// .SetSubtitle("CSV Data Source Item")
// .SetFields(DataSourceFactory.GetCsvDataSourceFields())
// .As<RestDataSourceItem>()
// .Uri("https://query.data.world/s/y32gtgblzpemyyvtig47dz7tedgkto")
// .IsAnonymous(true)
// .UseCsv()
// .Build();

var csvDataSourceItem = new RestDataSourceItem("Illinois School Info")
{
Subtitle = "CSV Data Source Item",
Uri = "https://query.data.world/s/y32gtgblzpemyyvtig47dz7tedgkto",
IsAnonymous = true,
Fields = DataSourceFactory.GetCsvDataSourceFields(),
};
csvDataSourceItem.UseCsv();

//var financialDataSourceItem = factory.Create(DataSourceType.REST, "OHLC")
// .SetSubtitle("Financial Data Source Item")
// .SetFields(DataSourceFactory.GetOHLCDataSourceFields())
// .As<RestDataSourceItem>()
// .Uri("https://excel2json.io/api/share/8bb2cd78-1b87-4142-00a2-08da188ec9ab")
// .IsAnonymous(true)
// .Build();

var financialDataSourceItem = new RestDataSourceItem("OHLC")
{
Subtitle = "Financial Data Source Item",
Uri = "https://excel2json.io/api/share/8bb2cd78-1b87-4142-00a2-08da188ec9ab",
IsAnonymous = true,
Fields = DataSourceFactory.GetOHLCDataSourceFields(),
};

//var revenueDataSourceItem = factory.Create(DataSourceType.REST, "Revenue")
// .SetSubtitle("Choropleth Data Source Item")
// .SetFields(DataSourceFactory.GetRevenueDataSourceFields())
// .As<RestDataSourceItem>()
// .Uri("https://excel2json.io/api/share/818e7b9a-f463-4565-435d-08da496bf5f2")
// .IsAnonymous(true)
// .Build();

var revenueDataSourceItem = new RestDataSourceItem("Revenue")
{
Subtitle = "Choropleth Data Source Item",
Uri = "https://excel2json.io/api/share/818e7b9a-f463-4565-435d-08da496bf5f2",
IsAnonymous = true,
Fields = DataSourceFactory.GetRevenueDataSourceFields(),
};

var document = new RdashDocument()
{
Expand Down
64 changes: 24 additions & 40 deletions e2e/Sandbox/Factories/RestDataSourceDashboards.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,61 +7,45 @@ 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();
var jsonDataSourceItem = new RestDataSourceItem(new DataSource { Title = "JSON DS", Subtitle = "JSON DS Subtitle" },"Sales by Category")
{
Id = "TESTING",
Subtitle = "JSON Data Source Item",
Uri = "https://excel2json.io/api/share/6e0f06b3-72d3-4fec-7984-08da43f56bb9",
IsAnonymous = true,
Fields = DataSourceFactory.GetSalesByCategoryFields(),
};

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();
var excelDataSourceItem = new RestDataSourceItem(new DataSource { Title = "Excel DS", Subtitle = "Excel DS Subtitle" }, "Marketing")
{
Subtitle = "Excel Data Source Item",
Uri = "http://dl.infragistics.com/reportplus/reveal/samples/Samples.xlsx",
IsAnonymous = true,
Fields = DataSourceFactory.GetMarketingDataSourceFields(),
};
excelDataSourceItem.UseExcel("Marketing");

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();
var csvDataSourceItem = new RestDataSourceItem(new DataSource { Title = "CSV DS", Subtitle = "CSV DS Subtitle" }, "Illinois School Info")
{
Subtitle = "CSV Data Source Item",
Uri = "https://query.data.world/s/y32gtgblzpemyyvtig47dz7tedgkto",
IsAnonymous = true,
Fields = DataSourceFactory.GetCsvDataSourceFields(),
};
csvDataSourceItem.UseCsv();

document.Visualizations.Add(new ScatterMapVisualization("Scatter", csvDataSourceItem)
.SetMap(Maps.NorthAmerica.UnitedStates.States.Illinois)
Expand Down
18 changes: 9 additions & 9 deletions e2e/Sandbox/Factories/SqlServerDataSourceDashboards.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ 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>
var sqlServerDataSourceItem = new MicrosoftSqlServerDataSourceItem("Customers")
{
Subtitle = "SQL Server Data Source Item",
Host = @"Brian-Desktop\SQLEXPRESS",
Database = "Northwind",
Table = "Customers",
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"));

Expand Down
67 changes: 33 additions & 34 deletions e2e/Sandbox/Helpers/DataSourceFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,61 +18,60 @@ internal class DataSourceFactory

internal static DataSourceItem GetMarketingDataSourceItem()
{
var excelDataSourceItem = _factory.Create(DataSourceType.REST, _excelDataSource, "Marketing")
.Subtitle("Excel Data Source Item")
.Fields(GetMarketingDataSourceFields())
.As<IRestDataSourceItemBuilder>()
.Uri(_restExcelUri)
.IsAnonymous(true)
.UseExcel("Marketing")
.Build();
var excelDataSourceItem = new RestDataSourceItem(_excelDataSource, "Marketing")
{
Subtitle = "Excel Data Source Item",
Uri = _restExcelUri,
IsAnonymous = true,
Fields = GetMarketingDataSourceFields(),
};
excelDataSourceItem.UseExcel("Marketing");

return excelDataSourceItem;
}

internal static DataSourceItem GetHealthcareDataSourceItem()
{
var excelDataSourceItem = _factory.Create(DataSourceType.REST, _excelDataSource, "Healthcare")
.Subtitle("Excel Data Source Item")
.Fields(GetHealthcareDataSourceFields())
.As<IRestDataSourceItemBuilder>()
.Uri(_restExcelUri)
.IsAnonymous(true)
.UseExcel("Healthcare")
.Build();
var excelDataSourceItem = new RestDataSourceItem(_excelDataSource, "Healthcare")
{
Subtitle = "Excel Data Source Item",
Uri = _restExcelUri,
IsAnonymous = true,
Fields = GetHealthcareDataSourceFields(),
};
excelDataSourceItem.UseExcel("Healthcare");

return excelDataSourceItem;
}

internal static DataSourceItem GetManufacturingDataSourceItem()
{
var excelDataSourceItem = _factory.Create(DataSourceType.REST, _excelDataSource, "Manufacturing")
.Subtitle("Excel Data Source Item")
.Fields(GetManufacturingDataSourceFields())
.As<IRestDataSourceItemBuilder>()
.Uri(_restExcelUri)
.IsAnonymous(true)
.UseExcel("Manufacturing")
.Build();
var excelDataSourceItem = new RestDataSourceItem(_excelDataSource, "Manufacturing")
{
Subtitle = "Excel Data Source Item",
Uri = _restExcelUri,
IsAnonymous = true,
Fields = GetManufacturingDataSourceFields(),
};
excelDataSourceItem.UseExcel("Manufacturing");

return excelDataSourceItem;
}

internal static DataSourceItem GetSalesDataSourceItem()
{
var excelDataSourceItem = _factory.Create(DataSourceType.REST, _excelDataSource, "Sales")
.Subtitle("Excel Data Source Item")
.Fields(GetSalesDataSourceFields())
.As<IRestDataSourceItemBuilder>()
.Uri(_restExcelUri)
.IsAnonymous(true)
.UseExcel("Sales")
.Build();
var excelDataSourceItem = new RestDataSourceItem(_excelDataSource, "Sales")
{
Subtitle = "Excel Data Source Item",
Uri = _restExcelUri,
IsAnonymous = true,
Fields = GetSalesDataSourceFields(),
};

return excelDataSourceItem;
}

internal static IEnumerable<IField> GetRevenueDataSourceFields()
internal static List<IField> GetRevenueDataSourceFields()
{
return new List<IField>()
{
Expand Down Expand Up @@ -198,7 +197,7 @@ internal static List<IField> GetCsvDataSourceFields()
};
}

internal static IEnumerable<IField> GetOHLCDataSourceFields()
internal static List<IField> GetOHLCDataSourceFields()
{
return new List<IField>
{
Expand Down
4 changes: 2 additions & 2 deletions e2e/Sandbox/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ private async void Create_Dashboard(object sender, RoutedEventArgs e)
//var document = CampaignsDashboard.CreateDashboard();
//var document = HealthcareDashboard.CreateDashboard();
//var document = ManufacturingDashboard.CreateDashboard();
var document = CustomDashboard.CreateDashboard();
//var document = RestDataSourceDashboards.CreateDashboard();
//var document = CustomDashboard.CreateDashboard();
var document = RestDataSourceDashboards.CreateDashboard();
//var document = SqlServerDataSourceDashboards.CreateDashboard();
//var document = DashboardLinkingDashboard.CreateDashboard();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class RdashDocumentValidatorFixture
[Fact]
public void DataSources_AddedToRdashDocument()
{
var dataSourceItem = new DataSourceItemFactory().Create(DataSourceType.REST, "").Fields(new List<IField>() { null }).Build();
var dataSourceItem = new DataSourceItemFactory().Create(DataSourceType.REST, "").SetFields(new List<IField>() { null });

var document = new RdashDocument();
document.Visualizations.Add(new KpiTimeVisualization(dataSourceItem));
Expand All @@ -27,7 +27,7 @@ public void DataSources_AddedToRdashDocument()
[Fact]
public void DataSources_FromVisualizationsAreNotDuplicated()
{
var dataSourceItem = new DataSourceItemFactory().Create(DataSourceType.REST, "").Fields(new List<IField>() { null }).Build();
var dataSourceItem = new DataSourceItemFactory().Create(DataSourceType.REST, "").SetFields(new List<IField>() { null });

var document = new RdashDocument();
document.Visualizations.Add(new KpiTimeVisualization(dataSourceItem));
Expand All @@ -47,7 +47,7 @@ public void DataSources_FromVisualizationsAreNotDuplicated()
[Fact]
public void DataSources_FromVisualizations_AndDataSources_AreNotDuplicated()
{
var dataSourceItem = new DataSourceItemFactory().Create(DataSourceType.REST, "").Fields(new List<IField>() { null }).Build();
var dataSourceItem = new DataSourceItemFactory().Create(DataSourceType.REST, "").SetFields(new List<IField>() { null });
var dataSource = dataSourceItem.DataSource;

var document = new RdashDocument();
Expand Down
Loading
Loading