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

Draw in Chart

5 Answers 88 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Mickael
Top achievements
Rank 1
Mickael asked on 27 Apr 2011, 09:20 AM
 

Hello,


I don't speak English very well, but I have a question about the API WPF Telerik.


I would like to know if it's possible to draw on charts?


The user must be able to draw a rectangle on a scatter series using the mouse.


This rectangle will be modified in width. The height will be automatically adjusted based on the average of selected points in the rectangle.


We would like to know if this is feasible or not via the API WPF Telerik and if so using what events?


Best regards,

5 Answers, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 02 May 2011, 12:09 PM
Hello Mickael,

Take a look at this blogpost that demonstrates our Interactivity API. The sample project that you may find attached there shows how to draw a rectangle over the ChartArea by handling the MouseLeftButtonDown, MouseMove and MouseLeftButtonUp. Furthermore it calculates the PlotArea's coordinates for positioning the rectangle from physical data.

Feel free to modify the source code so that it fits your requirements.

Greetings,
Evgenia
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Mickael
Top achievements
Rank 1
answered on 02 May 2011, 03:36 PM
Ok, but I want to draw my rectangle with axis X and axis Y for limit. 


And I can not find coordinates (x, y) of axisX and axisY.


Where can I find them?
0
Evgenia
Telerik team
answered on 05 May 2011, 12:32 PM
Hi Mickael,

The blogpost mentioned in my previous post describes exactly how to find the start and end coordinates of the axes so that the Rectangle will be drawn inside the ChartArea. "The tricky part is how to convert the size of the rectangle to a data range. Well that’s easy, because the Axis exposes methods that allow us to convert physical units to data units'. The method is ConvertPhysicalUnitsToData:

double startX = this.RadChart1.DefaultView.ChartArea.AxisX.ConvertPhysicalUnitsToData(this.plotAreaStartPosition.X);

By having the start and end values converted, you can easily use them to have the Rectangle drawn inside this range.
Once again the full source code in the end of the blogpost demonstrates this in action so give it a try.

Regards,
Evgenia
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Mickael
Top achievements
Rank 1
answered on 05 May 2011, 01:14 PM
Ok, but your example is in SilvertLight and I'm in WPF and  I don't have access to "ChildrenOfType()"

private Panel PlotAreaPanel
{
    get
    {
        return this.RadChart1.DefaultView.ChartArea.ChildrenOfType<ClipPanel>()[0] as Panel;
    }
}

So it's impossible to calculate "this.plotAreaStartPosition" and "this.plotAreaEndPosition".

How ?
0
Mickael
Top achievements
Rank 1
answered on 05 May 2011, 01:36 PM
Sorry, i forgot to import this library "using Telerik.Windows.Controls;".

Its ok for me.

Thank you
Tags
Chart
Asked by
Mickael
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Mickael
Top achievements
Rank 1
Share this question
or