Using NON Pixel units in GoJs

Hi All,

Is it possible to use NON Pixel based values in GoJS?

For example, I have to write some code that add’s picture elements to a GoJS canvas. Problem is, the measurments I get handed to me are in Millimeters.

I’m currently adding pictures using the following:

myDiagram.add(

    GO(go.Part, GO(go.Picture, {
        source: "/animage/somewhere",
        width: 100,
        height: 50
    }))

);

but I’d like to be able to say:

myDiagram.add(

    GO(go.Part, GO(go.Picture, {
        source: "/animage/somewhere",
        width: "100mm",
        height: "50mm"
    }))

);

I’d also like to be able to say "XPosition = " and "YPosition = " at the same time, is there anyway I can achieve this?

I can’t seem to find anything in the docs that address this question.

Cheers

Shawty

(answered via email)

It is not possible to use non-CSS-pixel values in GoJS, but if you need any help with conversion issues let us know.

Thanks Simon. It’s ok I’ve created a typescript library for the project that uses a known width/height off-screen div to calculate what I need to know.

Basically, all our measurments are in mm, so I create a 1mm by 1mm off screen div, then use the HTMLElement properties to find out how many pixels width/height it is.

I then use the 2 figures to derive a couple of conversion functions.

It might provide more precise conversion number if you used an HTML element that was 100mm by 100mm. Or 1000x1000. I haven’t tried this to confirm it, but that is what I would expect.

Thanks, will try a little experimentation :smile:

so far 1mm by 1mm has worked fine for us