diff --git a/samples/TestApplication/Pages/Index.cshtml b/samples/TestApplication/Pages/Index.cshtml index 3fb5512..75fa8c8 100644 --- a/samples/TestApplication/Pages/Index.cshtml +++ b/samples/TestApplication/Pages/Index.cshtml @@ -12,12 +12,12 @@ @functions { - public ChartJSChart blazorBarChartJS { get; set; } = new ChartJSChart(); + public ChartJSBarChart blazorBarChartJS { get; set; } = new ChartJSBarChart(); ChartJsBarChart barChartJs; protected override void OnInit() { - blazorBarChartJS = new ChartJSChart() + blazorBarChartJS = new ChartJSBarChart() { ChartType = "bar", CanvasId = "myFirstBarChart", @@ -27,7 +27,7 @@ BorderWidth = 1, Display = true }, - Data = new ChartJsData() + Data = new ChartJsBarData() { Labels = new List() { "Red", "Blue", "Yellow", "Green", "Purple", "Orange" }, Datasets = new List() diff --git a/samples/TestApplication/Pages/LineChart.cshtml b/samples/TestApplication/Pages/LineChart.cshtml index 74e723e..2c77487 100644 --- a/samples/TestApplication/Pages/LineChart.cshtml +++ b/samples/TestApplication/Pages/LineChart.cshtml @@ -10,13 +10,13 @@ @functions{ - public ChartJSChart blazorLineChartJS { get; set; } = new ChartJSChart(); + public ChartJSLineChart blazorLineChartJS { get; set; } = new ChartJSLineChart(); ChartJsLineChart lineChartJs; protected override void OnInit() { - blazorLineChartJS = new ChartJSChart() + blazorLineChartJS = new ChartJSLineChart() { ChartType = "line", CanvasId = "myFirstLineChart", @@ -26,7 +26,7 @@ Display = true, Responsive = false }, - Data = new ChartJsData() + Data = new ChartJsLineData() { Labels = new List() { "Red", "Blue", "Yellow", "Green", "Purple", "Orange" }, Datasets = new List() diff --git a/samples/TestApplication/Pages/RadarChart.cshtml b/samples/TestApplication/Pages/RadarChart.cshtml index 338c4b0..d6c40fc 100644 --- a/samples/TestApplication/Pages/RadarChart.cshtml +++ b/samples/TestApplication/Pages/RadarChart.cshtml @@ -10,13 +10,13 @@ @functions { - public ChartJSChart blazorRadarChartJS { get; set; } = new ChartJSChart(); + public ChartJSRadarChart blazorRadarChartJS { get; set; } = new ChartJSRadarChart(); ChartJsRadarChart radarChartJs; protected override void OnInit() { - blazorRadarChartJS = new ChartJSChart() + blazorRadarChartJS = new ChartJSRadarChart() { ChartType = "line", CanvasId = "myFirstRadarChart", @@ -25,7 +25,7 @@ Text = "Sample chart from Blazor", Display = true }, - Data = new ChartJsData() + Data = new ChartJsRadarData() { Labels = new List() { "Eating", "Drinking", "Social", "Coding", "Cycling", "Running" }, Datasets = new List() diff --git a/src/BlazorComponents/ChartJS/ChartJSBarChart.cs b/src/BlazorComponents/ChartJS/ChartJSBarChart.cs new file mode 100644 index 0000000..435344e --- /dev/null +++ b/src/BlazorComponents/ChartJS/ChartJSBarChart.cs @@ -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()}"; + } +} diff --git a/src/BlazorComponents/ChartJS/ChartJSInterop.cs b/src/BlazorComponents/ChartJS/ChartJSInterop.cs index 120e5a8..6cf30fc 100644 --- a/src/BlazorComponents/ChartJS/ChartJSInterop.cs +++ b/src/BlazorComponents/ChartJS/ChartJSInterop.cs @@ -5,32 +5,32 @@ namespace BlazorComponents.ChartJS { public class ChartJSInterop { - public static Task InitializeLineChart(ChartJSChart lineChart) + public static Task InitializeLineChart(ChartJSLineChart lineChart) { return JSRuntime.Current.InvokeAsync("BlazorComponents.ChartJSInterop.InitializeLineChart", new[] { lineChart }); } - public static Task InitializeBarChart(ChartJSChart barChart) + public static Task InitializeBarChart(ChartJSBarChart barChart) { return JSRuntime.Current.InvokeAsync("BlazorComponents.ChartJSInterop.InitializeBarChart", new[] { barChart }); } - public static Task UpdateLineChart(ChartJSChart lineChart) + public static Task UpdateLineChart(ChartJSLineChart lineChart) { return JSRuntime.Current.InvokeAsync("BlazorComponents.ChartJSInterop.UpdateLineChart", new[] { lineChart }); } - public static Task UpdateBarChart(ChartJSChart barChart) + public static Task UpdateBarChart(ChartJSBarChart barChart) { return JSRuntime.Current.InvokeAsync("BlazorComponents.ChartJSInterop.UpdateBarChart", new[] { barChart }); } - public static Task InitializeRadarChart(ChartJSChart radarChart) + public static Task InitializeRadarChart(ChartJSRadarChart radarChart) { return JSRuntime.Current.InvokeAsync("BlazorComponents.ChartJSInterop.InitializeRadarChart", new[] { radarChart }); } - public static Task UpdateRadarChart(ChartJSChart radarChart) + public static Task UpdateRadarChart(ChartJSRadarChart radarChart) { return JSRuntime.Current.InvokeAsync("BlazorComponents.ChartJSInterop.UpdateRadarChart", new[] { radarChart }); } diff --git a/src/BlazorComponents/ChartJS/ChartJSLineChart.cs b/src/BlazorComponents/ChartJS/ChartJSLineChart.cs new file mode 100644 index 0000000..5edb037 --- /dev/null +++ b/src/BlazorComponents/ChartJS/ChartJSLineChart.cs @@ -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()}"; + } +} diff --git a/src/BlazorComponents/ChartJS/ChartJSRadarChart.cs b/src/BlazorComponents/ChartJS/ChartJSRadarChart.cs new file mode 100644 index 0000000..fa281d1 --- /dev/null +++ b/src/BlazorComponents/ChartJS/ChartJSRadarChart.cs @@ -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()}"; + } +} diff --git a/src/BlazorComponents/ChartJS/ChartJsBarData.cs b/src/BlazorComponents/ChartJS/ChartJsBarData.cs new file mode 100644 index 0000000..bfa1c1f --- /dev/null +++ b/src/BlazorComponents/ChartJS/ChartJsBarData.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace BlazorComponents.ChartJS +{ + public class ChartJsBarData + { + public List Labels { get; set; } = new List(); + public List Datasets { get; set; } + } +} diff --git a/src/BlazorComponents/ChartJS/ChartJsLineData.cs b/src/BlazorComponents/ChartJS/ChartJsLineData.cs new file mode 100644 index 0000000..85cad08 --- /dev/null +++ b/src/BlazorComponents/ChartJS/ChartJsLineData.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace BlazorComponents.ChartJS +{ + public class ChartJsLineData + { + public List Labels { get; set; } = new List(); + public List Datasets { get; set; } + } +} diff --git a/src/BlazorComponents/ChartJS/ChartJsRadarData.cs b/src/BlazorComponents/ChartJS/ChartJsRadarData.cs new file mode 100644 index 0000000..783fb8c --- /dev/null +++ b/src/BlazorComponents/ChartJS/ChartJsRadarData.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace BlazorComponents.ChartJS +{ + public class ChartJsRadarData + { + public List Labels { get; set; } = new List(); + public List Datasets { get; set; } + } +} diff --git a/src/BlazorComponents/Shared/ChartJsBarChart.cshtml b/src/BlazorComponents/Shared/ChartJsBarChart.cshtml index 9feb396..6692f01 100644 --- a/src/BlazorComponents/Shared/ChartJsBarChart.cshtml +++ b/src/BlazorComponents/Shared/ChartJsBarChart.cshtml @@ -9,7 +9,7 @@ @functions { [Parameter] - ChartJSChart Chart { get; set; } + ChartJSBarChart Chart { get; set; } [Parameter] int Width { get; set; } = 400; [Parameter] @@ -20,7 +20,7 @@ ChartJSInterop.InitializeBarChart(Chart); } - public void UpdateChart(ChartJSChart updatedChart) + public void UpdateChart(ChartJSBarChart updatedChart) { ChartJSInterop.UpdateBarChart(updatedChart); } diff --git a/src/BlazorComponents/Shared/ChartJsLineChart.cshtml b/src/BlazorComponents/Shared/ChartJsLineChart.cshtml index 107acf0..33f8484 100644 --- a/src/BlazorComponents/Shared/ChartJsLineChart.cshtml +++ b/src/BlazorComponents/Shared/ChartJsLineChart.cshtml @@ -10,7 +10,7 @@ @functions { [Parameter] - ChartJSChart Chart { get; set; } + ChartJSLineChart Chart { get; set; } [Parameter] int Width { get; set; } = 200; [Parameter] @@ -27,7 +27,7 @@ ChartJSInterop.InitializeLineChart(Chart); } - public void UpdateChart(ChartJSChart updatedChart) + public void UpdateChart(ChartJSLineChart updatedChart) { ChartJSInterop.UpdateLineChart(updatedChart); } diff --git a/src/BlazorComponents/Shared/ChartJsRadarChart.cshtml b/src/BlazorComponents/Shared/ChartJsRadarChart.cshtml index a95fd39..f875cd2 100644 --- a/src/BlazorComponents/Shared/ChartJsRadarChart.cshtml +++ b/src/BlazorComponents/Shared/ChartJsRadarChart.cshtml @@ -10,7 +10,7 @@ @functions { [Parameter] - ChartJSChart Chart { get; set; } + ChartJSRadarChart Chart { get; set; } [Parameter] int Width { get; set; } = 200; [Parameter] @@ -23,7 +23,7 @@ ChartJSInterop.InitializeRadarChart(Chart); } - public void UpdateChart(ChartJSChart updatedChart) + public void UpdateChart(ChartJSRadarChart updatedChart) { ChartJSInterop.UpdateRadarChart(updatedChart); }