Page 1 of 2
cause a line to follow the mouse
Posted: Sun May 18, 2008 3:15 pm
by 9642362
hello,
is there a functionallity that allow the mouse to drag a line to a different location on the chart? if so, is there a code sample for it?
Posted: Mon May 19, 2008 9:10 am
by narcis
Hi idan,
Yes, you can do as in the example I posted
here.
drag and drop a bubble..
Posted: Wed May 21, 2008 1:27 pm
by 9642362
I am using the above sample to drag a bubble and not a line. Is there a way to show the bubble moving with the mouse cursor until the drop (in transperent way)
Posted: Wed May 21, 2008 1:47 pm
by narcis
Hi idan,
If you only want to drag one single bubble you should use DragPoint tool. You'll find an example at
All Features\Welcome !\Tools\Drag Point in the features demo, available at TeeChart's program group.
For setting bubble transparency you can do this:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Zoom.Allow = false;
bubble1 = new Steema.TeeChart.Styles.Bubble(tChart1.Chart);
bubble1.FillSampleValues();
tChart1.MouseUp += new MouseEventHandler(tChart1_MouseUp);
Steema.TeeChart.Tools.DragPoint dragPoint1 = new Steema.TeeChart.Tools.DragPoint(tChart1.Chart);
dragPoint1.Drag += new Steema.TeeChart.Tools.DragPointEventHandler(dragPoint1_Drag);
}
void dragPoint1_Drag(Steema.TeeChart.Tools.DragPoint sender, int index)
{
bubble1.Colors[index] = Color.FromArgb(50, bubble1.Colors[index]);
i = index;
}
private Steema.TeeChart.Styles.Bubble bubble1;
private int i = -1;
private void tChart1_MouseUp(object sender, MouseEventArgs e)
{
bubble1.Colors[i] = Color.FromArgb(0, bubble1.Colors[i]);
i = -1;
}
great tool.
Posted: Wed May 21, 2008 2:59 pm
by 9642362
Can i force the drag to be followed only on the y axis meaning only vertically, and how can i make the bubble transperent during the drag?
Posted: Wed May 21, 2008 3:04 pm
by narcis
Hi idan,
Yes, set DragPoint tool like this:
Code: Select all
dragPoint1.Style = Steema.TeeChart.Tools.DragPointStyles.Y;
Have you tried running the example I posted? It already makes the dragged bubble transparent.
one more question...
Posted: Wed May 21, 2008 3:09 pm
by 9642362
i have multiplie series on the chart, and i want to drag only specific graph and not all the series on the chart.
regarding the transperent issue...
Posted: Wed May 21, 2008 3:15 pm
by 9642362
i guess it's making it transperent, but it's very hard to see it because the bubble style is polished sphere
Posted: Thu May 22, 2008 7:29 am
by narcis
Hi idan,
You can set DragPoint tool to a specific series:
So that it will only work for this series. Using line above together with the code in my example will only drag bubble1 series.
click event is not fired because of dragTool
Posted: Thu May 22, 2008 8:20 am
by 9642362
after adding a drag tool to a series the series click event (only left click, right click fires the event) isn't fired. is that a known issue? is there a way to keep the drag tool and still fire the event?
Posted: Thu May 22, 2008 9:17 am
by narcis
Hi idan,
By defaul DragPoint tool uses left mouse button, if you want to use right button you need to do this:
Code: Select all
dragPoint1.Button = MouseButtons.Right;
DragPoint tool masks the ClickSeries event. However, you can achieve what you request using MouseDown event like this:
Code: Select all
void tChart1_MouseDown(object sender, MouseEventArgs e)
{
for (int i = 0; i < tChart1.Series.Count; i++)
{
if (tChart1[i].Clicked(e.X,e.Y) != -1)
{
tChart1.Header.Text = "Series " + i.ToString() + " clicked at point " +
tChart1[i].Clicked(e.X, e.Y).ToString();
}
}
}
double click event with DragTool
Posted: Thu May 22, 2008 11:19 am
by 9642362
the DragTool masks the double click for a series as well. is there a work around for it also?
one more question for the bubble graph. is there a way to keep the bubble the same size even in zoom events?
Posted: Thu May 22, 2008 11:30 am
by narcis
Hi idan,
the DragTool masks the double click for a series as well. is there a work around for it also?
You can use chart's DoubleClick event like this:
Code: Select all
void tChart1_DoubleClick(object sender, EventArgs e)
{
for (int i = 0; i < tChart1.Series.Count; i++)
{
if (tChart1[i].Clicked(X, Y) != -1)
{
tChart1.Header.Text = "Series " + i.ToString() + " dblclicked at point " +
tChart1[i].Clicked(X, Y).ToString();
}
}
X = -1;
Y = -1;
}
private int X = -1;
private int Y = -1;
void tChart1_MouseDown(object sender, MouseEventArgs e)
{
X = e.X;
Y = e.Y;
}
one more question for the bubble graph. is there a way to keep the bubble the same size even in zoom events?
I'm not sure about what you exactly mean. However, you could try changing bubbles radius according to the zooming ratio. You could try using the Zoomed and UndoneZoom events for that. Retrieving initial axes min. and max. values before and after zooming will give you the zooming ratio.
keep the bubble the same size even in zoom events
Posted: Thu May 22, 2008 12:19 pm
by 9642362
how can i change the radius for a series after calculating the zoom ratio.(I guess you meant the difference between the inital and current axes in the zoomed event...)
Posted: Thu May 22, 2008 12:41 pm
by narcis
Hi idan,
Yes, exactly. You can change radius values like this:
Code: Select all
for (int i = 0; i < bubble1.Count; i++)
{
bubble1.RadiusValues[i] *= ratio;
}