forked from loiane/javascript-datastructures-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchart.js
37 lines (32 loc) · 1.12 KB
/
chart.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
google.load('visualization', '1.0', {'packages':['corechart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'n');
data.addColumn('number', 'O(1)');
data.addColumn('number', 'O(log n)');
data.addColumn('number', 'O(n)');
data.addColumn('number', 'O(n log n)');
data.addColumn('number', 'O(n^2)');
data.addColumn('number', 'O(2^n)');
for (var i = 0; i <= 30; i++) {
data.addRow([i+'', 1, Math.log(i), i, Math.log(i)*i, Math.pow(i,2), Math.pow(2,i)]);
}
var options = {'title':'Big O Notation Complexity Chart',
'width':700,
'height':600,
'backgroundColor':{stroke:'#CCC',strokeWidth:1},
'curveType':'function',
'hAxis':{
title:'Elements (n)',
showTextEvery:5
},
'vAxis':{
title:'Operations',
viewWindowMode:'explicit',
viewWindow:{min:0,max:450}
}
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}