diff --git a/samples/TestApplication/Pages/Index - Copy.cshtml b/samples/TestApplication/Pages/Index - Copy.cshtml
new file mode 100644
index 0000000..a12b070
--- /dev/null
+++ b/samples/TestApplication/Pages/Index - Copy.cshtml
@@ -0,0 +1,81 @@
+@page "/backup"
+@using BlazorComponents.Shared
+
+
+
Chart JS charts using Blazor
+
+
+
+
+
+
+
+@functions {
+
+ public ChartJSBarChart blazorBarChartJS { get; set; } = new ChartJSBarChart();
+ ChartJsBarChart barChartJs;
+
+ protected override void OnInit()
+ {
+ blazorBarChartJS = new ChartJSBarChart()
+ {
+ ChartType = "bar",
+ CanvasId = "myFirstBarChart",
+ Options = new ChartJsOptions()
+ {
+ Text = "Sample chart from Blazor",
+ BorderWidth = 1,
+ Display = true
+ },
+ Data = new ChartJsBarData()
+ {
+ Labels = new List() { "Red", "Blue", "Yellow", "Green", "Purple", "Orange" },
+ Datasets = new List()
+ {
+ new ChartJsBarDataset()
+ {
+ Label = "# of Votes from blazor",
+ BackgroundColor = "#cc65fe",
+ BorderColor = "#cc65fe",
+ PointHoverRadius = 2,
+ Data = new List(){ 19.187,12.2253,5.5,3,3,2}
+ },
+ new ChartJsBarDataset()
+ {
+ Label = "# of Likes from blazor",
+ BackgroundColor = "#36a2eb",
+ BorderColor = "#36a2eb",
+ PointHoverRadius = 2,
+ Data = new List(){ 30,10,15,13,13,12}.Select(i=> i).ToList()
+ }
+ }
+ }
+ };
+ }
+
+ public async Task UpdateChart()
+ {
+ //Update existing dataset
+ blazorBarChartJS.Data.Labels.Add($"New{DateTime.Now.Second}");
+ var firstDataSet = blazorBarChartJS.Data.Datasets[0];
+ firstDataSet.Data.Add(DateTime.Now.Second);
+ StateHasChanged();
+ //Add new dataset
+ //blazorLineChartJS.Data.Datasets.Add(new ChartJsLineDataset()
+ //{
+ // BackgroundColor = "#cc65fe",
+ // BorderColor = "#cc65fe",
+ // Label = "# of Votes from blazor 1",
+ // Data = new List {20,21,12,3,4,4},
+ // Fill = true,
+ // BorderWidth = 2,
+ // PointRadius = 3,
+ // PointBorderWidth = 1
+ //});
+
+ //var done = await barChartJs.UpdateChart(blazorBarChartJS);
+ //StateHasChanged();
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/samples/TestApplication/Pages/Index.cshtml b/samples/TestApplication/Pages/Index.cshtml
index 75fa8c8..9ee0a59 100644
--- a/samples/TestApplication/Pages/Index.cshtml
+++ b/samples/TestApplication/Pages/Index.cshtml
@@ -17,6 +17,7 @@
protected override void OnInit()
{
+
blazorBarChartJS = new ChartJSBarChart()
{
ChartType = "bar",
@@ -37,27 +38,29 @@
Label = "# of Votes from blazor",
BackgroundColor = "#cc65fe",
BorderColor = "#cc65fe",
- Data = new List(){ 19,12,5,3,3,2}
+ PointHoverRadius = 2,
+ Data = new List(){ 19.187,12.2253,5.5,3,3,2}
},
new ChartJsBarDataset()
{
Label = "# of Likes from blazor",
BackgroundColor = "#36a2eb",
BorderColor = "#36a2eb",
- Data = new List(){ 30,10,15,13,13,12}
+ PointHoverRadius = 2,
+ Data = new List(){ 30,10,15,13,13,12}.Select(i=> i).ToList()
}
}
}
};
}
- public void UpdateChart()
+ public async Task UpdateChart()
{
//Update existing dataset
blazorBarChartJS.Data.Labels.Add($"New{DateTime.Now.Second}");
var firstDataSet = blazorBarChartJS.Data.Datasets[0];
firstDataSet.Data.Add(DateTime.Now.Second);
-
+ //var done = await barChartJs.UpdateChart();
//Add new dataset
//blazorLineChartJS.Data.Datasets.Add(new ChartJsLineDataset()
//{
@@ -71,6 +74,9 @@
// PointBorderWidth = 1
//});
- barChartJs.UpdateChart(blazorBarChartJS);
+ //var done = await barChartJs.UpdateChart(blazorBarChartJS);
+ //StateHasChanged();
+
+ return true;
}
}
\ No newline at end of file
diff --git a/samples/TestApplication/Pages/LineChart.cshtml b/samples/TestApplication/Pages/LineChart.cshtml
index 2c77487..4cc92ee 100644
--- a/samples/TestApplication/Pages/LineChart.cshtml
+++ b/samples/TestApplication/Pages/LineChart.cshtml
@@ -36,7 +36,7 @@
BackgroundColor = "#ff6384",
BorderColor = "#ff6384",
Label = "# of Votes from blazor",
- Data = new List{ 19,12,5,3,3,2},
+ Data = new List{ 19,12,5,3,3,2}.Select(i=> i).ToList(),
Fill = false,
BorderWidth = 2,
PointRadius = 3,
@@ -68,5 +68,6 @@
//});
lineChartJs.UpdateChart(blazorLineChartJS);
+ StateHasChanged();
}
}
\ No newline at end of file
diff --git a/samples/TestApplication/Pages/MutipleCharts.cshtml b/samples/TestApplication/Pages/MutipleCharts.cshtml
new file mode 100644
index 0000000..87ec57e
--- /dev/null
+++ b/samples/TestApplication/Pages/MutipleCharts.cshtml
@@ -0,0 +1,112 @@
+@page "/multiple"
+@using BlazorComponents.Shared
+
+
+
Chart JS Bar Chart Using Blazor
+
+
+
+
+
+
Chart JS Line Chart Using Blazor
+
+
+
+
+
+
+
+@functions {
+
+ public ChartJSBarChart blazorBarChartJS { get; set; } = new ChartJSBarChart();
+ ChartJsBarChart barChartJs;
+ public ChartJSLineChart blazorLineChartJS { get; set; } = new ChartJSLineChart();
+ ChartJsLineChart lineChartJs;
+
+ protected override void OnInit()
+ {
+
+ blazorBarChartJS = new ChartJSBarChart()
+ {
+ ChartType = "bar",
+ CanvasId = "myFirstBarChart",
+ Options = new ChartJsOptions()
+ {
+ Text = "Sample chart from Blazor",
+ BorderWidth = 1,
+ Display = true
+ },
+ Data = new ChartJsBarData()
+ {
+ Labels = new List() { "Red", "Blue", "Yellow", "Green", "Purple", "Orange" },
+ Datasets = new List()
+ {
+ new ChartJsBarDataset()
+ {
+ Label = "# of Votes from blazor",
+ BackgroundColor = "#cc65fe",
+ BorderColor = "#cc65fe",
+ PointHoverRadius = 2,
+ Data = new List(){ 19.187,12.2253,5.5,3,3,2}
+ },
+ new ChartJsBarDataset()
+ {
+ Label = "# of Likes from blazor",
+ BackgroundColor = "#36a2eb",
+ BorderColor = "#36a2eb",
+ PointHoverRadius = 2,
+ Data = new List(){ 30,10,15,13,13,12}.Select(i=> i).ToList()
+ }
+ }
+ }
+ };
+
+ blazorLineChartJS = new ChartJSLineChart()
+ {
+ ChartType = "line",
+ CanvasId = "myFirstLineChart",
+ Options = new ChartJsOptions()
+ {
+ Text = "Sample chart from Blazor",
+ Display = true,
+ Responsive = false
+ },
+ Data = new ChartJsLineData()
+ {
+ Labels = new List() { "Red", "Blue", "Yellow", "Green", "Purple", "Orange" },
+ Datasets = new List()
+ {
+ new ChartJsLineDataset()
+ {
+ BackgroundColor = "#ff6384",
+ BorderColor = "#ff6384",
+ Label = "# of Votes from blazor",
+ Data = new List{ 19,12,5,3,3,2}.Select(i=> i).ToList(),
+ Fill = false,
+ BorderWidth = 2,
+ PointRadius = 3,
+ PointBorderWidth=1
+ }
+ }
+ }
+ };
+ }
+
+ public async Task UpdateBarChart()
+ {
+ //Update existing dataset
+ blazorBarChartJS.Data.Labels.Add($"New{DateTime.Now.Second}");
+ var firstDataSet = blazorBarChartJS.Data.Datasets[0];
+ firstDataSet.Data.Add(DateTime.Now.Second);
+
+ return true;
+ }
+
+ public void UpdateLineChart()
+ {
+ //Update existing dataset
+ blazorLineChartJS.Data.Labels.Add($"New{DateTime.Now.Second}");
+ var firstDataSet = blazorLineChartJS.Data.Datasets[0];
+ firstDataSet.Data.Add(DateTime.Now.Second);
+ }
+}
\ No newline at end of file
diff --git a/samples/TestApplication/Pages/RadarChart.cshtml b/samples/TestApplication/Pages/RadarChart.cshtml
index d6c40fc..0a2428e 100644
--- a/samples/TestApplication/Pages/RadarChart.cshtml
+++ b/samples/TestApplication/Pages/RadarChart.cshtml
@@ -34,7 +34,7 @@
{
BackgroundColor = "#ff6384",
Label = "1st Dataset",
- Data = new List{ 19,12,5,3,3,2},
+ Data = new List{19.195,12.75,5.25,3,3,2},
BorderWidth = 2,
RadarChartPointStyle = RadarChartPointStyles.star,
PointBackgroundColor = "#a4cef0",
@@ -60,7 +60,7 @@
BackgroundColor = "#cc65fe",
BorderColor = "#cc65fe",
Label = "2nd Dataset",
- Data = new List { 20, 21, 12, 3, 4, 4 },
+ Data = new List { 20, 21, 12, 3, 4, 4 }.Select(i => i).ToList(),
BorderWidth = 2,
PointRadius = 3,
PointBorderWidth = 1
diff --git a/samples/TestApplication/Shared/NavMenu.cshtml b/samples/TestApplication/Shared/NavMenu.cshtml
index 52bc711..b43f162 100644
--- a/samples/TestApplication/Shared/NavMenu.cshtml
+++ b/samples/TestApplication/Shared/NavMenu.cshtml
@@ -22,6 +22,11 @@
Radar Chart
+
+
+ Mutiple Chart
+
+
diff --git a/samples/TestApplication/TestApplication.csproj b/samples/TestApplication/TestApplication.csproj
index 8ec5402..4191af4 100644
--- a/samples/TestApplication/TestApplication.csproj
+++ b/samples/TestApplication/TestApplication.csproj
@@ -17,4 +17,10 @@
+
+
+ $(IncludeRazorContentInPack)
+
+
+
diff --git a/samples/TestApplication/wwwroot/index.html b/samples/TestApplication/wwwroot/index.html
index bbee708..b033b98 100644
--- a/samples/TestApplication/wwwroot/index.html
+++ b/samples/TestApplication/wwwroot/index.html
@@ -17,6 +17,6 @@
-
+