How to display total stacked column value in tooltip in Blazor Charts?
This article explains how to display total stacked column value in tooltip in Blazor Charts.
Display Total Stacked Column Value in Tooltip
Blazor Charts provides an option to display total stacked column value in tooltip.
This can be achieved by using the TooltipRender event to get the argument of StackedTotalValue to display the total stacked column value in the tooltip.
The below code example demonstrates how to display the total stacked column value in the tooltip
Index.razor
@using Syncfusion.Blazor.Charts
<SfChart>
<ChartEvents TooltipRender="TooltipEvent" />
<ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category" />
<ChartSeriesCollection>
<ChartSeries DataSource="@MedalDetails" XName="DepartmentName" YName="YValue" Type="ChartSeriesType.StackingColumn" />
<ChartSeries DataSource="@MedalDetails" XName="DepartmentName" YName="YValue1" Type="ChartSeriesType.StackingColumn" />
</ChartSeriesCollection>
<ChartTooltipSettings Enable="true" />
</SfChart>
@code {
public class ChartData
{
public string DepartmentName { get; set; }
public double YValue { get; set; }
public double YValue1 { get; set; }
}
public List<ChartData> MedalDetails = new List<ChartData>
{
new ChartData { DepartmentName= "BAR", YValue= 95, YValue1 =100 },
new ChartData { DepartmentName= "DINING", YValue= 200, YValue1=900 },
};
public void TooltipEvent(TooltipRenderEventArgs args)
{
//We provided the total value of the Y-axis values as arguments in the TooltipRender Event to display the total value in the tooltip.
args.Text = "Total: " + args.Data.StackedTotalValue.ToString();
}
}
The following screenshot illustrates the output of the code snippet.
Live sample for display the total stacked column value in the tooltip
Conclusion
I hope you enjoyed learning how to display total stacked column value in tooltip in Blazor Charts.
You can refer to our Blazor Chart feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Blazor Chart example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, support portal, or feedback portal. We are always happy to assist you!