-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample2.html
41 lines (36 loc) · 1.51 KB
/
sample2.html
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
38
39
40
41
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Graphs ChartJS - Sample 2</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.css" integrity="sha256-aa0xaJgmK/X74WM224KMQeNQC2xYKwlAt08oZqjeF0E=" crossorigin="anonymous" />
</head>
<body>
<canvas id="myChart"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js" integrity="sha256-Uv9BNBucvCPipKQ2NS9wYpJmi8DTOEfTA/nH2aoJALw=" crossorigin="anonymous"></script>
<script>
var ctx = document.getElementById('myChart');
$.getJSON('server/ibge_json_data.json', (r) => data = r)
.fail(() => {
alert('ajax request fail')
}).then(() => {
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: data.anos,
datasets: [
{
label: 'População',
data: data.populacao,
backgroundColor: 'rgba(14,72,100,0.5)'
}
]
}
});
});
</script>
</body>
</html>