Issue with plotted point labels failing to display correctly on X Range Chart for the initial date of each month - Highcharts

Currently, I am implementing a chart that displays the timeline of activities using an x range. However, I have encountered an issue with the popup displaying data information when hovering over the bars.

The problem arises specifically on the first date of each month where the displayed information is inaccurate.

Below is a snippet of my code:

Highcharts.chart('container', {
    chart: {
       type: 'xrange',
        styledMode: true
    },
    title: {
        text: 'Highcharts X-range'
    },
    xAxis: {
        type: 'datetime'
    },
    yAxis: {
        title: {
            text: ''
        },
        categories: ['Proto', 'Dev', 'Test'],
        reversed: true
        },
    series: [{
        name: 'Project:',
        pointWidth: 20,
        data: [{
            x: Date.UTC(2014, 0, 1),
            x2: Date.UTC(2014, 5, 2),
            y: 0,
            partialFill: 0.25
        },  {
            x: Date.UTC(2014, 2, 1),
            x2: Date.UTC(2014, 3, 19),
            y: 1
        }, {
            x: Date.UTC(2014, 11, 1),
            x2: Date.UTC(2014, 11, 23),
            y: 2
        }],
          dataLabels: {
          enabled: true
        }
       }]
      });

I expect the output to be in the following format:

Wednesday, Jan 1, 2014 - Monday, Jun 2, 2014 Project: Proto

However, the current output appears as:

January 2014 - June 2014 Project: Proto

Your assistance in resolving this issue would be greatly appreciated.

Thank you.

Answer №1

To enhance your tooltip content, utilize the tooltip.formatter callback function and format dates to your preference using the Highcharts.dateFormat() method. Take a look at the code snippet and demo provided below.

HTML:

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/xrange.js"></script>
<div id="container"></div>

JS:

Highcharts.chart('container', {
  chart: {
    type: 'xrange',
    styledMode: true
  },
  title: {
    text: 'Highcharts X-range'
  },
  xAxis: {
    type: 'datetime'
  },
  yAxis: {
    title: {
      text: ''
    },
    categories: ['Proto', 'Dev', 'Test'],
    reversed: true
  },
  tooltip: {
    formatter: function() {
      var point = this,
        series = point.series,
        color = point.color || series.chart.options.colors[point.colorIndex],
        firstDate = Highcharts.dateFormat('%A, %b %e, %Y', point.x),
        secondDate = Highcharts.dateFormat('%A, %b %e, %Y', point.x2),
        header = '<span style="font-size: 10px">' + firstDate + ' - ' + secondDate + '</span><br/>',
        content = '<span style="color:' + color + '">\u25CF</span> ' + series.name + ': <b>' + point.yCategory + '</b><br/>';

      return header + content;
    }
  },
  series: [{
    name: 'Project',
    pointWidth: 20,
    data: [{
      x: Date.UTC(2014, 0, 1),
      x2: Date.UTC(2014, 5, 2),
      y: 0,
      partialFill: 0.25
    }, {
      x: Date.UTC(2014, 2, 1),
      x2: Date.UTC(2014, 3, 19),
      y: 1
    }, {
      x: Date.UTC(2014, 11, 1),
      x2: Date.UTC(2014, 11, 23),
      y: 2
    }],
    dataLabels: {
      enabled: true
    }
  }]

});

Demo:
https://jsfiddle.net/BlackLabel/3wbscy6q/

API reference:
https://api.highcharts.com/highcharts/tooltip.formatter
https://api.highcharts.com/class-reference/Highcharts#.dateFormat
https://api.highcharts.com/highcharts/tooltip.dateTimeLabelFormats

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

Converting an array of arrays into an object with an index signature: A step-by-step guide

I find myself facing a challenge where I have two types, B and A, along with an array called "a". My objective is to convert this array into type B. Type A = Array<[string, number, string]>; Type B = { [name: string]: { name: ...

I am seeking to enable a specific div when the crawler condition is met

This specific div houses the character and becomes active when the character is clicked. Upon clicking, a jQuery function is triggered to display other countries. //this particular div should remain active when the crawler condition is met. It displays th ...

Issue with uncaught exceptions in promise rejection test

I am experiencing an issue with the following code: function foo(){ bar().catch(function(){ //do stuff } } function bar(){ return promiseReturner().then( function(result){ if(_.isEmpty(result)){ throw "Result is empty"; ...

Discover specific element details using the id with Strapi and React

I am currently studying react with strapi and I have encountered an issue. I have successfully displayed all elements from a database, but I am facing a problem when trying to display specific information on clicking an element. Although I can retrieve t ...

Can you explain the significance of `Component<Props>` in React Native?

Recently, I started a new react-native project and noticed a change in the component syntax. It now reads export default class WelcomeScreen extends Component<Props>, which is different from what it used to be, export default class WelcomeScreen exte ...

The gap between list items(`<li>`s)

Feeling a bit perplexed here. I'm working on creating a page to showcase images. My goal is to have 5 images displayed per row, with maximum spacing when the window is at its widest (~950 px). However, as the window size decreases, I want the images t ...

Utilize jQuery to track and record AdWords conversions

I have noticed a number of inquiries regarding tracking Adwords conversions with jQuery on this platform. However, it appears that there is no definitive solution yet. My attempt at recording a conversion involves the code below following the submission o ...

res.json responding with altered input unexpectedly

When I use my res.json function, it seems to be altering my data. The data appears correct when logged in the function, but changes inside res.json and I can't figure out why. For example, instead of returning {"unix":"1484600306","naturalFormat":"20 ...

Customize the progress bar color in Bootstrap by setting a unique color to it

Is it possible to apply a custom color to the progress bar in Bootstrap that is not one of the standard options like success, info, warning or danger? I attempted adding the following code snippet to my bootstrap-theme.css file: .progress-bar-custom { b ...

Tips for creating a personalized dialog box after logging in with React Admin based on the server's response

One of my requirements is to allow users to select a role during the login process. Once the user enters their username and password, the server will respond with the list of available roles. How can I implement a dialog where the user can choose a role fr ...

Guide to utilizing import and export features in node.js

My issue involves two specific files: The first file, app.js The second file, module.js In app.js, there is an expression that looks like this: import 'foo' from './module' //use foo.. Meanwhile, module.js contains the following: ...

Accessing information from RESTful Web Service with Angular 2's Http functionality

I am currently working on retrieving data from a RESTful web service using Angular 2 Http. Initially, I inject the service into the constructor of the client component class: constructor (private _myService: MyService, private route: Activat ...

Navigating Time Constraints and Error Management in the World of Facebook Graph API

I'm currently working on a program that involves numerous fql and graph calls, but I'm facing difficulty in handling 'get' or 'post' errors. Can anyone provide guidance on how to implement retry functionality when these errors ...

Error encountered during npm installation caused by the extract-text-webpack-plugin

I encountered an error while attempting to install the extract-text-webpack-pluginpm plugin. extract-text-webpack-plugin <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3f12124c5e495a125b5a495e4f4f7f0f110e110f">[email  ...

Tips on invoking a method from a JavaScript object within an AJAX request

Considering the following code snippet: var submit = { send:function (form_id) { var url = $(form_id).attr("action"); $.ajax({ type: "POST", url: url, data: $(form_id).serialize(), dataType: 'json', succes ...

What could be the reason for JSON refusing to accept an element from an array?

I am looking to retrieve the exchange rates for all currencies from an API using an array that lists all available currencies. Below is the JavaScript code I have written: var requestURL = 'https://api.fixer.io/latest'; var requestUrlstandard ...

Connect radio input's value to object's key within AngularJS

Within my controller, I currently have an object structured as follows: $scope.colors = { green: "Green", yellow: "Yellow", red: "Red" }; I am attempting to dynamically generate radio inputs and then link the input value to the corresponding ...

Issue with HTML form not updating MySQL database with PHP

Oh no, this PHP situation is really confusing me! I've been at it for a month now and this is the kind of challenge I thought I would face four weeks ago. Sigh! I keep getting an "Undefined index" warning, and the database is updating with a date of ...

Change justify-content-between to something else

After successfully fixing the issue with aligning the navbar brand in the middle of my navigation bar, I am now facing a new challenge. I want to add a button right before the right navigation toggle, but all my attempts have been unsuccessful so far. I&ap ...

Guide to crafting a javascript variable from MySQL through the power of PHP and AJAX

I am not very experienced in working with AJAX and javascript. I am currently trying to pass longitude and latitude values from a MySQL database to javascript, but it doesn't seem to be working as expected. Can anyone help me figure out what I might b ...