annotate = {
const annotations = [
{
subject: {
height: 900- margin,
width: 165
},
type: d3_annotation.annotationCalloutRect,
y: 0,
disable: ["connector"],
x: 530,
y: 0,
dy: 1,
dx: 1,
className: "show-bg",
data: {}
},
{
note: {
label:
"Basic settings with subject position(x,y) and a note offset(dx, dy)",
title: "d3.annotationLabel"
},
x: 50,
y: 150,
dy: 137,
dx: 162
},
{
note: {
label:
"Added connector end 'arrow', note wrap '180', and note align 'left'",
title: "d3.annotationLabel",
wrap: 150,
align: "left"
},
connector: {
end: "arrow"
},
x: 170,
y: 150,
dy: 137,
dx: 162
},
{
note: {
label: "Changed connector type to 'curve'",
title: "d3.annotationLabel",
wrap: 150
},
connector: {
end: "dot",
type: "curve",
points: [[100, 14], [190, 52]]
},
x: 350,
y: 150,
dy: 137,
dx: 262
},
{
type: d3_annotation.annotationCalloutCircle,
note: {
label: "A different annotation type",
title: "d3.annotationCalloutCircle",
wrap: 190
},
subject: {
radius: 50
},
x: 620,
y: 150,
dy: 137,
dx: 102
}
].map(function(d) {
d.color = "#E8336D";
return d;
});
const makeAnnotations = d3_annotation
.annotation()
.type(d3_annotation.annotationLabel)
.annotations(annotations);
d3.select("svg")
.append("g")
.attr("class", "annotation-group")
.call(makeAnnotations);
}