Style depending on bubble value

3 posts, 1 answers
  1. Simon
    Simon avatar
    6 posts
    Member since:
    Jun 2013

    Posted 21 Jun 2013 Link to this post

    Hello,

    I have a bubble chart with positive and negative value for the same series. Would it be possible to give a different style for a negative value bubble ? Since my bubbles are blue, the negative ones could be red. If it is possible, what are the style changes that I can apply to a bubble (dotted perimeter, filled with a texture etc.) 

    Thank you in advance for your help!
  2. Answer
    Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 26 Jun 2013 Link to this post

    Hi,

    One option you have is to use the CreateItemStyleDelegate property of the RadChart (help topic here). The code below should also be helpful:
    public Style chart1_CreateItemStyle_RedIfNegative(Control c, Style s, DataPoint dp, DataSeries ds)
    {
     Style resultStyle = new Style(s.TargetType);
     resultStyle.BasedOn = s;
     
     var chartItem = c as BaseChartItem;
     var lineSeries = c as LineSeries;
     
     if (chartItem != null && ds[chartItem.CurrentIndex].YValue < 0)
     {
      Brush redBrush = new SolidColorBrush(new Color() { R = 200, G = 20, B = 20, A = 55 });
      resultStyle.Setters.Add(new Setter(Shape.FillProperty, redBrush));
     }
     
     return resultStyle;
    }


    Regards,
    Petar Marchev
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
  4. Simon
    Simon avatar
    6 posts
    Member since:
    Jun 2013

    Posted 26 Jun 2013 Link to this post

    Works perfectly, thank you!
Back to Top