Hello,
I have a diagram. When I call AutoFit() method it does not fill all the space available of the host window.I have to zoom in (manually) a bit to get a better fit. How do I achive AutoFit functionality that makes diagram as large as possible filling all visible space of the host window? Some function like ZoomToFit()?
I attach two images of what I get by default and what I would like to get.
I have a diagram. When I call AutoFit() method it does not fill all the space available of the host window.I have to zoom in (manually) a bit to get a better fit. How do I achive AutoFit functionality that makes diagram as large as possible filling all visible space of the host window? Some function like ZoomToFit()?
I attach two images of what I get by default and what I would like to get.
6 Answers, 1 is accepted
0

Sarper
Top achievements
Rank 2
answered on 07 Nov 2012, 07:44 PM
Hi Mikhail,
You can achieve that issue by giving a little margin to AutoFit() method. It has two optional parameters;
-Thickness margin => margin between diagram shapes and the host window
-bool useAnimation => ( autofit animation )
Here is the 5 value specifies a little margin. You can use that to fit your needs.
Sincerely,
Sarper
You can achieve that issue by giving a little margin to AutoFit() method. It has two optional parameters;
-Thickness margin => margin between diagram shapes and the host window
-bool useAnimation => ( autofit animation )
private
void
AutoFit_Click(
object
sender, RoutedEventArgs e)
{
this
.diagram.AutoFit(
new
Thickness(5),
true
);
}
Sincerely,
Sarper
0

Mikhail
Top achievements
Rank 1
answered on 07 Nov 2012, 08:03 PM
Hi,
Thanks for the answer.
However, it does not work. I tried it.
Margin works only if original diagram is bigger than view area.Then it zooms out enough to fit AND it sets proper Margins.
But , if original diagram is smaller and fits already, but needs to be auto zoomed in(enlarged), AutoFit with margin does not work!
It takes whole diagram and just puts it in center (like in my original bitmap i attached).
I think , it is bug. It should automatically zoom in and respect margins provided.
Let me know.
Thanks!
Thanks for the answer.
However, it does not work. I tried it.
Margin works only if original diagram is bigger than view area.Then it zooms out enough to fit AND it sets proper Margins.
But , if original diagram is smaller and fits already, but needs to be auto zoomed in(enlarged), AutoFit with margin does not work!
It takes whole diagram and just puts it in center (like in my original bitmap i attached).
I think , it is bug. It should automatically zoom in and respect margins provided.
Let me know.
Thanks!
0

Sarper
Top achievements
Rank 2
answered on 07 Nov 2012, 08:23 PM
Hi,
I tried different scenarios but it worked fine for me. Can you give the code-snippet that you use?
Sincerely,
Sarper
I tried different scenarios but it worked fine for me. Can you give the code-snippet that you use?
Sincerely,
Sarper
0

Mikhail
Top achievements
Rank 1
answered on 07 Nov 2012, 09:28 PM
I am not allowed to attach zip files. It is a very simple case.
Just try to Maximize your window and then call AutoFit with small margin. It will not work.
It looks like it only works when window is resized a bit. But when window size is close to Maximized, it does not respect margins anymore.
Just try to Maximize your window and then call AutoFit with small margin. It will not work.
It looks like it only works when window is resized a bit. But when window size is close to Maximized, it does not respect margins anymore.
0
Accepted
Hi Mikhail,
The AutoFit method of the RadDiagram control simply centers and zooms out the diagram to display all items. This is why in case you have a large Diagram area with small diagram shapes, the AutoFit method will only center them.
In order to stretch the shapes to fit to a certain area, you can use the FitTo() method - it takes a Rect object as an argument and fits the diagram to the specified rectangle. I attached a sample solution demonstrating this approach. Let me know if it helps.
Kind regards,
Tina Stancheva
the Telerik team
The AutoFit method of the RadDiagram control simply centers and zooms out the diagram to display all items. This is why in case you have a large Diagram area with small diagram shapes, the AutoFit method will only center them.
In order to stretch the shapes to fit to a certain area, you can use the FitTo() method - it takes a Rect object as an argument and fits the diagram to the specified rectangle. I attached a sample solution demonstrating this approach. Let me know if it helps.
Kind regards,
Tina Stancheva
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0

Mikhail
Top achievements
Rank 1
answered on 08 Nov 2012, 05:33 PM
Thank you for the fast answer!
Then if AutoFit only centers it (eventhough I provided margins), then it does not consider provided margins! Which I think is wrong and confusing. There should be another function related to Zoom. It should be called ZoomToFit()!
Anyway, I understood your point about using FitTo(). That's what I will do.
Thanks anyway.
Mikhail.
Then if AutoFit only centers it (eventhough I provided margins), then it does not consider provided margins! Which I think is wrong and confusing. There should be another function related to Zoom. It should be called ZoomToFit()!
Anyway, I understood your point about using FitTo(). That's what I will do.
Thanks anyway.
Mikhail.