HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
//create data
4
var data = [
5
{x: "A", value: 100},
6
{x: "B", value: 100},
7
{x: "C", value: 100},
8
{x: ["A", "B"], value: 20, custom_field: "info 1"},
9
{x: ["A", "C"], value: 20, custom_field: "info 2"},
10
{x: ["B", "C"], value: 20, custom_field: "info 3"},
11
{x: ["A", "B", "C"], value: 20, custom_field: "info 4"}
12
];
13
14
// create a chart and set the data
15
chart = anychart.venn(data);
16
17
// configure labels of intersections
18
chart.intersections().labels().format(function() {
19
if (this.x.length > 2)
20
return this.x;
21
});
22
23
// configure tooltips of intersections
24
chart.intersections().tooltip().format(function() {
25
return "Value: " + this.value + "\n(" +
26
this.x.length + " sets intersecting)\n\n" +
27
this.getData("custom_field");
28
});
29
30
// set the chart title
31
chart.title("Venn Diagram: Labels and Tooltips (Formatting Functions)");
32
33
// set the container id
34
chart.container('container');
35
36
// initiate drawing the chart
37
chart.draw();
38
});