Turn off tooltips specifically for months and days in Highcharts

Hello highcharts enthusiasts!

Within my angular 4 project, I am attempting to exclude the display of days and months in the tooltip of my horizontal bar chart, showing only hours, minutes, and seconds. Does anyone have a solution for achieving this?

I have already attempted using the dateTimeLabelFormats property without any success.

Thank you in advance.

horizontalbar.ts:

constructor(public userService3: UserService3) {

  const timeZoneOffset = new Date().getTimezoneOffset();

  const Highcharts = require('highcharts');

    Highcharts.setOptions({
  global: {
   timezoneOffset: timeZoneOffset
  },
      });


       this.options = {
        title : { text : '' },
        chart: {  type: 'area',
                    label: {
                      format: '{data: %B}'
                    }},
        legend: { enabled: false },
        credits: { enabled: false },
        xAxis: { type: 'datetime',
                //  day: '%H',
                startOnTick: false,
                endOnTick: false,
                minTickInterval: 24 * 3600 * 1000,
                tickInterval: 36e5 * 2, // two hours
                },
        yAxis: { min: 0,
          max: 100,
           labels: {
              enabled: true
          },
             title: {
             text: null
           },
        },
        plotOptions: {
          series: {
              color: '#648e59',
              fillOpacity: 0.8,
              fillColor: '#648e59',
              pointInterval: 36e5 * 2 // two hours
                  }
        },
        series: [{
          name: 'Taux de fonctionnement',
          data: [],
        }]
       };
   }
  saveInstance(chartInstance) {
    this.chart = chartInstance;
    console.log(chartInstance);
}

  public ngOnInit () {
  this.dataSubscription = this.userService3.getData().subscribe((data) 
 => {
  this.options.series[0].data = data.data.operating_details;
  console.log(data);
   });
}
   ngOnDestroy() {
  if (this.dataSubscription){
 this.dataSubscription.unsubscribe();
 }
   }
     public hideDem2(): void {
   this.hideMeup = !this.hideMeup;
    this.hideMeup = !this.hideMeup;

    this.hideItup = !this.hideItup;
        if (this.hideItup) {
          this.opened.emit(true);
        } else {
          this.closed.emit(false);
        }
           console.log(this.hideItup);
      }

   }

horizontalbar.html:

      <chart [options]="options" (load)="saveInstance($event.context)">
      <!--    <point (select)="onPointSelect($event)"></point> -->
      </chart>

Answer №1

If you're referring to a "tick in my horizontal bar chart" as the axis labels, you can include the following code in your xAxis options:

labels: {
    formatter: function () {
        return Highcharts.dateFormat('%H:%M:%S', this.value);
    },
},

This will display only the hours, minutes, and seconds of your axis labels in the format H:M:S.

You can learn more about the Highcharts.dateFormat() function here: http://api.highcharts.com/highcharts/Highcharts.numberFormat.

The Highcharts.dateFormat() function follows PHP's strftime formatting rules (refer to http://php.net/manual/en/function.strftime.php).

I hope this explanation proves useful to you.


Update: Based on Emile's feedback, it seems the tick referred to the chart's tooltip. To adjust this, modify the code as below:

tooltip: {
    formatter: function () {
        return Highcharts.dateFormat('%H:%M:%S', this.x);
    },
},

Refer to these resources from Highcharts documentation for more guidance:

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

Edge browser experiencing delays with dynamic select options in Angular 2

I am currently utilizing an *ngFor loop in Angular 2 Version: 4.0.1 to populate 5 select lists on a webpage with the given code: select [(ngModel)]="_materialInput.code" (change)="onChange()" formControlName="code" class="form-control" id="code"> & ...

Unable to assign an ID to an event in Angular when the eventReceived event is triggered

I am currently working with the Angular fullcalendar module that includes drag and drop functionality. My goal is to assign an ID to new events dropped on the calendar by users, but I am unsure of the proper way to do this. Here is the Stackblitz link. Ad ...

How can you retrieve the keys of an object that conforms to an interface?

In the following demonstration, we have two objects - KEYS and KEYS2. When importing KEYS in index.ts, autocomplete suggestions are available for K1 and K2 because KEYS does not adhere to an interface. On the other hand, with KEYS2, autocomplete is not pr ...

Sharing information between a cordova plugin and an Angular application

I have been working on an Angular/Cordova app and I am trying to pass the online/offline status to Angular: export class AppComponent implements OnInit { isOff = false; constructor() { document.addEventListener('deviceready', onDeviceRea ...

Ensure that Template.fromStack() includes resources with the specified logical identifiers

Currently, I am overhauling a CDK stack in TypeScript that has reached the resource limit. Given that it includes stateful resources, I need to ensure that the revamped stack points to the same resources and not new ones that could lead to unfavorable resu ...

What is the best way to update the state of a response from an API call for a detailed object using React context, so that there is no need to retrigger the API call

I'm currently developing a react native typescript project. How can I assign the data received from an API call to my context object? I want to avoid making the API call every time the component is loaded. Instead, I want to check if the context alr ...

Having trouble locating the withArgs() method of the Spy class when using Jasmine and TypeScript

As per the Jasmine documentation, there is a method called withArgs() in the Spy object. spyOn(someObj, 'func').withArgs(1, 2, 3).and.returnValue(42); In the TypeScript-adapted version, I am unable to locate this method. My project was initiali ...

Compiling TypeScript sources encountered a TS1005 error during compilation

While my application runs smoothly within VS2022, I encounter errors when attempting to run gulp and compile TypeScript sources. The errors look like the ones below. I have provided my tsconfig and package files; however, I am uncertain if I need to modify ...

Styling Form validation with Ant Design

Can a className prop be included in the Form.Item validation? <Form.Item name="username" rules={[ { required: true, message: '...' }, className="customValidation" //<- attempting to add a className but it is not fu ...

Mastering Firebase pagination with RxJS - the ultimate solution

I came across this helpful post on Cloud Firestore pagination with RXJS at Cloud Firestore - How to paginate data with RXJS While it is exactly what I need, I am struggling to understand how to implement the following code snippet: import { UsersService } ...

Connecting data from a .ts file in one webpage to the HTML content of another webpage

I am currently working on implementing the binding concept in Angular. The code snippet below is from PageOne.ts: this.navCtrl.push("PageTwo",{ paramType: params, }) Here is a snippet from PageTwo.html: <span>{{paramType}}</span> ...

Comparing Observable.toPromise() to Observable.firstValueFrom() in the context of Angular Firestore

I'm currently utilizing Observables in my Angular project version 13.0.3, connected to the AngularFireStore database (angular/fire 7.2). My requirement is a straightforward method to fetch data from a firestore collection and immediately return it fo ...

The @HostListener in Angular2 does not function correctly within a component that is inherited from another component

My Angular2-based client-side application has a base class: abstract class BaseClass { @HostListener('window:beforeunload') beforeUnloadHandler() { console.log('bla'); } } and two similar derived classes: @Component({ ...

Encountered an issue in Angular 2 when attempting to add an element to an array, resulting in the error message: "Attempting to

list.component import { Component, OnInit } from '@angular/core'; import { Todo } from '../model/todo'; import { TodoDetailComponent } from './detail.component'; import { TodoService } from '../service/todo.service' ...

Even with ngModel in place, Ng-Select fails to set a default value

Here is the HTML code I used: <ng-select [items]="sensorTypes" bindLabel="label" [multiple]="true" placeholder="Select" [(ngModel)]="selectedAttributes"> ...

Can user data be securely stored in localStorage using Angular?

I'm diving into the world of Angular and embarking on my first Angular app. I find myself pondering the safety of storing user data in localStorage. If it's not secure to do so, what alternative methods should I explore, especially since I am usi ...

Angular 8: ISSUE TypeError: Unable to access the 'invalid' property of an undefined variable

Can someone please explain the meaning of this error message? I'm new to Angular and currently using Angular 8. This error is appearing on my console. ERROR TypeError: Cannot read property 'invalid' of undefined at Object.eval [as updat ...

How can I use JavaScript to extract the contents of a file up to 'n' instances of a specific character and store it in a variable?

I have a text file that is being generated by the Apache Flink Tool. 1. My goal is to extract the contents of this file until it reaches the 999th "}," occurrence. 2. After extraction, remove the last comma(,) from the content. 3. Add "[" at the beginning ...

Which objects can be looped through in Aurelia templating?

In the documentation for Aurelia, it mentions that repeaters can be used with arrays and other iterable data types, including objects, as well as new ES6 standards like Map and Set. Map is usually recommended, as shown in the example below: <template&g ...

Using Angular and Angular Material to project content within MatDialog.open()

Suppose I have a Component: @Component( selector: "demo-comp", template: ` <div> Some text... <ng-content></ng-content> </div> ` ) export class DemoComponent { constructor(public dialogRef: MatD ...