Unable to drilldown into bar chart

4 posts, 0 answers
  1. Praveen
    Praveen avatar
    34 posts
    Member since:
    Apr 2009

    Posted 23 Feb 2011 Link to this post

    Hi,

    i am not able to drilldown into bar chart when one bar chart value in much higher as compare to other bars, The bar is not plotted for lower value chart so not able to drilldown. Is there any workaround for this. Like click events on bar value chart.

    Please have a look the attached file.


    Thanks
    Praveen Tomar
  2. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 28 Feb 2011 Link to this post

    Hi Praveen,

    Right now only the series items have an out-of-the-box CLR event for them. You can use framework-provided routed events to achieve the desired effect for the series item labels like this (note you will need to apply custom style to the series item labels in order to enable hit testing):

    XAML
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.Resources>
            <Style x:Key="CustomStyle" TargetType="telerik:SeriesItemLabel">
                <Setter Property="IsHitTestVisible" Value="True" />
            </Style>
        </Grid.Resources>
     
        <telerik:RadChart x:Name="RadChart1"  />
    </Grid>

    C#
    public MainPage()
    {
        InitializeComponent();
     
        RadChart1.DefaultSeriesDefinition = new BarSeriesDefinition() { SeriesItemLabelStyle = this.LayoutRoot.Resources["CustomStyle"] as Style };
     
        RadChart1.ItemsSource = new List<int> { 1000, 2000, 5000000 };
     
        RadChart1.AddHandler(MouseLeftButtonDownEvent, new MouseButtonEventHandler(MouseLeftBuddonDownEventHandler), true);
    }
     
    public void MouseLeftBuddonDownEventHandler(object sender, MouseButtonEventArgs e)
    {
        var textBlock = e.OriginalSource as TextBlock;
        if (textBlock == null)
            return;
     
        var seriesItemLabel = textBlock.GetVisualParent<SeriesItemLabel>();
        if (seriesItemLabel != null)
        {
            //textBlock.Text holds the string
            //...
     
            //seriesItemLabel.DataPoint / DataSeries properties hold the respective item / series info
            //...
        }
    }


    All the best,
    Giuseppe
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. Praveen
    Praveen avatar
    34 posts
    Member since:
    Apr 2009

    Posted 17 Mar 2011 Link to this post

    Thanks Giuseppe but it will not solve my problem. My drilldown functinality depends upon x-axis item. I need the value of X-axis DataPoint when I dilldown into specific bar chart.

    Like I did it on ChartArea ItemClick item

    int

     

     

    id = ((MyObject)(e.DataPoint.DataItem)).Id;

    Please help.

    Thanks
    Praveen Tomar

     

     

     

  4. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 22 Mar 2011 Link to this post

    Hello Praveen,

    As noted in the source code snippet we sent you in our previous reply, you can get the respective data point from the series item label itself:
    public void MouseLeftBuddonDownEventHandler(object sender, MouseButtonEventArgs e)
    {
        var textBlock = e.OriginalSource as TextBlock;
        if (textBlock == null)
            return;
     
        var seriesItemLabel = textBlock.GetVisualParent<SeriesItemLabel>();
        if (seriesItemLabel != null)
        {
            //textBlock.Text holds the string
            //...
     
            //seriesItemLabel.DataPoint / DataSeries properties hold the respective item / series info
            //...
        }
    }



    Greetings,
    Giuseppe
    the Telerik team
Back to Top