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
// data and fill color settings
4
var data = [
5
{x: "earth", value: 1, palette: anychart.palettes.earth},
6
{x: "monochrome", value: 1, palette: anychart.palettes.monochrome},
7
{x: "provence", value: 1, palette: anychart.palettes.provence},
8
{x: "morning", value: 1, palette: anychart.palettes.morning},
9
{x: "coffee", value: 1, palette: anychart.palettes.coffee},
10
{x: "wines", value: 1, palette: anychart.palettes.wines},
11
{x: "pastel", value: 1, palette: anychart.palettes.pastel},
12
{x: "blue", value: 1, palette: anychart.palettes.blue},
13
{x: "glamour", value: 1, palette: anychart.palettes.glamour},
14
{x: "sea", value: 1, palette: anychart.palettes.sea},
15
{x: "default", value: 1, palette: anychart.palettes.defaultPalette}
16
];
17
18
// chart type
19
var chart = anychart.funnel(data);
20
21
chart.title("Palettes Switch Sample - Click bars to change palette");
22
chart.neckWidth("60%");
23
chart.baseWidth("60%");
24
chart.legend().position("center-bottom");
25
chart.legend().itemsLayout("horizontal");
26
chart.overlapMode("allow-overlap");
27
chart.selected().labels().background().stroke("black");
28
29
// switch palette on click and update title
30
chart.listen("pointMouseDown",function(e){
31
chart.title(e.point.get("x"));
32
chart.palette(e.point.get("palette"));
33
});
34
35
// draw
36
chart.container("container");
37
chart.draw();
38
});