Pie Chart Custom colors

Thread is closed for posting
3 posts, 0 answers
  1. Neetha
    Neetha avatar
    36 posts
    Member since:
    Feb 2014

    Posted 21 May 2014 Link to this post

    I have a piechart, binding data from a storedprocedure. I am getting 2 columns  one is Age and BusinessTotal. Based on Age column data, Color should be showed. Please let me know how to accomplish this.

    <telerik:RadHtmlChart runat="server" ID="RadHtmlChart3" Width="300" Height="300" Transitions="true">
                        <Appearance>
                             <FillStyle BackgroundColor="White"></FillStyle>
                        </Appearance>                  
                        <Legend>
                             <Appearance BackgroundColor="White" Position="Right" Visible="false">
                             </Appearance>
                        </Legend>
                        <PlotArea>
                             <Appearance>
                                  <FillStyle BackgroundColor="White"></FillStyle>
                             </Appearance>
                             <Series>
                                  <telerik:PieSeries DataFieldY="BusinessTotal"  StartAngle="90" >
                                       <LabelsAppearance Visible="false" Position="InsideEnd" DataFormatString="{0:N0}">
                                       </LabelsAppearance>
                                       <TooltipsAppearance Color="White"  DataFormatString="{0:N0}"></TooltipsAppearance>
                             

    Databinding : C#
    protected void GetBusinessData(string metricName)
            {
                    SqlCommand cmdProc = new SqlCommand("[oss].[SelectSalespersonBusinessAge]", SqlConnection);
                    cmdProc.CommandType = CommandType.StoredProcedure;
                    cmdProc.Parameters.AddWithValue("@LoginName", loginName);
                    cmdProc.Parameters.AddWithValue("@MetricYear", metricYear);
                    cmdProc.Parameters.AddWithValue("@MetricMonth", metricMonth);

                    SqlDataAdapter adp = new SqlDataAdapter();
                    adp.SelectCommand = cmdProc;
                    adp.Fill(dt);
                    RadHtmlChart3.DataSource = dt;
                    RadHtmlChart3.DataBind();
                    if (dt.Rows[0]["age"].ToString() == "7-12 Months")
                    {
                      //Yellow color should be assigned for this part
                      
                    }
                    if (dt.Rows[1]["age"].ToString() == "12+ Months")
                    {
                       //REd for this
                    }              
    }
  2. Neetha
    Neetha avatar
    36 posts
    Member since:
    Feb 2014

    Posted 22 May 2014 in reply to Neetha Link to this post

    Any idea?.. How to accomplish this?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1490 posts

    Posted 23 May 2014 Link to this post

    Hello Neetha,

    You can use the ColorField property of the series, in order to reference a color for each item from the data source. Such an example is illustrated in the HtmlChart - Conditional Item Colorization online demo.

    Regards,
    Danail Vasilev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top