<!DOCTYPE html>
<
html
>
<
head
>
<
meta
charset
=
"utf-8"
>
<
script
src
=
</
script
>
</
head
>
<
body
>
<
h1
style
=
"text-align: center; color: green;"
>
GeeksforGeeks
</
h1
>
<
h3
style
=
"text-align: center;"
>
D3.js | area.context() Method
</
h3
>
<
center
>
<
canvas
id
=
"gfg"
width
=
"200"
height
=
"200"
>
</
canvas
>
</
center
>
<
script
>
var data = [
{xpoint: 25, ypoint: 150},
{xpoint: 75, ypoint: 50},
{xpoint: 100, ypoint: 150},
{xpoint: 100, ypoint: 50},
{xpoint: 200, ypoint: 150}];
var context = d3.select("#gfg")
.node().getContext("2d");
var Gen = d3.area()
.x((p) => p.xpoint)
.y0((p) => p.ypoint/2)
.y1((p) => p.ypoint)
.context(context);
context.translate(10,50);
Gen(data);
context.strokeStyle = "black";
context.fillStyle = "green";
context.fill();
context.stroke();
</
script
>
</
body
>
</
html
>