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

Drop from TreeView to RadChart DataPoint

4 Answers 54 Views
Chart
This is a migrated thread and some comments may be shown as answers.
John Lurtz
Top achievements
Rank 1
John Lurtz asked on 14 Oct 2009, 10:23 PM
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

4 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 20 Oct 2009, 12:07 PM
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.
0
Lutz
Top achievements
Rank 1
answered on 20 Aug 2012, 12:36 PM

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

0
Ves
Telerik team
answered on 23 Aug 2012, 11:19 AM
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.

0
Lutz
Top achievements
Rank 1
answered on 30 Aug 2012, 03:46 PM
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
Tags
Chart
Asked by
John Lurtz
Top achievements
Rank 1
Answers by
Ves
Telerik team
Lutz
Top achievements
Rank 1
Share this question
or