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

Piechart custom colors

2 Answers 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Neetha
Top achievements
Rank 1
Neetha asked on 19 May 2014, 05:20 PM
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 Answers, 1 is accepted

Sort by
0
Neetha
Top achievements
Rank 1
answered on 20 May 2014, 06:12 PM
Any Idea how to implement this?
0
Neetha
Top achievements
Rank 1
answered on 21 May 2014, 03:13 PM
I tried this but didnt help, please let me know how to proceed:

                if (dt.Rows[2]["age"].ToString() == "< 6 Months")
                {
                    PieSeriesItem psi = new PieSeriesItem();
                    psi.BackgroundColor = Color.Yellow;
                    PieSeries ps = new PieSeries();
                    ps.DataFieldY = "BusinessTotal";
                    ps.StartAngle = 90;
                    ps.SeriesItems.Add(psi);
                    RadHtmlChart3.PlotArea.Series.Add(ps);

                } in radhtmlchart method
Tags
Grid
Asked by
Neetha
Top achievements
Rank 1
Answers by
Neetha
Top achievements
Rank 1
Share this question
or