The horizontal axis displays the hours from 12:00 to 12:55 instead of specific calendar dates

This script creates a highchart that includes 2 Y axes and 1 X axis:

$('#main_chart').highcharts({
      chart: {
          zoomType: 'xy'
      },
      title: {
          text: 'Overview'
      },
      xAxis: [{
          type: 'datetime'
      }],
      yAxis: [{ // Primary yAxis
          labels: {
              format: '${value}',
              style: {
                  color: Highcharts.getOptions().colors[1]
              }
          },
          title: {
              text: 'Y1',
              style: {
                  color: Highcharts.getOptions().colors[1]
              }
          }
      }, { // Secondary yAxis
          title: {
              text: 'Y2',
              style: {
                  color: Highcharts.getOptions().colors[0]
              }
          },
          labels: {
              style: {
                  color: Highcharts.getOptions().colors[0]
              }
          },
          opposite: true
      }],
      tooltip: {
          shared: true
      },
      legend: {
          layout: 'vertical',
          align: 'left',
          x: 120,
          verticalAlign: 'top',
          y: 100,
          floating: true,
          backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
      },
      scrollbar: {
        enabled: true
      },
      series: [{
          name: 'Y1',
          data: y1Data
      }
      ,{
          name: 'Y2',
          data: y2Data
      }
      ]        
  });

y1Data and y2Data refer to arrays containing nested arrays like

[[1426525200, 2], [1426611600, 0], [1426698000, 0]...]
where the first element represents a date. The dates are consecutive with a daily increment:

1 Mar 2015, 2 Mar 2015, 3 Mar 2015....

However, only the time from 12:00 to 12:55 is shown on the X-axis and nothing else:

I expect to see the dates from

1 Mar 2015, 2 Mar 2015, 3 Mar 2015.... EndDate
. Additionally, why is there a negative value of $20 displayed? There should not be any negative values in the dataset.

Answer №1

When defining data, it is important to either provide a timestamp in milliseconds (not seconds) or use the JavaScript Date object instead:

var y1Data = [[new Date(), 2], [1426611600000, 0], [Date.UTC(2010, 2, 1), 0]];

In response to your question about $-20, Highcharts utilizes its own algorithm to guess the most suitable axis minimums and maximums. If you are unsatisfied with the result, you can manually set it by using:

yAxis: {
   min: 0,
   ...
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Calling Ajax in JavaScript

Trying to fetch a value in JavaScript using an Ajax Call, The code being used is as follows: <script> var value = $.ajax({ type:"GET", url:"get_result.php", data:"{'abc':" + $abc + "}", }); alert(val ...

Explore within the attribute of a JSON

Here is the JSON structure: var parse = [ { "variation_id":"34", "attributes":{ "attribute_pa_rozmiar":"m" }, "image_src":"http://localhost/Fraise-WP/wp-content/uploads/2013/06/Jellyfish-300x300.jpg", "image_l ...

Implement dynamic configuration injection by allowing users to specify the name of a configuration file during runtime, instead of having it fixed in the code

In my development using webpack, I am exploring ways to make my application configurations more dynamic. Presently, the project is a create-react-app that has been ejected. For instance, when creating a local build in my package.json file, I include the f ...

In need of assistance with Ember data! Struggling to deserialize JSON into model

Here is the technology stack I'm currently using: Ember 1.10.0 Ember Data 1.0.0-beta.15 Within my application, I have defined a model as shown below: //models//acceptedtask.js import DS from "ember-data"; export default DS.Model.extend({ userAg ...

Change the display of the lightbox when clicked. Utilize Angular and JQuery for this functionality

Here is the code for a lightbox: <div id="light-box"> <div id="first"> ..... </div> //initially visible <div id="second"> ..... </div> //hidden - but displayed when button is clicked. </div> I want to add two button ...

Looking for giphy link within a v-for loop (Vue.js)

I am fetching a list of movie characters from my backend using axios and rendering them in Bootstrap cards. My objective is to search for the character's name on Giphy and use the obtained URL as the image source for each card. However, when I attemp ...

Passing a variable from JavaScript to PHP, utilizing the variable in an SQL query, and showcasing the results through PHP

I need to pass a JavaScript variable to a PHP script, incorporate this variable into my SQL query, and then return the results back to JavaScript. JavaScript: // Sending a variable to PHP script var variableToSend = '30'; $.post('myPHPscri ...

What is the process for setting up a "Highlight tab" feature in Next.Js?

I am currently working on implementing a selected tab feature in Next.Js. Users will have the ability to search for either Users or Posts by clicking on corresponding buttons. https://i.sstatic.net/mRBgQ.png Once the user clicks on a button, it should ch ...

Controlling LED lights using Johnny-Five and Arduino in NW.js

I have a setup with my board that includes two buttons (each with pull-up resistors) and two LEDs. My goal is to make each button activate its corresponding LED while deactivating the other one. Here's the code I'm using: var five = require(&ap ...

AngularJS and ExpressJS clash in routing (Oops, Crash!)

When setting up routing in angularjs and expressjs, I have created app.all('/*'...) to enable rendering index.html. However, whenever I use /*, the page crashes with an "Aw, Snap!" message. angularjs home.config(function($routeProvider,$locatio ...

The Redux store is duplicating the state across different reducers, causing it to appear twice

Having Trouble Viewing Different States for Two Reducers in Redux DevTools In my React project, I am attempting to incorporate a second reducer using Redux to gain a better understanding of the overall state. However, when I inspect the state in Redux Dev ...

Is there a method to prompt Angular to alert me when utilizing an undeclared directive in a template?

At times, I find myself making typos in the angular directive's name or the element tag within its template. However, the only indication I receive is the directive mysteriously disappearing. It would be helpful if angularjs could alert me when I at ...

Default value for the href property in NextJS Link is provided

Is there a default href value for Next/Link that can be used, similar to the way it is done in plain HTML like this: <a href='#' ></a> I attempted to do this with Link, but it resulted in the page reloading. Leaving it empty caused a ...

Tips on how to direct the attention to a text box within a unique dialog, ensuring that the blinking cursor highlights the input area

Is there a way to set autofocus on a textbox when opening a custom dialog box? I've tried using the autofocus attribute for the input field, but it doesn't seem to work for me. Can anyone provide guidance on how to achieve autofocus for a textfie ...

Generate a new entry and its linked data simultaneously

The Issue: Picture this scenario: I have two connected models, Library which has multiple Books: var Library = sequelize.define('Library', { title: Sequelize.STRING, description: Sequelize.TEXT, address: Sequelize.STRING }); var Boo ...

How can I modify the base color of a cone in Three.js?

My cone in the jsfiddle link is currently all blue, but I want to change the color of the square base to red. To do that, I need to alter the color of the two faces that make up the square base. How can this be achieved? View my cone on JsFiddle: http://j ...

Arrange two arrays by organizing them based on the contents of one in JavaScript

Consider the following two arrays: priceArray= [1, 5, 3, 7] userIdArray=[11, 52, 41, 5] The goal is to sort the priceArray in such a way that the userIdArray also gets sorted accordingly. The desired output should look like this: priceArray= [1, 3, 5, ...

Optimize the performance of filtering large GeoJSON files using Ajax in leaflet for the

I am managing four 2MB geoJson files with four different Layers that need to be loaded. Each layer is loaded using the following code: LayerBoon = L.geoJSON.ajax(URL, {pointToLayer:returnBoonMarker, filter:filtertext}); There is also a button click functi ...

Updating a particular column in a table with Jquery

In this table : $('#listview-table tr').each(function() { var status_id = $(this).find(".listViewEntryValue").$('[data-name~="cf_1525"]').text(); alert(status_id); }); <table id="listview-table" class="table listv ...

JavaScript encounters an Access Denied error when attempting to read data from a JSON file in

My code is experiencing issues on IE browser and Chrome, but works perfectly on FireFox. var currentPage = 1; var max = 0; var myList = []; var links = []; $.ajax({ cache: false, type : 'GET', crossDomain: true, ...