Question: Is there a toolbar for SfChart?
I want to create a simplistic dashboard where you can add or remove charts. This gives a nice prototype for dragging and dropping but there doesn't appear to be any option for a toolbar or manu item specific for these charts?
Could somebody confirm this or maybe I'm missing something :-)
Thanks
Scott
Scott,
Greetings from Syncfusion.
You can achieve your requirement by dynamically adding and removing panels in the Syncfusion Blazor Dashboard Layout using the AddPanelAsync and RemovePanelAsync methods. These methods allow you to add new panels and remove existing ones by specifying the panel ID.
Please check the sample below, where we have implemented adding and removing panels through button clicks.
<SfButton CssClass="e-primary" Content="Add Panel" @onclick="AddClick"></SfButton> <SfButton CssClass="e-primary" Content="Remove Panel" @onclick="RemoveClick"></SfButton> public async Task RemoveClick() { if (this.Count > 0) { string panelId = this.Count.ToString() + "_layout"; await dashboardObject.RemovePanelAsync(panelId); this.Count--; } } public async Task AddClick() { this.Count = this.Count + 1; string HeaderText = "Panel " + this.Count.ToString(); PanelModel panel = new PanelModel { Id = this.Count.ToString() + "_layout", SizeX = 2, SizeY = 2, Row = 0, Column = 0, Enabled = true, Header = @<div>@HeaderText</div>, Content =@<SfChart> <ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category"> </ChartPrimaryXAxis> <ChartSeriesCollection> <ChartSeries DataSource="@Sales" XName="Month" YName="SalesValue" Type="Syncfusion.Blazor.Charts.ChartSeriesType.Column"> </ChartSeries> </ChartSeriesCollection> </SfChart> }; await dashboardObject.AddPanelAsync(panel); }
Sample : https://blazorplayground.syncfusion.com/hZBoXLCABAbuIINa
UG : https://blazor.syncfusion.com/documentation/dashboard-layout/getting-started#panels-with-components
The reported query appears to be addressed in the latest update. Could you please confirm if everything works as expected? Closing for now, but feel free to reopen if needed.