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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:53:53+00:00 2026-06-13T22:53:53+00:00

I am trying to add axis labels to my X axis with the date

  • 0

I am trying to add axis labels to my X axis with the date instead of just 1,2,3,4 etc. which it defaults to.

The date_time returned from the server also needs to be converted to a readable date/time.

Any help appreciated.

Code

<script type="text/javascript"> 

var chart;
var store;

require(["dojo/request/xhr",
    "dojo/json",
    "dojo/store/Memory",
    "dojo/store/Observable",
    "dojox/charting/StoreSeries",
    "dojox/charting/Chart2D", 
    "dojox/charting/plot2d/Lines", 
    "dojox/charting/axis2d/Default",    
    "dojo/domReady!"], 

    function(xhr, JSON, Memory, Observable, StoreSeries, Chart) {

    xhr("json_result.php",{
            handleAs: "json"
        }).then(function(data){ 

            store = Observable(new Memory({data: data}));

            chart = new Chart("graph");

            chart.addPlot("default", {type: "Lines", markers:true});

            chart.addAxis("x", {title:"Time", titleOrientation:"away"});
            chart.addAxis("y", {vertical: true, majorTick: false, title:"Load"});

            chart.addSeries("Load Cell 1", new StoreSeries(store, { query: { load_cell_id:0 }}, "kn"));
            chart.addSeries("Load Cell 2", new StoreSeries(store, { query: { load_cell_id:1 } }, "kn"));

            chart.render();
        });         
});


</script>

JSON Result

[{"date_time":1351280845,"load_cell_id":0,"kn":56.8},{"date_time":1351280845,"load_cell_id":1,"kn":45},{"date_time":1351367241,"load_cell_id":0,"kn":23.7},{"date_time":1351367241,"load_cell_id":1,"kn":34.9},{"date_time":1351417945,"load_cell_id":0,"kn":56.9},{"date_time":1351417945,"load_cell_id":1,"kn":67.8},{"date_time":1353914066,"load_cell_id":0,"kn":12.4},{"date_time":1353914066,"load_cell_id":1,"kn":19.43},{"date_time":1353992714,"load_cell_id":0,"kn":45.8},{"date_time":1353992714,"load_cell_id":1,"kn":40.8}]
  • 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-13T22:53:54+00:00Added an answer on June 13, 2026 at 10:53 pm

    Try following, its about controlling the indexes (major) and then formatting the data-date_time in a label generating function.

    ddl =>             "dojo/date/locale", require this
    
    chart.addAxis("x", {
        title: "Time",
        titleOrientation: "away",
        includeZero: true,
        //from: 0, to: (data.length -1),
        minorTicks: false,
        labelFunc: function(n){              
            // I am assuming that your timestamp needs to be multiplied by 1000. 
            var date = new Date(parseInt(data[n].date_time) * 1000);
            return ddl.format(date,  {
                selector: "date",
                datePattern: "dd MMMM"
            });
    
        }
    });
    

    The minor ticks will produce 0.1, 0.2 additions to the current major tick – and does not go well together with an array indice.

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

Sidebar

Related Questions

I'm trying to add some axis-labels to a graph which contains the Greek letter
I am trying to set date tick labels on x axis, only for given
I am trying to add arrows marking specific x coordinates below the x axis
So, I'm trying to add some labels to a graph, and I want to
I'm trying to add a web reference to an external Axis - generated web
I'm trying to go away from matlab and use python + matplotlib instead. However,
I'm trying to hide the axis labels on the first subplot at 211. I'd
I’m trying to add password digest WS-Security bits to web service calls from my
I'm trying to style and add another 2 x'axis to a Google area chart
I'm trying add data triggers to the default combobox style so each text item

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.