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

Unable to drilldown into bar chart

3 Answers 34 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Praveen
Top achievements
Rank 1
Praveen asked on 23 Feb 2011, 03:36 PM
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

3 Answers, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 28 Feb 2011, 03:04 PM
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!
0
Praveen
Top achievements
Rank 1
answered on 17 Mar 2011, 07:27 AM
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

 

 

 

0
Giuseppe
Telerik team
answered on 22 Mar 2011, 03:45 PM
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
Tags
Chart
Asked by
Praveen
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Praveen
Top achievements
Rank 1
Share this question
or