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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:37:28+00:00 2026-05-27T15:37:28+00:00

I encountered a new problem regarding my x-axis. My intention was to output a

  • 0

I encountered a new problem regarding my x-axis. My intention was to output a x-axis which indicates the time, while the y axis indicates the power. I decided to use time[i] and using graph.push([time[i], power[i]). However,my graph remains empty. I did an alert to output function and this was the result I got:

({1:"14:36", 2:"14:39", 3:"14:42", 4:"14:45", 5:"14:48", 6:"14:51", 7:"14:54", 8:"14:57"})

It’s in hour: mins. What should I change to obtain a time X-axis?

$(function () {
var graph = [];
var power = <?php echo json_encode($data);?>;
var time = <?php echo json_encode($times);?>;
var row = <?php echo json_encode($nrow);?>;
//alert(time.toSource());


for (var i = 1; i < row; i += 1) {

    //var test = time[i];
    //alert(test);
    graph.push([time[i], power[i]]);

}

var plot = $.plot($("#placeholder"),
       [ { data: graph, label: "Power" } ], {
           series: {
               lines: { show: true },
               points: { show: true }
           },
           grid: { hoverable: true, clickable: true },
           yaxis: { min: 0, max: 25 }


         });
  • 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-05-27T15:37:29+00:00Added an answer on May 27, 2026 at 3:37 pm

    You have to convert time from hour:mins to number

    for (var i = 1; i < row; i += 1) {
    
        //var test = time[i];
        //alert(test);
    
        var hhmm = time[i].split(":");
    
        var hh = parseInt(hhmm[0]);
        var mm = parseInt(hhmm[1])/60;
        var tt = hh + mm;
    
        graph.push([tt, power[i]]);
    
    }
    

    EDIT ( Eugene Wong) :

    //var options = {
    // xaxis: { ticks:[[1,time[1]],[2,time[2]],[3,time[3]],[4,time[4]],[5,time[5]],[6,time[6]],[7,time[7]],[8,time[8]]]}
    //};
    //alert(options.toSource());

    var plot = $.plot($("#placeholder"), 
           [ { data: graph, label: "Power" } ], {
               series: {
                   lines: { show: true },
                   points: { show: true }
               },
               grid: { hoverable: true, clickable: true },
               yaxis: { min: 0, max: 25 },
               xaxis: { mode: "time", timeformat:"%hh:%mm" }
               //xaxis: { ticks:[[1,time[1]],[2,time[2]],[3,time[3]],[4,time[4]],[5,time[5]],[6,time[6]],[7,time[7]],[8,time[8]]]}
    
    
           });
    

    EDIT(Diode):

    Even though I have created time charts before, this time setting x-axis configuration didn’t work. Anyway I have fixed this by adding a tick formatter function. See the code below. ‘graph’ is the sample data array I used.

        var graph = [[14.5, 10], [16.45, 15], [18.45, 20]];
    
    
        var plot = $.plot($("#placeholder"),
           [ { data: graph, label: "Power" } ], {
               series: {
                   lines: { show: true },
                   points: { show: true }
               },
               grid: { hoverable: true, clickable: true },
               yaxis: { min: 0, max: 25 },
               xaxis: {
                            min:14,
                            max:20,
                            tickSize:0.5,
                            tickFormatter: function(value){
                                var hours = Math.floor(value);
                                hours = (hours < 10)?"0"+hours:hours;
                                var minutes = (value - hours) * 60;
                                minutes = (minutes < 10)?"0"+minutes:minutes;
                                return hours + ":" + minutes;
                            }
                         }
    
    
    
             });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've encountered an curious problem while trying to use some objects through JSNI in
I'm new with Appcelerator and I encountered an annoying problem regarding layout. I have
I've just encountered a very annoying problem while deploying new updates to my website.
I'm new to working with XML, and I've encountered a weird problem while trying
I am confronted with a new kind of problem which I haven't encountered yet
I'm new here and kinda new to java. I've encountered a problem. I have
I am new to g++ and lapack, and attempting to use them. I encountered
Encountered a frustrating problem in our application today which came down to an ArrayIndexOutOfBounds
I'm new to Spring and I encountered a small problem: the web application runs
I'm new to hive and I have encountered a problem, I have a table

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.