I am trying to get jquery-ui datepicker to work with highcharts so that a user can select a date an example being
A user selects 10th October to 25th October
In onSelect callback of datepickers, you should validate, if both #from and #to are selected (or provide sensible defaults if not) and at the end fire and xhr request to server to get new series of data.
onSelect: function( selectedDate ) {
var option = this.id == "from" ? "minDate" : "maxDate",
instance = $( this ).data( "datepicker" ),
date = $.datepicker.parseDate(
instance.settings.dateFormat || $.datepicker._defaults.dateFormat,
selectedDate,
instance.settings
);
dates.not( this ).datepicker( "option", option, date );
// validate if we have both dates and get new series from server
if ($(dates[0]).datepicker("getDate") &&
$(dates[1]).datepicker("getDate")) {
$.ajax({
type: 'POST',
url: '<%= user_projects_path(params[:user_id]) %>',
data: {"from": $(dates[0]).datepicker("getDate"), "to" : $(dates[1]).datepicker("getDate") },
success: function(data) {
// now we have new series of data to display in graph
// we remove the old one, add the new and redraw the chart
for(var i=0; i
Controller method under user_projects_path url needs to exists and return JSON formatted series data for given user_id of course. You can filter your series data before returning with params sent by jquery xhr request (from and to).
Quick and dirty solution but I hope you got the point...