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
var data = getData();
3
4
var chart = anychart.sunburst(data, 'as-table');
5
6
// Create palette.
7
var palette = anychart.palettes.distinctColors();
8
palette.items(['#90caf9', ['#e6ee9c', '#ffab91'], '#80cbc4', '#aed581', '#e6ee9c', '#ffcc80']);
9
10
// Set palette.
11
chart.palette(palette);
12
13
chart.title('Set palette using distinct colors');
14
chart.container('container');
15
chart.draw();
16
});
17
function getData() {
18
return [
19
{name: 'Seasonal activities', id: 'activities', parent: null, value: 1000},
20
{name: 'Winter', parent: 'activities', id: 'winter', value: 250},
21
{name: 'Spring', parent: 'activities', id: 'spring', value: 250},
22
{name: 'Summer', parent: 'activities', id: 'summer', value: 250},
23
{name: 'Autumn', parent: 'activities', id: 'autumn', value: 250},
24
{name: 'Running', parent: 'winter', id: 'run', value: 43},
25
{name: 'Snowboarding', parent: 'winter', id: 'snowboard', value: 50},
26
{name: 'Nordic Skiing', parent: 'winter', id: 'nordic', value: 50},
27
{name: 'Working Out', parent: 'winter', id: 'workout', value: 30},
28
{name: 'Ice Skating', parent: 'winter', id: 'iceskate', value: 40},
29
{name: 'Kitesurfing', parent: 'winter', id: 'kitesurf', value: 37},
30
{name: 'Riding', parent: 'spring', id: 'ride', value: 100},
31
{name: 'Crossfit', parent: 'spring', id: 'crossfit', value: 30},
32
{name: 'Hiking', parent: 'spring', id: 'hike', value: 30},
33
{name: 'Yoga', parent: 'spring', id: 'yoga', value: 40},
34
{name: 'Running', parent: 'spring', id: 'run', value: 50},
35
{name: 'Riding', parent: 'summer', id: 'ride', value: 150},
36
{name: 'Windsurfing', parent: 'summer', id: 'windsurf', value: 20},
37
{name: 'Swimming', parent: 'summer', id: 'swim', value: 30},
38
{name: 'Roller Skiing', parent: 'summer', id: 'roller', value: 10},
39
{name: 'Rowing', parent: 'summer', id: 'rowing', value: 40},
40
{name: 'Riding', parent: 'autumn', id: 'ride', value: 90},
41
{name: 'Hiking', parent: 'autumn', id: 'windsurf', value: 20},
42
{name: 'Swimming', parent: 'autumn', id: 'swim', value: 10},
43
{name: 'Nordic Skiing', parent: 'autumn', id: 'nordic', value: 40},
44
{name: 'Climbing', parent: 'autumn', id: 'climbing', value: 40}
45
];
46
}