-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a7c4be1
Showing
7 changed files
with
927 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// HistogramModule.js | ||
var HistogramModule = function(bins, canvas_width, canvas_height) { | ||
// Create the elements | ||
|
||
// Create the tag: | ||
var canvas_tag = "<canvas width='" + canvas_width + "' height='" + canvas_height + "' "; | ||
canvas_tag += "style='border:1px dotted'></canvas>"; | ||
// Append it to body: | ||
var canvas = $(canvas_tag)[0]; | ||
$("#elements").append(canvas); | ||
// Create the context and the drawing controller: | ||
var context = canvas.getContext("2d"); | ||
|
||
// Prep the chart properties and series: | ||
var datasets = [{ | ||
label: "Distance of Stored food from nearest safe spot.", | ||
backgroundColor: ["rgba(0,129,255,0.5)"], | ||
borderColor: ["rgba(0,127,255,0.8)"], | ||
//backgroundFill: "rgba(0,127,255,0.75)", | ||
//highlightStroke: "rgba(0,127,255,1)", | ||
data: [] | ||
}]; | ||
|
||
// Add a zero value for each bin | ||
for (var i in bins) | ||
datasets[0].data.push(0); | ||
|
||
var data = { | ||
labels: bins, | ||
datasets: datasets | ||
}; | ||
|
||
var options = { | ||
scaleBeginsAtZero: true | ||
}; | ||
|
||
// Create the chart object | ||
var chart = new Chart(context,{'type': 'bar', 'data': data, 'options': options}); | ||
|
||
// Now what? | ||
this.render = function(data) { | ||
for (var i in data) | ||
chart.data.datasets[0].data[i] = data[i]; | ||
chart.update(); | ||
}; | ||
|
||
this.reset = function() { | ||
chart.destroy(); | ||
chart = new Chart(context,{'type': 'bar', 'data': data, 'options': options}); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// HistogramModule.js | ||
var HistogramModule = function(bins, canvas_width, canvas_height) { | ||
// Create the elements | ||
|
||
// Create the tag: | ||
var canvas_tag = "<canvas width='" + canvas_width + "' height='" + canvas_height + "' "; | ||
canvas_tag += "style='border:1px dotted'></canvas>"; | ||
// Append it to body: | ||
var canvas = $(canvas_tag)[0]; | ||
$("#elements").append(canvas); | ||
// Create the context and the drawing controller: | ||
var context = canvas.getContext("2d"); | ||
|
||
// Prep the chart properties and series: | ||
var datasets = [{ | ||
label: "Distance of directly eaten food from nearest safe spot.", | ||
fillColor: "rgba(0,127,255,0.5)", | ||
strokeColor: "rgba(0,127,255,0.8)", | ||
highlightFill: "rgba(0,127,255,0.75)", | ||
highlightStroke: "rgba(0,127,255,1)", | ||
data: [] | ||
}]; | ||
|
||
// Add a zero value for each bin | ||
for (var i in bins) | ||
datasets[0].data.push(0); | ||
|
||
var data = { | ||
labels: bins, | ||
datasets: datasets | ||
}; | ||
|
||
var options = { | ||
scaleBeginsAtZero: true | ||
}; | ||
|
||
// Create the chart object | ||
var chart = new Chart(context,{'type': 'bar', 'data': data, 'options': options}); | ||
|
||
// Now what? | ||
this.render = function(data) { | ||
for (var i in data) | ||
chart.data.datasets[0].data[i] = data[i]; | ||
chart.update(); | ||
}; | ||
|
||
this.reset = function() { | ||
chart.destroy(); | ||
chart = new Chart(context,{'type': 'bar', 'data': data, 'options': options}); | ||
}; | ||
}; |
Empty file.
Oops, something went wrong.