This is a migrated thread and some comments may be shown as answers.

How to change donut chart labels

2 Answers 115 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Arturo
Top achievements
Rank 1
Arturo asked on 26 May 2020, 05:37 PM

Good afternoon everyone, I am trying to make a donut chart and I have managed to fill it with the values of a datatable, the problem I have is when showing the legends, it always gives me the same value to show. How can I make the labels show as they should be? Thank you

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Vessy
Telerik team
answered on 29 May 2020, 01:11 PM

Hi Arturo,

In order to have different names for the series items of the Donut chart, you have to pass the name of the column holding the desired values to the NameField property of the chart.

For example:

        <telerik:RadHtmlChart ID="RadHtmlChart1" runat="server">
            <PlotArea>
                <Series>
                    <telerik:DonutSeries Name="Series 1" DataFieldY="valuesColumn" NameField="namesColumn">
                    </telerik:DonutSeries>
                </Series>
            </PlotArea>
        </telerik:RadHtmlChart>

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            RadHtmlChart1.DataSource = GetData();
            RadHtmlChart1.DataBind();
        }
    }

    private object GetData()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("valuesColumn");
        dt.Columns.Add("namesColumn");

        dt.Rows.Add(20, "Correctivo");
        dt.Rows.Add(20, "Verficacion");
        dt.Rows.Add(20, "Adaptaciones");
        dt.Rows.Add(20, "Garantia");

        return dt;
    }

Regards,
Vessy
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Arturo
Top achievements
Rank 1
answered on 29 May 2020, 07:51 PM
Thanks a lot, it works.
Tags
Chart (HTML5)
Asked by
Arturo
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Arturo
Top achievements
Rank 1
Share this question
or