SivaRajini
SivaRajini

Reputation: 7375

Clip-path and transform combination in svg

Please refer to the following clip-path in group.

<g id="container_svg_SeriesCollection" clip-path="url(#container_svg_ChartAreaClipRect)"><defs>
<clipPath id="container_svg_ChartAreaClipRect">
<rect id="container_svg_ChartAreaClipRect" x="128.8" y="20" width="651.2" height="415" fill="white" stroke-width="1" stroke="Gray"/>
</clipPath>
</defs>
<g id="container_svg_symbolGroup_0" transform="translate(128.8,435)" clip-path="url(#container_svg_ChartAreaClipRect)">
<circle id="container_svg_circlesymbol_3_0" cx="86.8" cy="-25.875" r="7.0710678118654755" fill="url(#container_svg_symbol0Gradient)" stroke-width="1" stroke="Gray"/><circle id="container_svg_circlesymbol_4_0" cx="108.5" cy="-155.25" r="7.0710678118654755" fill="url(#container_svg_symbol0Gradient)" stroke-width="1" stroke="Gray"/></g>
</g>
</g>

Group ID -> "container_svg_symbolGroup1_0 (I.e circle symbol) is not visible when I remove the clip-path is visible in chart.

What is the problem? Why transform and clip-path not working together in some cases?

How can I show circle symbol for above clip-path?

Upvotes: 3

Views: 2077

Answers (2)

SivaRajini
SivaRajini

Reputation: 7375

I found the solution my self. Please refer the below modified SVG.

<g id="container_svg_SeriesCollection" clip-path="url(#container_svg_ChartAreaClipRect)"><defs><clipPath id="container_svg_ChartAreaClipRect"><rect id="container_svg_ChartAreaClipRect" x="132" y="20" width="648" height="346" fill="white" stroke-width="1" stroke="Gray"></rect></clipPath></defs><defs><linearGradient id="container_svg_John0Gradient" x1="0%" y1="0%" x2="0%" y2="600%"><stop offset="0" stop-color="pink" stop-opacity="1"></stop><stop offset="0.5" stop-color="blue" stop-opacity="1"></stop></linearGradient></defs><g id="container_svg_SeriesGroup_0" transform="translate(132,366)" clip-path="url(#container_svg_SeriesGroup_0_ClipRect)"><path id="container_svg_John_0" fill="none" stroke-dasharray="" stroke-width="3" stroke="url(#container_svg_John0Gradient)" stroke-linecap="butt" stroke-linejoin="round" d="M 64.8 -51.9 L 194.4 -69.2 M 194.4 -69.2 L 324 -138.4 M 324 -138.4 L 453.59999999999997 -103.8 M 453.59999999999997 -103.8 L 583.2 -43.25 "></path><defs><clipPath id="container_svg_SeriesGroup_0_ClipRect"><rect id="container_svg_SeriesGroup_0_ClipRect" x="64.80000305175781" y="-138.39999389648438" width="528.4000244140625" height="105.14999389648438" fill="white" stroke-width="1" stroke="transparent"></rect></clipPath></defs></g><g id="container_svg_TextGroup_0" transform="translate(132,366)"><text id="container_svg_SeriesText0" x="64.8" y="-68.9" fill="black" font-size="12px" font-family="Times New Roman" font-style="Normal " text-anchor="center" dominant-baseline="top">700</text><text id="container_svg_SeriesText1" x="194.4" y="-86.2" fill="black" font-size="12px" font-family="Times New Roman" font-style="Normal " text-anchor="center" dominant-baseline="top">800</text><text id="container_svg_SeriesText2" x="324" y="-155.4" fill="black" font-size="12px" font-family="Times New Roman" font-style="Normal " text-anchor="center" dominant-baseline="top">1200</text><text id="container_svg_SeriesText3" x="453.59999999999997" y="-120.8" fill="black" font-size="12px" font-family="Times New Roman" font-style="Normal " text-anchor="center" dominant-baseline="top">1000</text><text id="container_svg_SeriesText4" x="583.2" y="-60.25" fill="black" font-size="12px" font-family="Times New Roman" font-style="Normal " text-anchor="center" dominant-baseline="top">650</text></g><g id="container_svg_symbolGroup_0" transform="translate(132,366)"><defs><linearGradient id="container_svg_symbol0Gradient" x1="0%" y1="0%" x2="0%" y2="600%"><stop offset="0" stop-color="yellow" stop-opacity="1"></stop><stop offset="0.5" stop-color="blue" stop-opacity="1"></stop></linearGradient></defs><circle id="container_svg_circlesymbol_0_0" cx="64.8" cy="-51.9" r="7.0710678118654755" fill="url(#container_svg_symbol0Gradient)" stroke-width="1" stroke="Gray"></circle><circle id="container_svg_circlesymbol_1_0" cx="194.4" cy="-69.2" r="7.0710678118654755" fill="url(#container_svg_symbol0Gradient)" stroke-width="1" stroke="Gray"></circle><circle id="container_svg_circlesymbol_2_0" cx="324" cy="-138.4" r="7.0710678118654755" fill="url(#container_svg_symbol0Gradient)" stroke-width="1" stroke="Gray"></circle><circle id="container_svg_circlesymbol_3_0" cx="453.59999999999997" cy="-103.8" r="7.0710678118654755" fill="url(#container_svg_symbol0Gradient)" stroke-width="1" stroke="Gray"></circle><circle id="container_svg_circlesymbol_4_0" cx="583.2" cy="-43.25" r="7.0710678118654755" fill="url(#container_svg_symbol0Gradient)" stroke-width="1" stroke="Gray"></circle></g></g>

The problem is multiple same clip paths used in parent group as well as child group.

I have modified the child group clip-path to some other clip-path and then its working fine.

so no need to set same clip-path to parent as well as children group. if you want to set clip-path for child group means the clip-path bounds will be smaller than parent clip-path.

Thanks,

Siva

Upvotes: 0

Chris
Chris

Reputation: 496

You have nested clip paths, reusing the same twice. Remove the inner clip path, and it works.

(Wrapped in an SVG document):

<svg version="1.1"
     baseProfile="full"
     xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:ev="http://www.w3.org/2001/xml-events">
    <g id="container_svg_SeriesCollection" clip-path="url(#container_svg_ChartAreaClipRect)">
        <defs>
            <clipPath id="container_svg_ChartAreaClipRect">
                <rect id="container_svg_ChartAreaClipRect" x="128.8" y="20" width="651.2" height="415" fill="white" stroke-width="1" stroke="Gray"/>
            </clipPath>
        </defs>
        <g id="container_svg_symbolGroup_0" transform="translate(128.8,435)">
            <circle id="container_svg_circlesymbol_3_0" cx="86.8" cy="-25.875" r="7.0710678118654755" fill="url(#container_svg_symbol0Gradient)" stroke-width="1" stroke="Gray"/>
            <circle id="container_svg_circlesymbol_4_0" cx="108.5" cy="-155.25" r="7.0710678118654755" fill="url(#container_svg_symbol0Gradient)" stroke-width="1" stroke="Gray"/>
        </g>
    </g>
</svg>

Also, I would remove id="container_svg_ChartAreaClipRect" from the rect inside the clipPath

Upvotes: 2

Related Questions