Aggiunta gestione chart dispose + fix commenti
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
@inject IJSRuntime JSRuntime
|
||||
@implements IDisposable
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
@@ -26,8 +27,6 @@
|
||||
bgColors = pieLabels.Select(l => PieColor.ContainsKey(l) ? PieColor[l] : "rgba(0,0,0,0.3)").ToList();
|
||||
bordColors = bgColors.Select(c => c.Replace("0.3", "1")).ToList();
|
||||
|
||||
// await JSRuntime.InvokeVoidAsync("chartsInterop.createPieChart", CanvasId, pieLabels, values, bgColors);
|
||||
|
||||
await JSRuntime.InvokeVoidAsync("chartsInterop.createPieChart", CanvasId, new
|
||||
{
|
||||
type = "pie",
|
||||
@@ -47,12 +46,17 @@
|
||||
},
|
||||
options = new
|
||||
{
|
||||
responsive = true
|
||||
responsive = true,
|
||||
animation = false
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Chiama il metodo JS per pulire il dizionario
|
||||
_ = JSRuntime.InvokeVoidAsync("chartsInterop.destroyChart", CanvasId);
|
||||
}
|
||||
private List<string> pieLabels = new();
|
||||
private List<double> pieValues = new();
|
||||
private List<string> bgColors = new();
|
||||
@@ -91,7 +95,8 @@
|
||||
},
|
||||
options = new
|
||||
{
|
||||
responsive = true
|
||||
responsive = true,
|
||||
animation = false
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -76,22 +76,6 @@
|
||||
}
|
||||
},
|
||||
|
||||
//createPieChart: function (canvasId, labels, values, bgColors) {
|
||||
// const ctx = document.getElementById(canvasId);
|
||||
// new Chart(ctx, {
|
||||
// type: "pie",
|
||||
// data: {
|
||||
// labels: labels,
|
||||
// datasets: [{
|
||||
// data: values,
|
||||
// backgroundColor: bgColors,
|
||||
// borderColor: bgColors.map(c => c.replace("0.6", "1")),
|
||||
// borderWidth: 2
|
||||
// }]
|
||||
// },
|
||||
// options: { responsive: true }
|
||||
// });
|
||||
//},
|
||||
|
||||
createBarChart: function (canvasId, labels, datasets) {
|
||||
const ctx = document.getElementById(canvasId);
|
||||
|
||||
Reference in New Issue
Block a user