HTMLcopy
1
<script src="https://cdn.anychart.com/releases/8.9.0/js/anychart-core.min.js"></script>
2
<script src="https://cdn.anychart.com/releases/8.9.0/js/anychart-venn.min.js"></script>
3
<script src="https://cdn.anychart.com/releases/8.9.0/themes/pastel.min.js"></script>
4
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital@0;1&display=swap" rel="stylesheet">
5
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 100%;
5
height: 100%;
6
margin: 0;
7
padding: 0;
8
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
// set chart theme
3
anychart.theme("pastel");
4
5
var data = [
6
{
7
x: "A",
8
value: 100,
9
name: "TIME\n Can be quickly made",
10
tooltipTitle: "TIME\n Can be quickly made",
11
normal: { fill: "#8ecafb 0.7" },
12
hovered: { fill: "#8ecafb 1" },
13
selected: { fill: "#8ecafb 1" }
14
},
15
{
16
x: "B",
17
value: 100,
18
name: "INGREDIENTS \n Key elements available",
19
tooltipTitle: "INGREDIENTS \n Key elements available",
20
normal: { fill: "#ffeaa6 0.7" },
21
hovered: { fill: "#ffeaa6 1" },
22
selected: { fill: "#ffeaa6 1" }
23
},
24
{
25
x: "C",
26
value: 100,
27
name: "COMPLEXITY\n Manageable level",
28
tooltipTitle: "COMPLEXITY\n Manageable level",
29
normal: { fill: "#ee957f 0.7" },
30
hovered: { fill: "#ee957f 1" },
31
selected: { fill: "#ee957f 1" }
32
},
33
{
34
x: ["A", "C"],
35
value: 20,
36
name: "Add to\n wishlist",
37
tooltipTitle: "Add to wishlist",
38
tooltipDesc: "Add the ingredients in the next shopping list",
39
normal: { fill: "#a98caf 0.6" },
40
hovered: { fill: "#a98caf 1" },
41
selected: { fill: "#a98caf 1" },
42
hatchFill: {
43
type: "weave",
44
color: "#8b6b92"
45
}
46
},
47
{
48
x: ["A", "B"],
49
value: 20,
50
name: "Possibility \nof disaster",
51
tooltipTitle: "Possibility of disaster",
52
tooltipDesc: "Keep a backup ready",
53
normal: { fill: "#9fdebe 0.8" },
54
hovered: { fill: "#9fdebe 1" },
55
selected: { fill: "#9fdebe 1" },
56
hatchFill: {
57
type: "weave",
58
color: "#83c3a3"
59
}
60
},
61
{
62
x: ["B", "C"],
63
value: 20,
64
name: "Try on a\n holiday",
65
tooltipTitle: "Try on a holiday",
66
tooltipDesc: "When there is no other work pending",
67
normal: { fill: "#f5b57c 0.8" },
68
hovered: { fill: "#f5b57c 1" },
69
selected: { fill: "#f5b57c 1" },
70
hatchFill: {
71
type: "weave",
72
color: "#d09259"
73
}
74
},
75
{
76
x: ["A", "B", "C"],
77
value: 30,
78
name: "The Perfect\n Recipe",
79
tooltipTitle: "The Perfect Recipe",
80
tooltipDesc:
81
"Easy to follow and fast to cook with whatever is in the kitchen",
82
label: { enabled: true, fontStyle: "normal" },
83
normal: { fill: "#8392ab 0.9" },
84
hovered: { fill: "#8392ab 1" },
85
selected: { fill: "#8392ab 1" },
86
hatchFill: {
87
type: "percent40",
88
color: "#5f6b7d"
89
}
90
}
91
];
92
93
// create venn diagram
94
var chart = anychart.venn(data);
95
96
// set chart title
97
chart
98
.title()
99
.enabled(true)
100
.fontFamily("Roboto, sans-serif")
101
.fontSize(24)
102
.padding({ bottom: 25 })
103
.text("The perfect recipe to try while working from home");
104
105
// set chart stroke
106
chart.stroke("1 #fff");
107
108
// set labels settings
109
chart
110
.labels()
111
.fontSize(14)
112
.fontColor("#5e6469")
113
.hAlign("center")
114
.vAlign("center")
115
.fontFamily("Roboto, sans-serif")
116
.fontWeight("500")
117
.format("{%Name}");
118
119
// set intersections labels settings
120
chart
121
.intersections()
122
.labels()
123
.fontStyle("italic")
124
.fontColor("#fff")
125
.format("{%Name}");
126
127
// disable legend
128
chart.legend(false);
129
130
// set tooltip settings
131
chart
132
.tooltip()
133
.titleFormat("{%tooltipTitle}")
134
.format("{%tooltipDesc}")
135
.background()
136
.fill("#000 0.5");
137
138
// set container id for the chart
139
chart.container("container");
140
141
// initiate chart drawing
142
chart.draw();
143
});