Title: Hovertext: Correct Units
Last modified: August 8, 2023

---

# Hovertext: Correct Units

 *  Resolved [Gowtham](https://wordpress.org/support/users/sgowtham/)
 * (@sgowtham)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/hovertext-correct-units/)
 * _Greetings._
 * _I have many maps using your plugin in my website (one example: [https://sgowtham.com/journal/2023-grandmas-marathon/](https://sgowtham.com/journal/2023-grandmas-marathon/)–
   I used just altitude on the y-axis and distance on the x-axis). When I hover 
   the mouse pointer over this graph, I see the hover text as “3 ft Altitude: 667
   ft” instead of “3 mi Altitude: 667 ft”._
 * _Any chance you are willing to fix this in the next version of this plugin? It’d
   also be great if the distance can be more granular. For example, “3.15 mi Altitude:
   667 ft”._
 * _Thank you for your work on this!_
 * _Gowtham (G)_
 * ![](https://i0.wp.com/sgowtham.com/assets/files/20230807_WPGPXMaps_HoverText.
   png?ssl=1)
    -  This topic was modified 2 years, 9 months ago by [Gowtham](https://wordpress.org/support/users/sgowtham/).
    -  This topic was modified 2 years, 9 months ago by [Gowtham](https://wordpress.org/support/users/sgowtham/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fhovertext-correct-units%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 1 replies (of 1 total)

 *  Thread Starter [Gowtham](https://wordpress.org/support/users/sgowtham/)
 * (@sgowtham)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/hovertext-correct-units/#post-16955722)
 * Greetings.
 * I was able to resolve both issues. All edits are in `js/WP-GPX-Maps.js`.
 * ******************************
 * For issue #1 (incorrect units in the hovertext/tooltip), the solution was replacing
 * `_formats.push( l_y );`
 * with
 * `_formats.push( l_x );`
 * in the `if ( graphEle != '' ) {` block – around line #1220.
 * ******************************
 * For issue #2 (number of decimal places in the graph’s tooltip/hovertext), the
   solution was replacing
 * `return Math.round( tooltipItems[0].xLabel, fpt.dec ) + fpt.suf;`
 * with
 * `return tooltipItems[0].xLabel + fpt.suf;`
 * in the `tooltips: {` section of the `var hoptions = {` block – around line #1130.
 * ******************************
 * Furthermore, I opted to add a single space between the metric and its unit. This
   was accomplished by making `l_x` and `l_y` look as follows (I just use `uom =
   1` and `uom = 2`) – around line #1040.
 *     ```wp-block-code
                           if ( '1' == unit ) {
   
                                   /* feet / miles */
                                   l_x = { suf: ' mi', dec: 1 };
                                   l_y = { suf: ' ft', dec: 0 };
   
                           } else if ( '2' == unit ) {
   
                                   /* meters / kilometers */
                                   l_x = { suf: ' km', dec: 1 };
                                   l_y = { suf: ' m', dec: 0 };
       ```
   
 * ******************************
 * A couple pages where the solution can be observed are
   [https://sgowtham.com/journal/2023-grandmas-marathon/](https://sgowtham.com/journal/2023-grandmas-marathon/)`(
   uom = 1)`
 * [https://sgowtham.com/journal/2023-american-birkebeiner/](https://sgowtham.com/journal/2023-american-birkebeiner/)`(
   uom = 2)`
 * I hope these help someone looking for similar solution.
 * My best,
 * Gowtham (G)
    -  This reply was modified 2 years, 9 months ago by [Gowtham](https://wordpress.org/support/users/sgowtham/).
    -  This reply was modified 2 years, 9 months ago by [Gowtham](https://wordpress.org/support/users/sgowtham/).
    -  This reply was modified 2 years, 9 months ago by [Gowtham](https://wordpress.org/support/users/sgowtham/).
    -  This reply was modified 2 years, 9 months ago by [Gowtham](https://wordpress.org/support/users/sgowtham/).

Viewing 1 replies (of 1 total)

The topic ‘Hovertext: Correct Units’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-gpx-maps_bcbfb3.svg)
 * [WP GPX Maps](https://wordpress.org/plugins/wp-gpx-maps/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-gpx-maps/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-gpx-maps/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-gpx-maps/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-gpx-maps/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-gpx-maps/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [Gowtham](https://wordpress.org/support/users/sgowtham/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/hovertext-correct-units/#post-16955722)
 * Status: resolved