Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8071145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:36:55+00:00 2026-06-05T13:36:55+00:00

I found the following thread very useful http://groups.google.com/group/jqplot-users/browse_thread/thread/1986 … I would like to get

  • 0

I found the following thread very useful

http://groups.google.com/group/jqplot-users/browse_thread/thread/1986…

I would like to get all the y axis values or ticks in an array…My
intention is to count the number of digits in each of the ticks and
find the most frequent number of digits.
Based on that im planning to truncate number of digits in the y axis
ticks/values.
For example : if most of the ticks have 6 digits, truncate to 3 digits
and append the word (in Thousands) to the axis label.

How can i achieve this? In the below function i can get the ticks one
by one…but i need to get them in advance so that i can decide by
what factor to truncate the number.Please ignore the function numberwithCommas.Its just an example.

(function($) {
    $.jqplot.tickNumberFormatter = function (format, val) {
        if (typeof val == 'number') {
            if (!format) {
                format = '%.1f';
            }
            return numberWithCommas($.jqplot.sprintf(format, val));
        }
        else {
            return String(val);
        }
    };

    function numberWithCommas(x) {
        return x.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");
    } 

@Boro : Thank you so much for the reply. Could you please let me know what this line does exactly?

   var ticks = $('.jqplot-' + axisName + '-tick'); 

The same line isn’t working in my code. How can I use it?

Can I use it to push all ticks into an array before the control enters the formatter? In other words, can I get all the ticks before the control enters the following function?

   $.jqplot.tickNumberFormatter = function (format, val) {

The following code works brilliantly in your example. Why doesn’t it work in mine 🙁

                var axisName = 'yaxis';
                var count = 0;
                var ticks = $('.jqplot-' + axisName + '-tick');
                for (count = 0; count <= ticks.length; count++)
                    {

                console.log($(ticks[count]).text());
                    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T13:36:59+00:00Added an answer on June 5, 2026 at 1:36 pm

    At first I thought it would be as easy as taking the values from the plot itself using a similar approach as here. Thus, I created a sample which on click on any bar loops around the selected axis ticks. The problem with this one is that we are using ‘private’ variable _ticks as the ticks one is an empty array (since it must be explicitly set). This approach would not work, for example, with xaxis where we set the ticks variable.

    Therefore, to get all ticks, independently from them being set by you or not, I would use jQuery and grab them whenever you need them, as presented in this code. Though, thinking about it, if the formatter acts before the plot is finished the HTML elements might not be there yet to grab them, but you can test it yourself. If this approach does not work you can always adapt the first approach to act differently depending on the ticks being set or not.

    EDIT in response to OP’s EDIT:

    Could you please let me know what this line does exactly?

    Here I use jQuery to capture ticks for axis specified by its name (axisName). For this before I use it I specify the var axisName = 'yaxis'; variable. You could substitute it with: var ticks = $('.jqplot-yaxis-tick');

    As it goes to the rest of your questions it might be the case that I am mentioning towards the end of my first answer, i.e. if the formatter acts before the plot is finished the HTML elements might not be there yet to grab them.

    EDIT2:

    Check out this sample. It grabs the ticks inside the formatter, as you could observe there sometimes they are zero probably because the formatter is called before the ticks HTML elements are created. Therefore, just apply your algorithm when there are some ticks otherwise apply default formatting, see if this approach will work.

    It still might not work as we do not know what is happening, for example, why in the console we have the ticksNoZeroCounter variable equal 20 which represents a number of times the formatter was called and ticks.size() !== 0. Why the variable is not equal to 21 or to some other number divisible by 7 (i.e. the number of ticks)?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found the following semaphore example. I'm currently learning about thread syncing. I have
Reading through documentation, I found following: 1.9.1 1.8.4 1.8.2 A version of 1.8.2 select
On the MSDN, I have found following: public event EventHandler<MyEventArgs> SampleEvent; public void DemoEvent(string
I found the following table structures while I was watching ruby on rails tutorial.
I found the following code somewhere, but I am not understanding the code properly.
I found the following article : here about installing fonts on a Windows computer
I found the following syntax as a VB.NET property and I'm trying to convert
I found the following code in my team's project: Public Shared Function isRemoteDisconnectMessage(ByRef m
I found the following claim in the documentation for Net::OpenSSH : Note that using
I found the following statement: Map is an object that stores key/volume pairs. Given

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.