Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 在SVG中旋转文本_Xml_Svg_Rotation_Scale_Scaletransform - Fatal编程技术网

Xml 在SVG中旋转文本

Xml 在SVG中旋转文本,xml,svg,rotation,scale,scaletransform,Xml,Svg,Rotation,Scale,Scaletransform,我得到了一个带有svg的图表,看起来像 现在我想像这样旋转文本 我的SVG根目录如下 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" version="1.1" baseProfile="full" viewbox="-75 0 1075 800"

我得到了一个带有svg的图表,看起来像

现在我想像这样旋转文本

我的
SVG根目录如下

<svg xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:ev="http://www.w3.org/2001/xml-events"
    version="1.1" baseProfile="full"
    viewbox="-75 0 1075 800"
    transform="translate(0, 750) scale(1, -1)"
    width="1000" height="800">
</svg>

如果我尝试使用

<text x="-70" y="50%" stroke="blue" transform="rotate(90)">U [mV]</text>
U[mV]
文本消失了

U[mV]
什么也没发生


如何旋转第二张图片中显示的三个文本对象?谢谢。

以下内容现在适合我:

<svg xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:ev="http://www.w3.org/2001/xml-events"
    version="1.1" baseProfile="full"
    viewbox="-75 0 1075 800"
    width="1000" height="800">

    <g transform="translate(0, 750) scale(1, -1)"> <!-- hint from @altocumulus -->
        ...

        <g transform="translate(-75, 375) scale(1, -1) rotate(-90)">
            <!--
                translate(x, y) => create a new local coordination system
                with the point of origin at this point
            -->

            <text stroke="blue">U [mV]</text>
        </g>

        ...
    </g>
</svg>

...
U[mV]
...

无法100%确定发生了什么,但我怀疑它“旋转”到了错误的位置,文本最终会出现在不同的位置,可能是在您的第一个案例中的屏幕外。试着只旋转1,看看它是否有轻微的移动——这可能会给你一些确切的指示。svg中的
transform
属性不支持百分比值(现在),他们希望将来会这样做。小提琴可能很好,但你的问题很可能是由于坐标系翻转造成的,有几种方法可以解决这个问题。类似的问题也有一种解决方法,对你也应该有用。这尤其是在元素上使用旋转来寻址,该元素按一定百分比定位。如果您不必将
50%
作为相对值来定位,那么有更简单的解决方案。在这种情况下,请更具体一点,并提供更多的代码以获得一个好的答案。另一方面,尽管这与您的问题没有直接关系:您的
根元素中存在缺陷。根据,它不支持
转换
属性。尽管某些用户代理可能会正确地呈现它,但您可能应该插入一个
,并对其应用转换以完全符合规范。来自@altocumulus的
-Tag的提示很好(使用
-Tag应该也可以)。如果我也将其用于文本对象,我可以为该对象定义一个新的坐标系,并旋转到原点(这是我想要旋转的错误点,就像@Flynn1179 said中的注释一样)。
<svg xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:ev="http://www.w3.org/2001/xml-events"
    version="1.1" baseProfile="full"
    viewbox="-75 0 1075 800"
    width="1000" height="800">

    <g transform="translate(0, 750) scale(1, -1)"> <!-- hint from @altocumulus -->
        ...

        <g transform="translate(-75, 375) scale(1, -1) rotate(-90)">
            <!--
                translate(x, y) => create a new local coordination system
                with the point of origin at this point
            -->

            <text stroke="blue">U [mV]</text>
        </g>

        ...
    </g>
</svg>