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 8429119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:14:45+00:00 2026-06-10T05:14:45+00:00

I am using jqPlot with DateAxisRenderer to display graphs of various functions of time.

  • 0

I am using jqPlot with DateAxisRenderer to display graphs of various functions of time. I want to make the graph communicate with other modules of the application, that also deal with time data (but not with graphs). To accomplish this, all modules will write and read the same time variable (so they always display data for the same instant). If any module sets the variable, the others have to react accordingly.

Example: User enters time in a readable format, what causes a custom tick to be displayed in the graph on the proper x coordinate.

However, to implement this, I need to convert between three representations of time

  • any human-readable format (or the javascript Date object as its encapsulation)
  • the timestamp used internally by jqPlot to represent time
  • x coordinate (in pixels) in the graph

I know that DateAxisRenderer can display the timestamp in a customizable human-readable format, as it does so when it renders the x-axis. I know that after clicking in the graph, I get the timestamp in the event information (together with the x coordinate). But my question is: How to do these conversions explicitly?.

  • 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-10T05:14:46+00:00Added an answer on June 10, 2026 at 5:14 am

    Date <–> human-readable formats

    Datejs works well for this. For example:

    var date = Date.parse('February 20th 1973');
    var date = Date.parse('next thursday');
    
    // Now let's convert a date into a human-readable string
    var dateString = date.toString('dddd, MMMM d, yyyy');
    

    Date <–> jqPlot timestamp

    The timestamp used internally in jqPlot is simply the Unix time in milliseconds:

    var exampleTimestamp = 1345671839000;
    var date = new Date(exampleTimestamp);
    
    // Now let's convert a date into a timestamp
    var jqPlotTimestamp = date.getTime();
    

    Date <–> x coordinate (in pixels)

    Assuming your x-axis is linear you can determine the value of a point on the x-axis like this (fill in your own values):

    var myPlot = jqplot(...);
    var xAxis = myPlot.axes.xaxis;
    
    var MARGIN_LEFT = 15; // Pixels from [left edge of chart --> minimum X value]
    
    var pixelRange = 300; // Pixels from [min X value --> max X value]
    var timeRange = xAxis.max - xAxis.min;
    
    var time; // This will be our answer in the chart's units
    time = xAxis.min + timeRange * (xCoordinate - MARGIN_LEFT) / pixelRange;
    
    var timeInMillis = ... ; // Convert the X-Axis unit of time into millis
    var date = new Date(timeInMillis);
    
    // Now let's convert a date into an x coordinate
    timeInMillis = date.getTime();
    time = ...; // Convert millis into X-Axis unit of time
    var x = MARGIN_LEFT + pixelRange * (time - xAxis.min) / timeRange;
    

    At the time of writing this post, here is a list of the axis names:

    ['yMidAxis', 'xaxis', 'yaxis', 'x2axis', 'y2axis', 'y3axis', 'y4axis', 'y5axis', 'y6axis', 'y7axis', 'y8axis', 'y9axis'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using JQPlot to graph usage over time of an application. Currently I
i'm using jqplot 1.0.0b1_r746. i want to display some time periods using the date
I'm using jqplot for displaying bar chart and pie chart. I want to display
I'm using jqPlot to make a simple graph: Their documentation states that it's very
Hi I'm using jqPlot to plot a graph over time. I'm also using the
How can I re-set ticks's formatString after a zoom operation? I'm using $.jqplot.DateAxisRenderer plugin
I'm (trying to) using JSON with PHP. I want to plot a graph using
I am using jqplot to plot line graphs with dates in x axis ..
I hope this doesn't seem too opaque: I'm using jqPlot to make a bar
I tried to plot data useage per day using jqPlot along with its DateAxisRenderer

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.