Drop from TreeView to RadChart DataPoint

5 posts, 0 answers
  1. John Lurtz
    John Lurtz avatar
    1 posts
    Member since:
    Sep 2009

    Posted 14 Oct 2009 Link to this post

    Hello!

    I am able to drop TreeView Items onto my RadCharts succesfully.  My question is around dropping the items to a specific DataPoint in the Chart.  For example, if I have a BarSeries RadChart with 3 columns(datapoints) if I drag and drop the TreeView item over column #2 am I able to realize that the drop happened on column #2 and not just on the ChartArea in General?

    Thanks,
    JL
  2. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 20 Oct 2009 Link to this post

    Hi John,

    Yes, this is possible with our RadDragAndDropManager. You will need to set RadDragAndDropManager.AllowDrop property to true for Bar. You can use styles for this:

    <Style x:Key="BarItemsStyle" TargetType="chart:Bar">
                <Setter Property="dragDrop:RadDragAndDropManager.AllowDrop" Value="True" />
            </Style>

    And make sure this style is applied:

    DataSeries series = new DataSeries();
    series.Definition = new BarSeriesDefinition() { ItemStyle = this.Resources["BarItemsStyle"] as Style };

    Now set e.QueryResult to true in DropQuery event handler and you will be able to retrieve the Bar instance in the DropInfo event handler through e.Options.Destination. You can find more details about RadDragAndDropManager in this help topic.


    Best regards,
    Ves
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Lutz
    Lutz avatar
    5 posts
    Member since:
    Aug 2012

    Posted 20 Aug 2012 Link to this post

    Hello Telerik,

    we got a System.NullReferenceException in the statement ‘RadDragAndDropManager.AddDropQueryHandler’.
    Our code:

     

    Private Sub SetDefinitionToChart(ByRef dataSeries As DataSeries, definition As ISeriesDefinition) 
        dataSeries.Definition = definition 
        Dim depObj As DependencyObject = CType(dataSeries.Definition, DependencyObject) 
        RadDragAndDropManager.SetAllowDrop(depObj, True)
       
        RadDragAndDropManager.AddDropQueryHandler(depObj, AddressOf RadChart_Series_OnDropQuery) 
        RadDragAndDropManager.AddDropInfoHandler(depObj, AddressOf RadChart_Series_OnDropInfo) 
    End Sub
      
    Private Sub RadChart_Series_OnDropQuery(ByVal sender As Object, ByVal e As DragDropQueryEventArgs)
    End Sub

     

     


    Do you have an idea, wath´s wrong with our code?

     

    We are using the WPF RadChart, Version 2011.2.712.40 of the Telerik.Windows.Controls.Charting.dll.

     

    In your answer in the previous post you talked only about finding the DataSeries, but the task is, to drop on a DataPoint. Please can you explain this in more detail?

     

    Thanks,
    Lutz

  5. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 23 Aug 2012 Link to this post

    Hi Lutz,

    The style, set to ItemStyle property of the BarSeriesDefinition will be applied to every Bar item in the series, so basically it covers this requirement -- the item will be dropped on a datapoint (bar in this example). Can you send us a small example, which reproduces the problem you are getting? This way we will be able to debug it locally and get back to you with our findings.

    Best regards,
    Ves
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Lutz
    Lutz avatar
    5 posts
    Member since:
    Aug 2012

    Posted 30 Aug 2012 Link to this post

    Hello Telerik,

    we support configurable charttypes, so we like to set the drop capability for all types at once.
    Our solution is now:

    Public Function RadChart_CreateItemStyle(ByVal item As Control, ByVal style As Style, ByVal point As DataPoint, ByVal dataSeries As DataSeries) As Style
        Dim newStyle As New Style(style.TargetType)
        newStyle.BasedOn = style
        If TypeOf item Is BaseChartItem Or
            TypeOf item Is ChartLegendItem Or
            TypeOf item Is SelfDrawingSeries Then

            
    RadDragAndDropManager.SetAllowDrop(item, True)
            RemoveHandler item.DragOver, AddressOf RadChart_SeriesItem_DragOver
            RadDragAndDropManager.RemoveDropQueryHandler(item, AddressOf RadChart_Series_OnDropQuery)
            RadDragAndDropManager.RemoveDropInfoHandler(item, AddressOf RadChart_Series_OnDropInfo)

            
    AddHandler item.DragOver, AddressOf RadChart_SeriesItem_DragOver
            RadDragAndDropManager.SetAllowDrop(item, True)
            RadDragAndDropManager.AddDropQueryHandler(item, AddressOf RadChart_Series_OnDropQuery)
            RadDragAndDropManager.AddDropInfoHandler(item, AddressOf RadChart_Series_OnDropInfo)
        End If
        Return newStyle
    End Function

    It may look a little strange, to do this in the CreateItemStyleDelegate, but it works. We don´t find any other possibility to get the instances of type BaseChartItem etc.

    Thank you
Back to Top
DevCraft banner