# JavaScript How to Make a bar chart with rounded corners with extended grid in d3.js? [duplicate] make chart with excel,make chart with two y-axis,

This question already has answers here:
Answer:1

One option is to use a clip path, but you can also create a simple path generator using the same information you use to build the rectangles: x,y,width,height, plus radius. The path is fairly simple:

1. Move to bottom left corner
2. Line to bottom of top left arc
3. Arc to top of top left arc
4. Line to the top of the top right arc
5. Arc to the bottom of the top right arc.
6. Line to the bottom right corner
7. Close path.

Which is comes together something like:

1. M x,y
2. L x,y-height+radius
3. A radius,radius,0,0,1,x+radius,y-height
4. L x+width-r,y-height
5. A radius,radius,0,0,1,x+width,y-height+radius
6. L x+width,y
7. Z

Which could look like this (a rather lazy implementation):

``````function bar(x,y,w,h,r,f) {
// Flag for sweep:
if(f == undefined) f = 1;
// x coordinates of top of arcs
var x0 = x+r;
var x1 = x+w-r;
// y coordinates of bottom of arcs
var y0 = y-h+r;

// assemble path:
var parts = [
"M",x,y,               // step 1
"L",x,y0,              // step 2
"A",r,r,0,0,f,x0,y-h,  // step 3
"L",x1,y-h,            // step 4
"A",r,r,0,0,f,x+w,y0,  // step 5
"L",x+w,y,             // step 6
"Z"                    // step 7
];
return parts.join(" ");
}
``````

I've included an optional sweep flag (`f`) - it'll invert the arcs if set to 0.

And applied something like so:

`````` .attr("d", function(d) {
return bar(x(d),y(0),x.bandwidth(),y(0)-y(d),15);
})
``````

Put together you might get something like:

``````var width = 500;
var height = 200;
var svg = d3.select("body").append("svg").attr("width",width).attr("height",height);
var data = [ 10,20,30,40,20,50,60 ];

var x = d3.scaleBand().domain(d3.range(data.length)).range([10,width-10]).paddingInner(0.1);
var y = d3.scaleLinear().domain([0,60]).range([height-10,10]);

var bars = svg.selectAll(null)
.data(data)
.enter()
.append("path")
.attr("d", function(d,i) {
return bar(x(i),y(0),x.bandwidth(),y(0)-y(d),10);
})

function bar(x,y,w,h,r,f) {
// Flag for sweep:
if(f == undefined) f = 1;

// x coordinates of top of arcs
var x0 = x+r;
var x1 = x+w-r;
// y coordinates of bottom of arcs
var y0 = y-h+r;
// just for convenience (slightly different than above):
var l = "L", a = "A";

var parts = ["M",x,y,l,x,y0,a,r,r,0,0,f,x0,y-h,l,x1,y-h,a,r,r,0,0,f,x+w,y0,l,x+w,y,"Z"];
return parts.join(" ");
}

// Still transitionable:
bars.data(data.reverse())
.transition()
.attr("d", function(d,i) {
return bar(x(i),y(0),x.bandwidth(),y(0)-y(d),30);
})
.duration(2000)
.transition()
.attr("d", function(d,i) {
return bar(x(i),y(0),x.bandwidth(),y(0)-y(d),0);
})
.duration(2000)
.transition()
.attr("d", function(d,i) {
return bar(x(i),y(0),x.bandwidth(),y(0)-y(d),15);
})
.duration(2000);``````
``<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.10.0/d3.min.js"></script>``
Answer:2

## Lagging Javascript Card Game

I’m trying to make a card game in javascript. I want the user to see the front of a card when clicking the button ”clicky” and then the back of the same card when clicking again. On the click after ...

I’m trying to make a card game in javascript. I want the user to see the front of a card when clicking the button ”clicky” and then the back of the same card when clicking again. On the click after ...

## React - Checkbox select all

I've got a list of items, each with their own checkboxes and I've decided to try add a 'select all' checkbox to make it easier for the user to select them all at once. Unfortunately I'm finding it ...

I've got a list of items, each with their own checkboxes and I've decided to try add a 'select all' checkbox to make it easier for the user to select them all at once. Unfortunately I'm finding it ...

1. react checkbox select all
2. react checkbox select only one
3. react select checkbox example
4. react select checkbox dropdown
5. react checkbox checked
6. react checkbox checked attribute
7. react checkbox checked not working
8. react checkbox checked state
9. react checkbox checked value
10. react checkbox checked not updating
11. react checkbox checked event
12. react checkbox checked onchange
13. react checkbox checked by default
14. react checkbox checked and unchecked
15. react checkbox checked function
16. react checkbox checked array
17. react checkbox checked change
18. react checkbox checked property
19. react checkbox checked css
20. react checkbox checked or not

## How to remove word with extra delimiter from given string?

I have following string. var str = "abc, abcd, abc, abcf, abc, abc"; I want to remove abc from a given string with , (space). Basically, I want output something like below. var output = "abcd, abcf"...

I have following string. var str = "abc, abcd, abc, abcf, abc, abc"; I want to remove abc from a given string with , (space). Basically, I want output something like below. var output = "abcd, abcf"...

1. remove word with regex
2. remove word with sed
3. remove word from string python
4. remove word from string javascript
5. remove word from string php
6. remove word from string java
7. remove word from string c#
8. remove word from excel cell
9. remove word from string
10. remove word from list python
11. remove word in excel
12. remove word from string js
13. remove word from google search
14. remove word from iphone dictionary
15. remove word from dictionary chrome
16. remove word from autocorrect iphone
17. remove word from string jquery
18. remove word from autocorrect
19. remove word from string bash
20. remove word from dictionary

## Remove empty & null values from nested object (ES6) - Clean nested Objects

I got an object which looks like this : { "a": "string not empty", "b": { "c": "string not empty", }, "d": { "e": false, "f": 0, "g": true, ...

I got an object which looks like this : { "a": "string not empty", "b": { "c": "string not empty", }, "d": { "e": false, "f": 0, "g": true, ...

1