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

RadDiagram - set milimeters as unit of measurement

1 Answer 140 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 25 Oct 2016, 01:49 PM

Hello,

 

Currently, RadDiagram uses pixels as the unit of measurement. I have been working on a solution, which requires millimeters as the unit of measurement.

I know I can change RadRuler measurement unit to centimeter (http://www.telerik.com/forums/ruler-that-displays-units-in-inches-mm), but this change only display value on ruler. I need support in the RadDiagram - grid lines in mm, snap to milimeters (not pixels) and page size in mm. How I can add support to milimeters unit?

 

Thanks you
Adam

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 28 Oct 2016, 12:18 PM
Hello Adam,

Currently the BackgroundGrid and the DiagramRuler's MeasurementUnit are not directly connected. We understand your requirement and that is why we logged it in our portal as a new feature request.

What you can do on your side is to set the BackgroundGrid's cell size and all other elements via manual calculations. Here is a part of an internal code that you can use:

private const double DipsInInch = 96d;
        private const double CmsInInch = 2.54d;
 
        /// <summary>
        /// Converts inches to DIPs (Device Independent Pixel).
        /// </summary>
        /// <param name="inch">An inch value.</param>
        /// <returns>A Dip value.</returns>
        internal static double InchToDip(double inch)
        {
            return inch * DipsInInch;
        }
 
        /// <summary>
        /// Converts DIPs (Device Independent Pixel) to inches.
        /// </summary>
        /// <param name="dip">An inch value.</param>
        /// <returns>A Dip value.</returns>
        internal static double DipToInch(double dip)
        {
            return dip / DipsInInch;
        }
 
        /// <summary>
        /// Converts centimeters to DIPs (Device Independent Pixel).
        /// </summary>
        /// <param name="cm">A centimeter value.</param>
        /// <returns>A Dip value.</returns>
        internal static double CmToDip(double cm)
        {
            return (cm / CmsInInch) * DipsInInch;
        }
 
        /// <summary>
        /// Converts DIPs (Device Independent Pixel) to centimeters.
        /// </summary>
        /// <param name="dip">A Dip value.</param>
        /// <returns>A centimeter value.</returns>
        internal static double DipToCm(double dip)
        {
            return (dip / DipsInInch) * CmsInInch;
        }


Regards,
Petar Mladenov
Telerik by Progress
Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
Tags
Diagram
Asked by
Adam
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or