Bar color binding

2 posts, 0 answers
  1. Alex
    Alex avatar
    23 posts
    Member since:
    Oct 2011

    Posted 28 Feb 2012 Link to this post

    Is there any way to bind bar chart single bar color to datasource?
  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 02 Mar 2012 Link to this post

    Hello Alex,

    Thanks for using our support.
    Please clarify what kind of DataSource you are referring to.
    When you have a bar series, each bar can be described by a point template. See for example how to create
    an orange bar and a blue bar:

    <telerik:BarSeries>
        <telerik:BarSeries.PointTemplates>
            <DataTemplate>
                <Rectangle Fill="DarkOrange" />
            </DataTemplate>
            <DataTemplate>
                <Rectangle Fill="Blue" />
            </DataTemplate>
        </telerik:BarSeries.PointTemplates>
        <telerik:CategoricalDataPoint Category="1" Value="0.9" />
        <telerik:CategoricalDataPoint Category="2" Value="0.6" />
    </telerik:BarSeries>

    If you know how many bars you will have and if the order of the bars is consistent, you can set different templates for the different bars. Also you can use the PointTemplateSelector property and implement your custom logic (DataTemplateSelector class) for choosing the appropriate bar color.

    Please write again if you need further assistance.

    Kind regards,
    Victor
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
Back to Top