Skip to content

Commit

Permalink
removed generic classes...
Browse files Browse the repository at this point in the history
  • Loading branch information
muqeet-khan committed Oct 8, 2018
1 parent 990e0bb commit 232a8d0
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 21 deletions.
6 changes: 3 additions & 3 deletions samples/TestApplication/Pages/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

@functions {

public ChartJSChart<ChartJsBarDataset> blazorBarChartJS { get; set; } = new ChartJSChart<ChartJsBarDataset>();
public ChartJSBarChart blazorBarChartJS { get; set; } = new ChartJSBarChart();
ChartJsBarChart barChartJs;

protected override void OnInit()
{
blazorBarChartJS = new ChartJSChart<ChartJsBarDataset>()
blazorBarChartJS = new ChartJSBarChart()
{
ChartType = "bar",
CanvasId = "myFirstBarChart",
Expand All @@ -27,7 +27,7 @@
BorderWidth = 1,
Display = true
},
Data = new ChartJsData<ChartJsBarDataset>()
Data = new ChartJsBarData()
{
Labels = new List<string>() { "Red", "Blue", "Yellow", "Green", "Purple", "Orange" },
Datasets = new List<ChartJsBarDataset>()
Expand Down
6 changes: 3 additions & 3 deletions samples/TestApplication/Pages/LineChart.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

@functions{

public ChartJSChart<ChartJsLineDataset> blazorLineChartJS { get; set; } = new ChartJSChart<ChartJsLineDataset>();
public ChartJSLineChart blazorLineChartJS { get; set; } = new ChartJSLineChart();
ChartJsLineChart lineChartJs;

protected override void OnInit()
{

blazorLineChartJS = new ChartJSChart<ChartJsLineDataset>()
blazorLineChartJS = new ChartJSLineChart()
{
ChartType = "line",
CanvasId = "myFirstLineChart",
Expand All @@ -26,7 +26,7 @@
Display = true,
Responsive = false
},
Data = new ChartJsData<ChartJsLineDataset>()
Data = new ChartJsLineData()
{
Labels = new List<string>() { "Red", "Blue", "Yellow", "Green", "Purple", "Orange" },
Datasets = new List<ChartJsLineDataset>()
Expand Down
6 changes: 3 additions & 3 deletions samples/TestApplication/Pages/RadarChart.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

@functions {

public ChartJSChart<ChartJSRadarDataset> blazorRadarChartJS { get; set; } = new ChartJSChart<ChartJSRadarDataset>();
public ChartJSRadarChart blazorRadarChartJS { get; set; } = new ChartJSRadarChart();
ChartJsRadarChart radarChartJs;

protected override void OnInit()
{

blazorRadarChartJS = new ChartJSChart<ChartJSRadarDataset>()
blazorRadarChartJS = new ChartJSRadarChart()
{
ChartType = "line",
CanvasId = "myFirstRadarChart",
Expand All @@ -25,7 +25,7 @@
Text = "Sample chart from Blazor",
Display = true
},
Data = new ChartJsData<ChartJSRadarDataset>()
Data = new ChartJsRadarData()
{
Labels = new List<string>() { "Eating", "Drinking", "Social", "Coding", "Cycling", "Running" },
Datasets = new List<ChartJSRadarDataset>()
Expand Down
12 changes: 12 additions & 0 deletions src/BlazorComponents/ChartJS/ChartJSBarChart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace BlazorComponents.ChartJS
{
public class ChartJSBarChart
{
public string ChartType { get; set; } = "bar";
public ChartJsBarData Data { get; set; }
public ChartJsOptions Options { get; set; }
public string CanvasId { get; set; } = $"BlazorChartJS_{new Random().Next(0, 1000000).ToString()}";
}
}
12 changes: 6 additions & 6 deletions src/BlazorComponents/ChartJS/ChartJSInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@ namespace BlazorComponents.ChartJS
{
public class ChartJSInterop
{
public static Task<bool> InitializeLineChart(ChartJSChart<ChartJsLineDataset> lineChart)
public static Task<bool> InitializeLineChart(ChartJSLineChart lineChart)
{
return JSRuntime.Current.InvokeAsync<bool>("BlazorComponents.ChartJSInterop.InitializeLineChart", new[] { lineChart });
}

public static Task<bool> InitializeBarChart(ChartJSChart<ChartJsBarDataset> barChart)
public static Task<bool> InitializeBarChart(ChartJSBarChart barChart)
{
return JSRuntime.Current.InvokeAsync<bool>("BlazorComponents.ChartJSInterop.InitializeBarChart", new[] { barChart });
}

public static Task<bool> UpdateLineChart(ChartJSChart<ChartJsLineDataset> lineChart)
public static Task<bool> UpdateLineChart(ChartJSLineChart lineChart)
{
return JSRuntime.Current.InvokeAsync<bool>("BlazorComponents.ChartJSInterop.UpdateLineChart", new[] { lineChart });
}

public static Task<bool> UpdateBarChart(ChartJSChart<ChartJsBarDataset> barChart)
public static Task<bool> UpdateBarChart(ChartJSBarChart barChart)
{
return JSRuntime.Current.InvokeAsync<bool>("BlazorComponents.ChartJSInterop.UpdateBarChart", new[] { barChart });
}

public static Task<bool> InitializeRadarChart(ChartJSChart<ChartJSRadarDataset> radarChart)
public static Task<bool> InitializeRadarChart(ChartJSRadarChart radarChart)
{
return JSRuntime.Current.InvokeAsync<bool>("BlazorComponents.ChartJSInterop.InitializeRadarChart", new[] { radarChart });
}

public static Task<bool> UpdateRadarChart(ChartJSChart<ChartJSRadarDataset> radarChart)
public static Task<bool> UpdateRadarChart(ChartJSRadarChart radarChart)
{
return JSRuntime.Current.InvokeAsync<bool>("BlazorComponents.ChartJSInterop.UpdateRadarChart", new[] { radarChart });
}
Expand Down
12 changes: 12 additions & 0 deletions src/BlazorComponents/ChartJS/ChartJSLineChart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace BlazorComponents.ChartJS
{
public class ChartJSLineChart
{
public string ChartType { get; set; } = "bar";
public ChartJsLineData Data { get; set; }
public ChartJsOptions Options { get; set; }
public string CanvasId { get; set; } = $"BlazorChartJS_{new Random().Next(0, 1000000).ToString()}";
}
}
12 changes: 12 additions & 0 deletions src/BlazorComponents/ChartJS/ChartJSRadarChart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace BlazorComponents.ChartJS
{
public class ChartJSRadarChart
{
public string ChartType { get; set; } = "bar";
public ChartJsRadarData Data { get; set; }
public ChartJsOptions Options { get; set; }
public string CanvasId { get; set; } = $"BlazorChartJS_{new Random().Next(0, 1000000).ToString()}";
}
}
10 changes: 10 additions & 0 deletions src/BlazorComponents/ChartJS/ChartJsBarData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;

namespace BlazorComponents.ChartJS
{
public class ChartJsBarData
{
public List<string> Labels { get; set; } = new List<string>();
public List<ChartJsBarDataset> Datasets { get; set; }
}
}
10 changes: 10 additions & 0 deletions src/BlazorComponents/ChartJS/ChartJsLineData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;

namespace BlazorComponents.ChartJS
{
public class ChartJsLineData
{
public List<string> Labels { get; set; } = new List<string>();
public List<ChartJsLineDataset> Datasets { get; set; }
}
}
10 changes: 10 additions & 0 deletions src/BlazorComponents/ChartJS/ChartJsRadarData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;

namespace BlazorComponents.ChartJS
{
public class ChartJsRadarData
{
public List<string> Labels { get; set; } = new List<string>();
public List<ChartJSRadarDataset> Datasets { get; set; }
}
}
4 changes: 2 additions & 2 deletions src/BlazorComponents/Shared/ChartJsBarChart.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@functions {
[Parameter]
ChartJSChart<ChartJsBarDataset> Chart { get; set; }
ChartJSBarChart Chart { get; set; }
[Parameter]
int Width { get; set; } = 400;
[Parameter]
Expand All @@ -20,7 +20,7 @@
ChartJSInterop.InitializeBarChart(Chart);
}

public void UpdateChart(ChartJSChart<ChartJsBarDataset> updatedChart)
public void UpdateChart(ChartJSBarChart updatedChart)
{
ChartJSInterop.UpdateBarChart(updatedChart);
}
Expand Down
4 changes: 2 additions & 2 deletions src/BlazorComponents/Shared/ChartJsLineChart.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@functions {

[Parameter]
ChartJSChart<ChartJsLineDataset> Chart { get; set; }
ChartJSLineChart Chart { get; set; }
[Parameter]
int Width { get; set; } = 200;
[Parameter]
Expand All @@ -27,7 +27,7 @@
ChartJSInterop.InitializeLineChart(Chart);
}

public void UpdateChart(ChartJSChart<ChartJsLineDataset> updatedChart)
public void UpdateChart(ChartJSLineChart updatedChart)
{
ChartJSInterop.UpdateLineChart(updatedChart);
}
Expand Down
4 changes: 2 additions & 2 deletions src/BlazorComponents/Shared/ChartJsRadarChart.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@functions {

[Parameter]
ChartJSChart<ChartJSRadarDataset> Chart { get; set; }
ChartJSRadarChart Chart { get; set; }
[Parameter]
int Width { get; set; } = 200;
[Parameter]
Expand All @@ -23,7 +23,7 @@
ChartJSInterop.InitializeRadarChart(Chart);
}

public void UpdateChart(ChartJSChart<ChartJSRadarDataset> updatedChart)
public void UpdateChart(ChartJSRadarChart updatedChart)
{
ChartJSInterop.UpdateRadarChart(updatedChart);
}
Expand Down

0 comments on commit 232a8d0

Please sign in to comment.