-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphController.js
More file actions
74 lines (71 loc) · 1.86 KB
/
GraphController.js
File metadata and controls
74 lines (71 loc) · 1.86 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
class GraphController {
constructor () {
this.geracao = 0
this.colorNames = ['rgb(255, 99, 132)', 'rgb(255, 159, 64)', 'rgb(255, 205, 86)', 'rgb(75, 192, 192)', 'rgb(54, 162, 235)', 'rgb(153, 102, 255)']
this.config = {
type: 'line',
data: {
labels: [],
datasets: [{
label: 'Melhor Individuo da Geração',
backgroundColor: this.colorNames[3],
borderColor: this.colorNames[3],
data: [
],
fill: false
},
{
label: 'Pior Individuo da Geração',
backgroundColor: this.colorNames[0],
borderColor: this.colorNames[0],
data: [
],
fill: false
}]
},
options: {
responsive: true,
title: {
display: true,
text: 'Population History'
},
tooltips: {
mode: 'index',
intersect: false
},
hover: {
mode: 'nearest',
intersect: true
},
scales: {
xAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'Generation'
}
}],
yAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'Path Cost'
}
}]
}
}
}
}
addToGraph (populacao) {
var element = populacao.individuos
element.sort(function (a, b) { return a.coincidence - b.coincidence })
this.config.data.labels.push(this.geracao)
this.geracao++
this.config.data.datasets[0].data.push(element[0].coincidence)
this.config.data.datasets[1].data.push(element[element.length - 1].coincidence)
}
drawChart (divId) {
var ctx = $(divId).get(0).getContext('2d')
window.myDoughnut = new Chart(ctx, this.config)
}
}