Skip to content

kb(chart):kb for adding data table below chart #335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions knowledge-base/chart-add-data-table.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
title: Data table in the chart
description: How to add a data table in the chart?
type: how-to
page_title: Data table in the chart
slug: chart-kb-data-table
position:
tags: telerik,blazor,chart,data,table
ticketid: 1520360
res_type: kb
---

## Environment
<table>
<tbody>
<tr>
<td>Product</td>
<td>Charts for Blazor</td>
</tr>
</tbody>
</table>


## Description
Is there an easy way to put the data table below the chart? Chart with data table. How to add a data table to the Chart?

## Solution
You can use Grid for data table below the Chart. By using the same data from the Chart in the Grid below it, you can achieve the desired result.

>caption Added Grid in the role of data table below the Chart. The result from the snippet below.

![Chart with data table](images/chart-with-data-table-below.png)

````CSHTML
@*This chart is using Grid for thr role of data table*@

<TelerikChart Height="400px" Width="800px">
<ChartSeriesItems>
<ChartSeries Type="ChartSeriesType.Bar" Data="@theData" ColorField="@nameof(MyChartDataModel.Color)"
Field="@nameof(MyChartDataModel.ItemValue)" CategoryField="@nameof(MyChartDataModel.Category)" />
</ChartSeriesItems>
<ChartTitle Text="Revenue per product" />
<ChartLegend Position="ChartLegendPosition.Right" />
</TelerikChart>
<TelerikGrid Data="@theData" Height="150px" Width="800px">
<GridColumns>
<GridColumn Field="@(nameof(MyChartDataModel.Category))" />
<GridColumn Field="@(nameof(MyChartDataModel.ItemValue))" />
<GridColumn Field="@(nameof(MyChartDataModel.Color))" />
</GridColumns>
</TelerikGrid>

@code {
public class MyChartDataModel
{
public string Category { get; set; }
public double ItemValue { get; set; }
public string Color { get; set; }
}

public List<MyChartDataModel> theData = new List<MyChartDataModel>
{
new MyChartDataModel
{
Category = "Product 1",
ItemValue = 2,
Color = "red"
},
new MyChartDataModel
{
Category = "Product 2",
ItemValue = 3,
Color = "lime"
},
new MyChartDataModel
{
Category = "Product 3",
ItemValue = 4,
Color = "blue"
}
};
}
````
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.