I have 2 ChartView's with trackballs. I want to mouse over one 1 graph that shows the trackball and programatically position the second graphs trackball dependent upon where I am mouse overing on the the first graph. What approach should I take?
Thanks
Thanks
5 Answers, 1 is accepted
0
Accepted
Hello Deamon,
Thank you for writing.
Please, find attached an example project where I have implemented a similar case to yours. The solution is to create a custom chart view control inheriting from RadChartView and allow mouse move events to be fired through code. This starts the internal mechanism of the trackball and the two trackballs move together.
I hope this will be useful. Should you have further questions, I would be glad to help.
Regards,
Ivan Petrov
the Telerik team
Thank you for writing.
Please, find attached an example project where I have implemented a similar case to yours. The solution is to create a custom chart view control inheriting from RadChartView and allow mouse move events to be fired through code. This starts the internal mechanism of the trackball and the two trackballs move together.
I hope this will be useful. Should you have further questions, I would be glad to help.
Regards,
Ivan Petrov
the Telerik team
0
Deamon
Top achievements
Rank 2
answered on 21 Nov 2012, 09:29 PM
This worked for me with a modification. My x's don't match due to padding on the second graph. I move by x + offset and it works like a charm, thanks.
I tried to add the same thing so that movement of the send trackball moves the first, but ran into weird issues since the first trackball then proceeds to move the second and so forth.
G
I tried to add the same thing so that movement of the send trackball moves the first, but ran into weird issues since the first trackball then proceeds to move the second and so forth.
G
0
Hello Deamon,
Thank you for writing back.
I am glad my previous post was helpful. To overcome the issue where the two trackballs would move each other until a StackOverflow exception is thrown, you can make the following change to the code:
I have moved the trackballs to be fields of the form. Their LocationChanged event is handled in one method. You will have to again calculate the proper location based on the offset(s) in the charts.
I hope this will help. Feel free to write back with any further questions.
Greetings,
Ivan Petrov
the Telerik team
Thank you for writing back.
I am glad my previous post was helpful. To overcome the issue where the two trackballs would move each other until a StackOverflow exception is thrown, you can make the following change to the code:
private
ChartTrackballController leftTrackball;
private
ChartTrackballController rightTrackball;
private
void
trackball_LocationChanged(
object
sender, LocationChangedEventArgs e)
{
this
.leftTrackball.LocationChanged -= trackball_LocationChanged;
this
.rightTrackball.LocationChanged -= trackball_LocationChanged;
if
(sender ==
this
.leftTrackball)
{
this
.radChartView2.MoveTrackball(e.Location);
}
else
if
(sender ==
this
.rightTrackball)
{
this
.radChartView1.MoveTrackball(e.Location);
}
this
.leftTrackball.LocationChanged += trackball_LocationChanged;
this
.rightTrackball.LocationChanged += trackball_LocationChanged;
}
I have moved the trackballs to be fields of the form. Their LocationChanged event is handled in one method. You will have to again calculate the proper location based on the offset(s) in the charts.
I hope this will help. Feel free to write back with any further questions.
Greetings,
Ivan Petrov
the Telerik team
0
Sudha
Top achievements
Rank 1
answered on 18 May 2016, 06:23 PM
My requirement is slightly different. I have a RadChartView and RadGridView that displays the chart data in a tabular form. When the TrackBall location changes I change the row selection in the RadGridView. What I dont have right now is when the RadGridView row changes move the trackball selection to the desired position in RadChartView.
Could anyone help me achiveve this?
Thank you so much!
Sudha
0
Hello Sudha,
Thank you for writing.
Please refer to the following code snippet demonstrating how to achieve the illustrated result from the attached gif file:
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Telerik
Thank you for writing.
Please refer to the following code snippet demonstrating how to achieve the illustrated result from the attached gif file:
private
void
Form1_Load(
object
sender, EventArgs e)
{
this
.productsTableAdapter.Fill(
this
.nwindDataSet.Products);
this
.radGridView1.DataSource =
this
.productsBindingSource;
this
.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
LineSeries lineSeria =
new
LineSeries();
radChartView1.Series.Add(lineSeria);
lineSeria.ValueMember =
"UnitPrice"
;
lineSeria.CategoryMember =
"ProductName"
;
lineSeria.DataSource =
this
.productsBindingSource;
CategoricalAxis horizontalAxis = lineSeria.HorizontalAxis
as
CategoricalAxis;
if
(horizontalAxis !=
null
)
{
horizontalAxis.LabelFitMode = AxisLabelFitMode.MultiLine;
}
trackBallController =
new
CustomChartTrackballController();
radChartView1.Controllers.Add(trackBallController);
this
.radGridView1.CurrentRowChanged += radGridView1_CurrentRowChanged;
}
private
void
radGridView1_CurrentRowChanged(
object
sender, CurrentRowChangedEventArgs e)
{
if
(e.CurrentRow !=
null
&& e.CurrentRow.Index>-1)
{
CategoricalDataPoint point =
this
.radChartView1.Series[0].DataPoints[e.CurrentRow.Index]
as
CategoricalDataPoint;
trackBallController.MoveTrackballToCoordinates(
new
PointF((
float
)point.LayoutSlot.Location.X, (
float
)point.LayoutSlot.Location.Y));
this
.radChartView1.Invalidate();
}
}
CustomChartTrackballController trackBallController =
null
;
public
class
CustomChartTrackballController : ChartTrackballController
{
public
void
MoveTrackballToCoordinates(PointF point)
{
this
.MoveTrackball(point);
}
}
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.