Example of bulletGraph

2 posts, 0 answers
  1. sunita
    sunita avatar
    9 posts
    Member since:
    Feb 2011

    Posted 05 Apr 2011 Link to this post

    hello ,

    Can you provide me an example ( sample code)  in which data binding is done programmatically.Values for ComparativeMeasure FeaturedMeasure, and QualitativeRanges should be set programmatically.

    <telerik:RadHorizontalBulletGraph.QualitativeRanges>

    <telerik:QualitativeRange x:Name="Min" Brush="#A8A8A8" Value="3" />

    <telerik:QualitativeRange x:Name="Avg" Brush="#C6C8C8" Value="4" />

    <telerik:QualitativeRange x:Name="Max" Brush="#E8E8E8" />

    </telerik:RadHorizontalBulletGraph.QualitativeRanges>

    it will be very help full for me

    Thanks
    Sunita



  2. Evgenia
    Admin
    Evgenia avatar
    1407 posts

    Posted 08 Apr 2011 Link to this post

    Hello sunita,

    The following sample code demonstrates how to create RadBulletGraph programmatically. The Hex Colors for the range Brushes are converted to SolidColorBrush as shown in this public forum post:

    public partial class MainPage : UserControl
       {
           public MainPage()
           {
               InitializeComponent();
               horizontalBulletGraph.AutoRange = false;
               horizontalBulletGraph.Width = 300;
               horizontalBulletGraph.Height = 50;
               horizontalBulletGraph.Minimum = 0;
               horizontalBulletGraph.Maximum = 100;
               horizontalBulletGraph.FeaturedMeasure = 60d;
               horizontalBulletGraph.ComparativeMeasure = 65d;
               horizontalBulletGraph.ProjectedValue = 75d;
               QualitativeRange range = new QualitativeRange();
               range.Value = 50;
               range.Brush = CombineAlphaAndColorInSolidColorBrush(0, "#A8A8A8");
               horizontalBulletGraph.QualitativeRanges.Add(range);
               QualitativeRange range1 = new QualitativeRange();
               range1.Value = 70;
               range1.Brush = CombineAlphaAndColorInSolidColorBrush(0, "#C6C8C8");
               horizontalBulletGraph.QualitativeRanges.Add(range1);
               QualitativeRange range2 = new QualitativeRange();
               range2.Brush = CombineAlphaAndColorInSolidColorBrush(0, "#E8E8E8");
               horizontalBulletGraph.QualitativeRanges.Add(range2);
           }
           #region protected static SolidColorBrush CombineAlphaAndColorInSolidColorBrush(double opacity, string color)
           /// <summary>
           /// adds the alpha (opacity) value to the front of the color string
           /// </summary>
           /// <param name="opacity"></param>
           /// <param name="color"></param>
           /// <returns></returns>
           protected static SolidColorBrush CombineAlphaAndColorInSolidColorBrush(double opacity, string color)
           {
               SolidColorBrush theAnswer = new SolidColorBrush();
               // //////////////////////////////////////////////////////
               // deal with opacity
               if (opacity > 1.0)
                   opacity = 1.0;
               if (opacity < 0.0)
                   opacity = 0.0;
               // get the hex value of the alpha chanel (opacity):
               byte a = (byte)(Convert.ToInt32(255 * opacity));
               // --cmt:5afff4b1-daca-4daf-ab56-64864c80235e--
               // deal with the color
               try
               {
                   byte r = (byte)(Convert.ToUInt32(color.Substring(1, 2), 16));
                   byte g = (byte)(Convert.ToUInt32(color.Substring(3, 2), 16));
                   byte b = (byte)(Convert.ToUInt32(color.Substring(5, 2), 16));
                   theAnswer.Color = Color.FromArgb(a, r, g, b);
               }
               catch
               {
                   // pick a fugly color, but don't cause the system to barf.
                   theAnswer.Color = Color.FromArgb(255, 255, 0, 0);
               }
               return theAnswer;
           }
           #endregion
       }

    Greetings,
    Evgenia
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
Back to Top