Answer:
<SfPivotView TValue="PivotProductDetails" Width="800" Height="80%" > <PivotViewDataSourceSettings DataSource="@Data"> <PivotViewColumns> <PivotViewColumn Name="Country"></PivotViewColumn> <PivotViewColumn Name="Products"></PivotViewColumn> </PivotViewColumns> <PivotViewRows> <PivotViewRow Name="Year"></PivotViewRow> <PivotViewRow Name="Quarter"></PivotViewRow> </PivotViewRows> <PivotViewValues> <PivotViewValue Name="Sold" Caption="Unit Sold"></PivotViewValue> <PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue> </PivotViewValues> <PivotViewFormatSettings> <PivotViewFormatSetting Name="Amount" Format="C"></PivotViewFormatSetting> </PivotViewFormatSettings> </PivotViewDataSourceSettings> <PivotViewDisplayOption View=View.Chart></PivotViewDisplayOption> <PivotChartSettings Title="Sales Analysis"> <PivotChartSeries Type=ChartSeriesType.Column></PivotChartSeries> <PivotChartPrimaryYAxis> <PivotChartPrimaryYAxisBorder Width="0"></PivotChartPrimaryYAxisBorder> </PivotChartPrimaryYAxis> <PivotChartTooltipSettings Enable="true"> <Template> @{ var data = context as Syncfusion.Blazor.Charts.ChartTooltipInfo; <div>The series name is <b>@data.SeriesName</b> and the X value is @data.PointX and the Y value is @data.PointY</div> } </Template> </PivotChartTooltipSettings> </PivotChartSettings> </SfPivotView> |
Find the sample for show custom data in the Pivot Table tooltip from here.
This answer shows how to add a custom tooltip to the chart. How do you add a custom tooltip to the pivot TABLE?
|
<PivotViewTemplates>
<CellTemplate>
@{
var data = (context as AxisSet);
if (data != null)
{
if (data.Axis == "value")
{
var row = "Row : " + (context.IsGrandSum && context.RowHeaders.ToString() == "" ? "Grand Total" : string.Join('-', context.RowHeaders.ToString().Split('.')));
var column = "Column : " + (context.IsGrandSum && context.ColumnHeaders.ToString() == "" ? "Grand Total" : string.Join('-', context.ColumnHeaders.ToString().Split('.')));
var value = context.ActualText + " : " + context.FormattedText;
Count++;
<SfTooltip Target="#txt" @key="@Count">
<TooltipTemplates>
<Content>
<div>@row </div>
<div>@column</div>
<div>@value</div>
</Content>
</TooltipTemplates>
<div id="txt">@context.FormattedText</div>
</SfTooltip>
}
else
{
@data.FormattedText
}
}
}
</CellTemplate>
</PivotViewTemplates> |