Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Drag and Drop/interactive?? (Read 4021 times)
TRB
Junior Member
**
Offline


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Drag and Drop/interactive??
May 14th, 2016 at 2:00am
Print Post  
Hi,
    I am looking to add some bar graphs to my current project (which I use mind fusion scheduling control and love it!).

Is it possible to enable drag drop functionality to your charts?

Example of what I want to achieve.

I have a data repeater of unassigned data(projects). I want the user to be able to drag that data to the bar graph where it adds a new stacked series to the graph it was dropped (assigning the data to a resource) This new stacked series (and any other series) needs to be able to be dragged and dropped to any other series (resource).

Please let me know if you need me to explain it a different way.  Huh
  

Regards,
TRB
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Drag and Drop/interactive??
Reply #1 - May 16th, 2016 at 7:54am
Print Post  
Hi,

You can handle data dragged from another control to the chart like this -

Code
Select All
chart.AllowDrop = true;

chart.DragEnter += (s, e) =>
	e.Effect = DragDropEffects.Copy;

chart.DragDrop += (s, e) =>
	chart.Series.Add(
		new BarSeries(
			new double[] { 5, 5, 5 }, null, null));
 



Letting users start drag and drop operation from a bar in the chart should look like this -

Code
Select All
chart.MouseDown += (s, e) =>
{
	var hit = chart.HitTest(e.Location);
	if (hit != null)
		chart.DoDragDrop(chart.Series.IndexOf(hit.Series), DragDropEffects.Copy);
}; 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
TRB
Junior Member
**
Offline


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Re: Drag and Drop/interactive??
Reply #2 - May 17th, 2016 at 6:57am
Print Post  
Thanks so much for the response. This is exactly what I am after. I am however struggling to convert this to vb.net.... Embarrassed .... it looks like another one of your controls I will have to start using though!
  

Regards,
TRB
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Drag and Drop/interactive??
Reply #3 - May 17th, 2016 at 7:56am
Print Post  
Hi,

That code uses lambda expressions, you can find how to write them in VB.NET here -
https://msdn.microsoft.com/en-us/library/bb531253.aspx

Here is equivalent (auto-converted) VB.NET code -

Code
Select All
AddHandler chart.DragEnter, Sub(s, e) e.Effect = DragDropEffects.Copy

AddHandler chart.DragDrop, Sub(s, e) chart.Series.Add(New BarSeries(New Double() {5, 5, 5}, Nothing, Nothing))

AddHandler chart.MouseDown, Sub(s, e)
	Dim hit = chart.HitTest(e.Location)
	If hit IsNot Nothing Then
		chart.DoDragDrop(chart.Series.IndexOf(hit.Series), DragDropEffects.Copy)
	End If
End Sub 



It does not look as nice as in C#, so maybe you'd better use classic event handler subs Wink

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint