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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:22:21+00:00 2026-05-30T16:22:21+00:00

Hi I need to create a flot graph. for that I am using this

  • 0

Hi I need to create a flot graph. for that I am using this plugin http://people.iola.dk/olau/flot/API.txt.

I need to show time (h:m) on x axis and counts on y axis. For that I written this kind of a script. But its not working. Any body can help me please.

var running = false;
var array;
var xscale = 10;

//this function does the plotting 
function draw() {
    var timearr = getTimeArray();
    this.array=timearr;
    var sTime ="";
    var oDate = new Date();
    var sTimestamp ="";
    var exparr = "";
    for (var l = 0; l < 10; l++) {
        sTime = this.array[l][1];
        oDate.setUTCHours(
            parseInt(sTime.substr(0, 2), 10),
            parseInt(sTime.substr(3, 2), 10),
            0,
            0
        );
        sTimestamp = oDate.getTime();
        this.array[l]=[parseInt(l),parseInt(sTimestamp)];
    }
    $.plot(
        $("#graphdiv"),[
            {
                label: "Logged In",
                data: this.array,
                lines: { show: true, fill: true, fillColor: "rgba(249, 28, 61,0.3)",lineWidth: 2.5 },
                //color:"rgba(249, 28, 61, 1)"
                color:0
            }         
        ],
        {
        xaxis: {
            ticks: getTimeArray(1),
            mode: "time",
            timeformat: "%H:%M"

        },
        yaxis: {
            ticks: [0 , 1, 2, 3,4,5, 6,7,8,9,10],
            min: 0,
            tickDecimals: 0
        },            
        grid: {
            show: true,
            color: '#474747',
            tickColor: '#474747',
            borderWidth: 2,
            autoHighlight: true,
            mouseActiveRadius: 2
        }
    });
}

function getTimeArray(flg)
{
    array = [];
    var d = new Date();
    var hour='';
    var minute='';
    var timeString ='';

    for (var i = 9; i >= 0; i--){
        if(i<9)d = new Date( d.getTime() - 5*60*1000 );
        hour   = d.getHours();
        minute = d.getMinutes();
        if (hour   > 12) { hour = hour - 12;      }
        if (hour   == 0) { hour = 12;             }
        if (hour   < 10) { hour   = "0" + hour;   }
        if (minute < 10) { minute = "0" + minute; }
        timeString = hour + ':' + minute;
        if(timeString!=undefined){
            array[i]=[i,timeString];
        }
    }
    return array;
} 


function initialize() {
    this.array = new Array();
    for (var i = 0; i < xscale; i++) {
        this.array[i] = [i, 0.0];
    }
}

function refreshStat() {
    if (!running) {
        running = true;
        draw();
        running = false;
    }
}

$(document).ready(function () {
    initialize();
    refreshStat();
    setInterval("refreshStat()", 10);
});
  • 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-30T16:22:22+00:00Added an answer on May 30, 2026 at 4:22 pm

    You have mistaken how flot deals with xaxis mode “time”. What it wants is x values that are integers representing javascript timestamps. It then takes care of the formatting to %H:%M.

    So you’ve got some convoluted code there to make values in %H:%M and then convert them to timestamps and pass them into flot, but then also specify which ticks to show. Instead, you can just generate the timestamps you want, put them into your data array like this:

    [[1329930943084,0],
     [1329931043084,1],
     ...
     [<timestamp>  ,10]]
    

    And that’s it, just feed that into flot, no need to define the ticks on either x or y axis.

    Further, your setInterval throws an error, which may have been why you weren’t getting anywhere. You can make that more like this:

    setInterval(refreshStat, 10);
    

    Here is a super-simplified version of your code: http://jsfiddle.net/ryleyb/MaJgn/

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

Sidebar

Related Questions

I need to create an XML schema that looks something like this: <xs:element name=wrapperElement>
I am using flot to create bar charts like I need to specify a
I am using Flot to create graphs. This is my Code here jsFiddle code
I'm using jqgrid and i need to update a graph (jquery flot) based on
I'm using jQuery.flot to create custom charts in my project, but I need invert
I need to create a dynamic dataseries for flot graph. My x-axis is time
I am using this API to create an online image gallery for my application
Need to create a custom DNS name server using C which will check against
I need to create a backup of a SQL Server 2005 Database that's only
I to need create a programmatic equivalent using delphi language... or could someone post

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.