Unable to update the y formatter for tooltip on Apexcharts

My current issue involves a seemingly simple task. I have created a basic formatter method to convert numbers into currency values. It appears to be functioning properly based on the y axis values being displayed with formatting like "$8,000". However, I am encountering an issue where the tooltip y values remain unformatted (as depicted in the image). According to the documentation, these values should be formatted using the y axis formatter, which does not seem to be taking effect.

https://i.sstatic.net/wbMe6.png

Despite attempting a custom formatter, it does not produce the desired outcome:

tooltip: {
  shared: false,
  intersect: true,
  x: {
    show: true,
  },
  y: {
    formatter: (y: any) => {
      return '$' + y;
    },
  },
},

Interestingly, when I utilize console.log(...) within that custom formatter, it only prints once or twice, displaying only the Maximum value (e.g. 7380.69999999999) instead of all five values as expected.

In addition, I am struggling to display the tooltip x header. Despite setting it to true, it remains hidden.

Although I am implementing this in vue, it seems that this issue is unrelated to the framework. Most Apexchart options are functioning correctly except for this particular one.

Answer №1

After analyzing the code within apexcharts.js, I stumbled upon this clever solution:

tooltip: {
    shared: false,
    intersect: true,
    custom: function({ seriesIndex, dataPointIndex, w }) {
      const minimum = w.globals.seriesCandleO[seriesIndex][dataPointIndex]
      const q1 = w.globals.seriesCandleH[seriesIndex][dataPointIndex]
      const median = w.globals.seriesCandleM[seriesIndex][dataPointIndex]
      const q3 = w.globals.seriesCandleL[seriesIndex][dataPointIndex]
      const maximum = w.globals.seriesCandleC[seriesIndex][dataPointIndex]

      return `<div class="apexcharts-tooltip-box apexcharts-tooltip-boxPlot">
        <div>Minimum: <span class="value">\$${minimum}</span></div>
        <div>Q1: <span class="value">\$${q1}</span></div>
        <div>Median: <span class="value">\$${median}</span></div>
        <div>Q3: <span class="value">\$${q3}</span></div>
        <div>Maximum: <span class="value">\$${maximum}</span></div>
      </div>`
    }
  }

This resulted in the following:

Check out the demonstration at codi.link

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

Tips for inserting a string into an array nested within an object stored in a state array

Currently, the variable sizeVariant is a string array and I am trying to append strings to it using an onClick event. The function findIndex seems to be working fine. However, there seems to be an issue with the concatenation section. It appears that using ...

Using VUEJS to pass the value of a JavaScript button

I am having difficulty passing the value of a button to a function when it is clicked. These buttons were dynamically created using JavaScript, which complicates the process. methods:{ createButtons() { var i; var rows ...

Best practices for securing Firebase Database

So, here's the scenario - we need to save data from a form to Firebase. The backend work is managed by Express. Time is of the essence here, so I want to make sure I get it right the first time. Right now, I've set the rules to allow both read ...

Display upon hovering, conceal with a button located within a popup container

There seems to be an issue with the code below. Even though it works perfectly in jsfiddle, it breaks in my Chrome and other browsers right after displaying the ".popup" div. Can anyone point out what I might be doing wrong? I found similar code on this si ...

Adjusting Javascript code to convert numerical values in HTML table cells from thousands to millions

Does anyone know how to create a Javascript function for a web report that converts table values to thousands or millions by dividing or multiplying by 1000? The issue is that each value is clickable, meaning it is wrapped in an anchor tag. Is there a wa ...

When using v-for to render an array list fetched from AsyncData, an error is thrown: The virtual DOM tree rendered on the client-side does not match the one

For my application, I am utilizing Nuxt.js. On one of the pages, I am using AsyncData to fetch an array of data objects from my API asynchronously. These data objects are then rendered in my template using v-for. Everything is functioning properly until I ...

Establishing an RSS feed (Google shopping) for an online store built on Vue-storefront

I recently launched a Vue-storefront based online store and now I'm looking to set up Google Shopping ads using an RSS feed for my products. However, I've encountered an error message saying "Unexpected token < in JSON at position 0" when tryi ...

Leveraging this jQuery code across multiple div elements

As a newcomer to jQuery, I am currently experimenting with a test script. My goal is to create an effect where when an image is clicked, a div slides down displaying more information similar to the new google images effect. The issue with the current scri ...

Unable to input information into Textbox in real-time

Having trouble entering data from one page to another using ng-model. After filling in some information in a textbox and moving to the next page, I want the same data to be entered when I return to the previous page. I've written the code but it doesn ...

Struggling to create an access token with the Slack API

My goal is to retrieve an access token from the Slack API. When I use the code provided below, it generates an authorization URL containing a temporary code in the query string. Once permissions are granted, the process redirects to /slack/oauthcallback. ...

Best practices for avoiding string concatenation in Oracle-db with Node.js

Is there a way to prevent SQL injection caused by string concatenation in the SQL query? The searchParameter and searchString parameters, which come from a GET request, are optional. They should be added to the WHERE clause to filter results based on user ...

Encountering an issue with core.js:15723 showing ERROR TypeError: Unable to access property 'toLowerCase' of an undefined value while using Angular 7

Below, I have provided my code which utilizes the lazyLoading Module. Please review my code and identify any errors. Currently facing TypeError: Cannot read property 'toLowerCase' of undefined in Angular 7. Model Class: export class C_data { ...

When using setState in the onRowSelection event with React's Material-ui tableRow, the selection cannot be properly controlled

Currently, I am working with a material-ui table https://i.stack.imgur.com/JIzLT.png and my goal is to pass selected rows to a function when the DELETE button is clicked. constructor(props) { super(props); this.state = { selecte ...

What is the best way to extract "true" values from an array and store them in a new array during iteration?

I am currently enrolled in a Codecademy course and I am facing a roadblock. My main goal is to gain a solid grasp of JavaScript. The current task at hand is as follows: "There is an array of unnecessary words. Your goal is to iterate over the array and fi ...

How can you style a two-item list in Material-UI React to display the items side by side?

I have a list that contains two items: 'label' and 'value'. This is the current layout: https://i.stack.imgur.com/HufX7.png How can I rearrange the items on the right to be positioned next to the label on the left? https://i.stack.im ...

Tips for displaying complex JSON structures in VueJS

I want to extract this information from a JSON dataset <ol class="dd-list simple_with_drop vertical contract_main"> <li class="alert mar" data-id="1" data-name="Active" style=""> <div class="dd-handle state-main">Active<span cl ...

Is it possible to directly utilize functions from an imported JavaScript library, such as Change Case, within the template of a Vue component?

After successfully importing and using the Change Case library within the <script></script> element of a Vue component, I now seek to directly utilize the Change Case functions in the template itself. As of now, my understanding is that when d ...

What causes a TypeError (Invalid response status code) when a 204 response is returned to a fetch() call within a React Server Component?

Take a look at this straightforward Next.js application: https://codesandbox.io/p/sandbox/next-js-app-router-1bvd7d?file=README.md Here is an API route (/api/hello): export default function handler(req, res) { res.status(204).end(); } And there's ...

In what time frame is Javascript/AJAX functioning?

Do you know if the times are measured in milliseconds or seconds? I'm puzzled why these two scripts aren't synchronizing - there's a significant delay. $(document).ready(function() { $("#idle").delay(300000).fadeIn(500); }); var interv ...

Merge two arrays together in Javascript by comparing and pairing corresponding elements

Dealing with two arrays here. One comes from an API and the other is fetched from Firebase. Both contain a common key, which is the TLD as illustrated below. API Array [ { "TLD" : "com", "tld_type": 1, }, "TLD" : "org", "tld_type" : 1, } ] Fi ...