I have a Ruby on Rails application that utilizes highcharts. I am currently working on enhancing it to display the amount of time spent on specific projects. To demonstrate what I am trying to achieve, I have created a JSFiddle example which can be found here. My initial goals are as follows:
- The user logs in to their timesheet, selects one or multiple projects, and enters the hours spent
- The entered data regarding hours and selected project(s) are then stored in a ProjectsHours table
- The current user can later view the project hours page, where the information from the ProjectsHours table is extracted and displayed similarly to the provided JSFiddle example
Upon conducting my research, I discovered on the Highcharts website that data can be requested through an Ajax request.
I am reaching out with this question because I am still relatively new to Ruby on Rails and JavaScript.
Furthermore, I have implemented an autocomplete feature using an Ajax request and JSON data retrieval. While slightly unrelated, I am sharing the following JavaScript code for my autocomplete function as I believe it could have similarities to what I am attempting to accomplish. Any corrections or guidance would be greatly appreciated.
Autocomplete
Application.js
function log(message) {
$( "<div>" ).text( message ).prependTo("#log");
}
$("#tags1").autocomplete({
minLength: 2,
source: function(request, response) {
$.ajax({
url: "/positionlist",
dataType: "json",
data: {
style: "full",
maxRows: 12,
term: request.term
},
success: function(data) {
var results = [];
$.each(data, function(i, item) {
var itemToAdd = {
value: item,
label: item
};
results.push(itemToAdd);
});
return response(results);
}
});
}
});