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

RadHTMLChart

1 Answer 69 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Srivalli
Top achievements
Rank 1
Srivalli asked on 20 May 2016, 02:32 PM
Hi,

Im using radhmtl chart and binding the data using Dataset, I want to show the column series on different colors based on data, Can you please help how to add different colors for columnseries based on the condition I have, following is the code
<telerik:RadHtmlChart runat="server" ID="RadHtmlChart5" Width="600px" Height="400px" Visible="false" OnDataBound="RadHtmlChart5_DataBound">

<PlotArea>
<Series>
<telerik:ColumnSeries Name="Hours" DataFieldY="TotalHours">
<TooltipsAppearance Color="White"></TooltipsAppearance>
</telerik:ColumnSeries>
</Series>
<XAxis DataLabelsField="Service"></XAxis>
<YAxis><MinorGridLines Visible="false"></MinorGridLines></YAxis>
</PlotArea>
<Legend><Appearance Visible="false"></Appearance></Legend>
<ChartTitle Text="Total Hours Per Service"></ChartTitle>
</telerik:RadHtmlChart>


DataTable dt = new DataTable();
dt=Cls.GetAllData(id);
RadHtmlChart5.Visible = true;
for(int i=0; i<dt.Rows.Count; i++)
{


if (dt.Rows[0]["Service"].ToString() == "Employee")
{
//I want to show columnserries color as red
}
if (dt.Rows[0]["Service"].ToString() == "Vendor")
{
//I want to show columnserries color as blue
}
if (dt.Rows[0]["Service"].ToString() == "Contractor")
{
//I want to show columnserries color as green}
}

RadHtmlChart5.DataSource = dt;

RadHtmlChart5.DataBind();

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 25 May 2016, 08:08 AM

Hi,

I advise you review the following resouces that explain how to do this:

You can either add a field (column) in your data source that contains this information, or create SeriesItems programmatically based on your conditions.


Regards,

Marin Bratanov
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Chart (HTML5)
Asked by
Srivalli
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or