Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8657911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:38:18+00:00 2026-06-12T15:38:18+00:00

I’m trying to combine the jquery datepicker with the jqplot plugin. Basically, I’m having

  • 0

I’m trying to combine the jquery datepicker with the jqplot plugin. Basically, I’m having the plot load with default values, then when a button is hit, I’m trying to have the plot redraw with new max and mins.

I’ve been reading through the documentation, and I can’t seem to find a clear answer to my question. Here is my code:

 $(document).ready(function(){



                            var ajaxDataRenderer = function(url, plot, options) {
                                var ret = null;
                                $.ajax({
                                    async: false,
                                    url: url,
                                    type: "GET",
                                    dataType:"json",
                                    data: {metricName: ""},
                                    success: function(data) {
                                        ret = data;
                                    },
                                    error:function (xhr, ajaxOptions, thrownError){
                                        alert(xhr.responseText);
                                    }    
                                });
                                return ret;
                            };

                            //var jsonurl = "/reports/reportData.json";
                            var jsonurl = "/tenant/metrics/get.json";

                            var currentTime = new Date()
                            var month = currentTime.getMonth() + 1;
                            var day = currentTime.getDate();
                            var year = currentTime.getFullYear();
                            var today = month + "-" + day + "-" + year;

                            var currentDatePlus = new Date(new Date().getTime() + 24 * 60 * 60 * 1000);
                            var dayPlus = currentDatePlus.getDate()
                            var monthPlus = currentDatePlus.getMonth() + 1
                            var yearPlus = currentDatePlus.getFullYear()
                            var tomorrow = monthPlus + "/" + dayPlus + "/" + yearPlus;


                            function getLastWeek(){
                                var today = new Date();
                                var lastWeek = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 7);
                                return lastWeek ;
                            }

                            var lastWeek = getLastWeek();
                            var lastWeekMonth = lastWeek.getMonth() + 1;
                            var lastWeekDay = lastWeek.getDate();
                            var lastWeekYear = lastWeek.getFullYear();

                            var lastWeekDisplay = lastWeekMonth + "/" + lastWeekDay + "/" + lastWeekYear;

                            var datepickerBegin = $("#datepicker_start").val();
                            var datepickerEnd = $("#datepicker_to").val();

                            $('#applyBtn').click( function() {
                                // Check to make sure the datepicker isn't empty
                            if ($("#datepicker_start").val() !== "" && $("#datepicker_to").val() !== "") {

                                var datepickerBegin = $("#datepicker_start").val();
                                var datepickerEnd = $("#datepicker_to").val();
                                alert(datepickerBegin);
                                alert(datepickerEnd);
                                //redraw the plot now.
                                plot2.reInitialize({});
                                plot2.redraw({});
                                //
                                alert('hasd')

                                }
                            })

                                if (datepickerBegin == "") {
                                    var startingDate = lastWeekDisplay;
                                } else {
                                    var startingDate = datepickerBegin;
                                }

                                if (datepickerEnd == "") {
                                    var endingDate = tomorrow;
                                } else {
                                    var endingDate = datepickerEnd;
                                }

                            //



                            var plot2 = $.jqplot('chart2', jsonurl,{
                                title: "",
                                dataRenderer: ajaxDataRenderer,
                                dataRendererOptions: {unusedOptionalUrl: jsonurl},
                                axes: {
                                    xaxis: {
                                        //'numberTicks' : 7,
                                        min: startingDate,
                                        max: endingDate,
                                        renderer:$.jqplot.DateAxisRenderer,
                                        rendererOptions:{tickRenderer:$.jqplot.CanvasAxisTickRenderer},
                                        tickInterval: '1 day',
                                        tickOptions:{formatString:'%#m/%#d/%Y'

                                        }
                                        //rendererOptions: {sdaTickInterval: [1, 'month']}

                                    },
                                    yaxis: {
                                        label: "MB",
                                        tickOptions:{formatString:'%d '},
                                        // Comment the next line out to allow negative values (and therefore rounded ones)
                                        min: 0
                                    }

                                },
                                highlighter: {
                                    show: true,
                                    sizeAdjust: 7.5
                                }
                            });


                        });

Can anyone out there help me? I may just be having a fundamental flaw in logic as well. Please help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:38:20+00:00Added an answer on June 12, 2026 at 3:38 pm

    Okay, so the answer, however ugly, is to just recreate the plot fully on the click event. This is how the code looks:

     $('#applyBtn').click( function() {
                                    // Check to make sure the datepicker isn't empty
                                if ($("#datepicker_start").val() !== "" && $("#datepicker_to").val() !== "") {
    
                                    var datepickerBegin = $("#datepicker_start").val();
                                    var datepickerEnd = $("#datepicker_to").val();
    
                                            //Recreate the plot
                                            var plot2 = $.jqplot('chart2', jsonurl,{
                                            title: "",
                                            dataRenderer: ajaxDataRenderer,
                                            dataRendererOptions: {unusedOptionalUrl: jsonurl},
                                            axes: {
                                                xaxis: {
                                                    //'numberTicks' : 7,
                                                    min: datepickerBegin,
                                                    max: datepickerEnd,
                                                    renderer:$.jqplot.DateAxisRenderer,
                                                    rendererOptions:{tickRenderer:$.jqplot.CanvasAxisTickRenderer},
                                                    tickInterval: '1 day',
                                                    tickOptions:{formatString:'%#m/%#d/%Y'
    
                                                    }
                                                    //rendererOptions: {sdaTickInterval: [1, 'month']}
    
                                                },
                                                yaxis: {
                                                    label: "MB",
                                                    tickOptions:{formatString:'%d '},
                                                    // Comment the next line out to allow negative values (and therefore rounded ones)
                                                    min: 0
                                                }
    
                                            },
                                            highlighter: {
                                                show: true,
                                                sizeAdjust: 7.5
                                            }
                                        });
                                    //redraw the plot now.
                                    //plot2.reInitialize({});
                                    plot2.replot({});
    
                                    }
                                })
    

    I couldn’t get any of the answers to work — however, if anyone has an opinions or solutions, please let me know!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to select an H1 element which is the second-child in its group
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.