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
// create data set on our data
3
var dataSet = anychart.data.set([
4
['Q1: It was my first experience of<BR>using an app for dialogue',40.54,43.24,0,10.81,5.41],
5
['Q2: I enjoyed using talkwall in<BR>classroom',2.7,2.7,13.51,56.76,24.32],
6
['Q3: Talkwall made the learning<BR>process easy',2.7,32.43,27.03,29.73,8.11],
7
['Q4: More courses should be thought<BR>using talkwall',2.7,18.92,29.73,29.73,18.92],
8
['Q5: I believe I will remember the<BR>taught lessons better now',0,13.51,29.73,40.54,16.22],
9
['Q6: I did not have difficulty using the<BR>application',2.7,8.11,2.7,45.95,40.54],
10
['Q7: Talkwall is easy to use and<BR>require no special training for using it',0,2.7,5.41,45.95,45.95],
11
['Q8: After experience with talkwall I<BR>want all lessons to be dialogue based',5.41,21.62,18.92,32.43,21.62],
12
['Q9: I will share experience of what I<BR>have learnt with others',8.11,5.41,10.81,62.16,13.51]
13
14
]);
15
16
// map data for the first series, take x from the zero area and value from the first area of data set
17
var seriesData_1 = dataSet.mapAs({'x': 0, 'value': 1});
18
19
// map data for the second series, take x from the zero area and value from the second area of data set
20
var seriesData_2 = dataSet.mapAs({'x': 0, 'value': 2});
21
22
// map data for the second series, take x from the zero area and value from the third area of data set
23
var seriesData_3 = dataSet.mapAs({'x': 0, 'value': 3});
24
25
// map data for the fourth series, take x from the zero area and value from the fourth area of data set
26
var seriesData_4 = dataSet.mapAs({'x': 0, 'value': 4});
27
28
var seriesData_5 = dataSet.mapAs({'x': 0, 'value': 5});
29
30
// create bar chart
31
var chart = anychart.bar();
32
33
// turn on chart animation
34
chart.animation(true).barGroupsPadding(0.5);
35
36
// force chart to stack values by Y scale.
37
chart.yScale().stackMode('percent');
38
chart.labels().enabled(true).position("center-center").offsetX(30).offsetY(-15);
39
chart.labels().format('{%value}{decimalsCount:0}%').fontColor('white')
40
var crosshair = chart.crosshair();
41
// turn on the crosshair
42
crosshair.enabled(true)
43
.yStroke(null)
44
.xStroke('#fff')
45
.zIndex(99);
46
crosshair.yLabel().enabled(false);
47
crosshair.xLabel().enabled(false);
48
49
// set chart title text settings
50
chart.title('Feedback');
51
chart.title().padding([0, 0, 10, 0]);
52
53
// set yAxis labels formatting, force it to add % to values
54
chart.yAxis(0).labels().format("{%Value}%");
55
56
// helper function to setup label settings for all series
57
var setupSeries = function (series, name, color) {
58
series.name(name)
59
.stroke('1 #fff 1')
60
.fill(color);
61
};
62
63
// temp variable to store series instance
64
var series;
65
66
// create first series with mapped data
67
series = chart.bar(seriesData_5);
68
setupSeries(series, 'Strongly Agree', '#083D77 0.8');
69
70
// create second series with mapped data
71
series = chart.bar(seriesData_4);
72
setupSeries(series, 'Agree', '#59A9FF 0.8');
73
74
// create third series with mapped data
75
series = chart.bar(seriesData_3);
76
setupSeries(series, 'Neutral', '#7B8C96 0.5');
77
78
// create fourth series with mapped data
79
series = chart.bar(seriesData_2);
80
setupSeries(series, 'Disagree', '#EE964B 0.8');
81
82
// create fourth series with mapped data
83
series = chart.bar(seriesData_1);
84
setupSeries(series, 'Strongly Disagree' , '#D13B1D 0.8');
85
// set interactivity and toolitp settings
86
// chart.interactivity().hoverMode('by-x');
87
// chart.tooltip().displayMode('union');
88
89
// turn on legend
90
chart.legend()
91
.enabled(true)
92
.fontSize(13)
93
.padding([0, 0, 25, 0]);
94
95
// set container id for the chart
96
chart.container('container');
97
var axisLabels = chart.xAxis().labels();
98
axisLabels.useHtml(true);
99
axisLabels.format("<span style='color:black;'>{%value}</span>");
100
// initiate chart drawing
101
chart.draw();
102
});