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

Diagram Canvas Size

3 Answers 215 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
yenkay
Top achievements
Rank 2
yenkay asked on 30 Mar 2020, 06:06 AM

How to create a Rad Diagram canvas with fixed height and width and get only the positive quadrant (x,y) in the view port?

The issue is when I add shapes to the canvas it can be dragged to any quadrant of the canvas, which I want to restrict.

In any case the shapes should not go outside the positive x,y coordinates. I could not find any setting or implementation related to this any samples.

3 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 01 Apr 2020, 10:59 AM

Hi Karthik N,

I think the Restrict the Draggable Area help article is what you need. This article describes how you can use the DraggingService of the RadDiagram to restrict the dragging area.

I hope this article is helpful.

Regards,
Dinko
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
yenkay
Top achievements
Rank 2
answered on 01 Apr 2020, 12:53 PM

The question I meant to ask was, the canvas when dragged or zoomed out, we are able to see the -x, -y quadrants of it, which I want to control. With that being restricted, the user will be able to work only on the positive quadrant of the canvas with Zoom/Drag options.

How to achieve this ?

0
Dinko | Tech Support Engineer
Telerik team
answered on 06 Apr 2020, 09:36 AM

Hi Karthik,

Thank you for elaborating on your scenario.

What comes up to my mind is to use the BringIntoView() method of the RadDiagram. You could subscribe to the ViewPortChanged event. In its event handler, you can get check the new TopLeft point from the event arguments. If Top or Left properties are negative you can reset them to 0. The following code snippet demonstrate what I have in mind.

private void Diagram_ViewportChanged(object sender, PropertyEventArgs<Rect> e)
{
    if (e.NewValue.Top < 0)
    {
        diagram.BringIntoView(new Rect(e.NewValue.X, 0, e.NewValue.Width, e.NewValue.Height),false);
    }
    if (e.NewValue.Left < 0)
    {
        diagram.BringIntoView(new Rect(0, e.NewValue.Y, e.NewValue.Width, e.NewValue.Height),false);
    }
}

Regards,
Dinko
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Diagram
Asked by
yenkay
Top achievements
Rank 2
Answers by
Dinko | Tech Support Engineer
Telerik team
yenkay
Top achievements
Rank 2
Share this question
or