I am trying to implement a bar chart like diagram. I have the following html element
<rect x="35" y="-135" width="10" height="51" style="stroke: rgb(255, 255, 255); opacity: 0.8; fill: rgb(255, 122, 0);"></rect>
I want to give the top corner of the rectangle a rounded shape.
How is it possible?
I am not able to apply border-radius property.
You may use
clipPath
too. It's a kind of an hack but it may be easier to implement.Assuming the follow:
width="10"
height="51"
rx="5"
andry="5"
Some Notes:
So, the clip with is exactly the same as you
rect
because you want the corner radius on top and theclipPath
is exactlyrect.height
+desired-corner-radius
.In that way you won't touch the bottom part of your rect with the
clipPath
.As commented by Robert Longson you need to convert your rect element to a path element to control the rounded corners.
In the following example, I used a cubic bezier curve with the
Q
command to make the top left rounded corner (Q1 1 5 1
in thed
attribute):Use the
<path>
element with thearc
command (http://devdocs.io/svg/attribute/d#arcto).Syntax:
a rx,ry x-axis-rotation large-arc-flag sweep-flag dx,dy