How is the number of ticks on an axis defined?Validate decimal numbers in JavaScript - IsNumeric()How do JavaScript closures work?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How do I include a JavaScript file in another JavaScript file?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?

Can anyone give me examples of the relative-determinative 'which'?

What is this weird d12 for?

How might a landlocked lake become a complete ecosystem?

Formal Definition of Dot Product

How does a permutation act on a string?

Why were the bells ignored in S8E5?

How to rename multiple files in a directory at the same time

Is the seat-belt sign activation when a pilot goes to the lavatory standard procedure?

Why would company (decision makers) wait for someone to retire, rather than lay them off, when their role is no longer needed?

enumitem: Understanding the usage of asterisk and exclamation mark in setting the different lengths

labelled end points on logic diagram

Was the dragon prowess intentionally downplayed in S08E04?

How would you translate "grit" (personality trait) to Chinese?

Could there be something like aerobatic smoke trails in the vacuum of space?

Does this "yield your space to an ally" rule my 3.5 group uses appear anywhere in the official rules?

How did the horses get to space?

c++ conditional uni-directional iterator

Developers demotivated due to working on same project for more than 2 years

Does addError() work outside of triggers?

Should I communicate in my applications that I'm unemployed out of choice rather than because nobody will have me?

Why did the metro bus stop at each railway crossing, despite no warning indicating a train was coming?

How does Ctrl+c and Ctrl+v work?

Why would someone open a Netflix account using my Gmail address?

Why are lawsuits between the President and Congress not automatically sent to the Supreme Court



How is the number of ticks on an axis defined?


Validate decimal numbers in JavaScript - IsNumeric()How do JavaScript closures work?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How do I include a JavaScript file in another JavaScript file?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I'm new to d3 and have the following code for creating the x-axis on my graph:



export const drawXAxis = (svg, timestamps, chartWidth, chartHeight) => 
console.log(chartWidth); // 885
console.log(timestamps.length); // 310
const xScale = d3.scaleLinear()
.domain([-1, timestamps.length])
.range([0, chartWidth]);

const xBand = d3.scaleBand()
.domain(
d3.range(-1, timestamps.length))
.range([0, chartWidth])
.padding(0.3);

const xAxis = d3.axisBottom()
.scale(xScale)
.tickFormat(function(d)
const ts = moment.utc(timestamps[d]);
return ts.format('HH') + 'h';
);

const gX = svg.append("g")
.attr("class", "axis x-axis")
.attr("transform", "translate(0," + chartHeight + ")")
.call(xAxis);

return [xScale, xBand, xAxis, gX];
;


enter image description here



As I understand it, d3 decides on the number of ticks that appears on the X-axis.

In order to gain more control over the values appearing on the X-axis for zooming purposes, I would like to understand how d3 determines that - in this case - I have 16 ticks.

What If I want to space the ticks more evenly, for example, I want to see a tick on every 12 or 6 hours? My data contains 0 -> 23 hour values per day consistently, but d3 displays random hours on my graph.










share|improve this question
























  • Hey, can you please reproduce it on jsfiddle or something? I have a hunch on how to fix it for you, but I need to test it out first.

    – wentjun
    Mar 23 at 15:29











  • @wentjun Ok will do when I get home

    – Trace
    Mar 23 at 15:40











  • Sure! I have come up with a rough sketch of the solution on my answer. I will try to improvise once I have access to the demo.

    – wentjun
    Mar 23 at 15:44

















1















I'm new to d3 and have the following code for creating the x-axis on my graph:



export const drawXAxis = (svg, timestamps, chartWidth, chartHeight) => 
console.log(chartWidth); // 885
console.log(timestamps.length); // 310
const xScale = d3.scaleLinear()
.domain([-1, timestamps.length])
.range([0, chartWidth]);

const xBand = d3.scaleBand()
.domain(
d3.range(-1, timestamps.length))
.range([0, chartWidth])
.padding(0.3);

const xAxis = d3.axisBottom()
.scale(xScale)
.tickFormat(function(d)
const ts = moment.utc(timestamps[d]);
return ts.format('HH') + 'h';
);

const gX = svg.append("g")
.attr("class", "axis x-axis")
.attr("transform", "translate(0," + chartHeight + ")")
.call(xAxis);

return [xScale, xBand, xAxis, gX];
;


enter image description here



As I understand it, d3 decides on the number of ticks that appears on the X-axis.

In order to gain more control over the values appearing on the X-axis for zooming purposes, I would like to understand how d3 determines that - in this case - I have 16 ticks.

What If I want to space the ticks more evenly, for example, I want to see a tick on every 12 or 6 hours? My data contains 0 -> 23 hour values per day consistently, but d3 displays random hours on my graph.










share|improve this question
























  • Hey, can you please reproduce it on jsfiddle or something? I have a hunch on how to fix it for you, but I need to test it out first.

    – wentjun
    Mar 23 at 15:29











  • @wentjun Ok will do when I get home

    – Trace
    Mar 23 at 15:40











  • Sure! I have come up with a rough sketch of the solution on my answer. I will try to improvise once I have access to the demo.

    – wentjun
    Mar 23 at 15:44













1












1








1








I'm new to d3 and have the following code for creating the x-axis on my graph:



export const drawXAxis = (svg, timestamps, chartWidth, chartHeight) => 
console.log(chartWidth); // 885
console.log(timestamps.length); // 310
const xScale = d3.scaleLinear()
.domain([-1, timestamps.length])
.range([0, chartWidth]);

const xBand = d3.scaleBand()
.domain(
d3.range(-1, timestamps.length))
.range([0, chartWidth])
.padding(0.3);

const xAxis = d3.axisBottom()
.scale(xScale)
.tickFormat(function(d)
const ts = moment.utc(timestamps[d]);
return ts.format('HH') + 'h';
);

const gX = svg.append("g")
.attr("class", "axis x-axis")
.attr("transform", "translate(0," + chartHeight + ")")
.call(xAxis);

return [xScale, xBand, xAxis, gX];
;


enter image description here



As I understand it, d3 decides on the number of ticks that appears on the X-axis.

In order to gain more control over the values appearing on the X-axis for zooming purposes, I would like to understand how d3 determines that - in this case - I have 16 ticks.

What If I want to space the ticks more evenly, for example, I want to see a tick on every 12 or 6 hours? My data contains 0 -> 23 hour values per day consistently, but d3 displays random hours on my graph.










share|improve this question
















I'm new to d3 and have the following code for creating the x-axis on my graph:



export const drawXAxis = (svg, timestamps, chartWidth, chartHeight) => 
console.log(chartWidth); // 885
console.log(timestamps.length); // 310
const xScale = d3.scaleLinear()
.domain([-1, timestamps.length])
.range([0, chartWidth]);

const xBand = d3.scaleBand()
.domain(
d3.range(-1, timestamps.length))
.range([0, chartWidth])
.padding(0.3);

const xAxis = d3.axisBottom()
.scale(xScale)
.tickFormat(function(d)
const ts = moment.utc(timestamps[d]);
return ts.format('HH') + 'h';
);

const gX = svg.append("g")
.attr("class", "axis x-axis")
.attr("transform", "translate(0," + chartHeight + ")")
.call(xAxis);

return [xScale, xBand, xAxis, gX];
;


enter image description here



As I understand it, d3 decides on the number of ticks that appears on the X-axis.

In order to gain more control over the values appearing on the X-axis for zooming purposes, I would like to understand how d3 determines that - in this case - I have 16 ticks.

What If I want to space the ticks more evenly, for example, I want to see a tick on every 12 or 6 hours? My data contains 0 -> 23 hour values per day consistently, but d3 displays random hours on my graph.







javascript d3.js






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 2:54









Gerardo Furtado

69.7k75498




69.7k75498










asked Mar 23 at 15:17









TraceTrace

8,33363890




8,33363890












  • Hey, can you please reproduce it on jsfiddle or something? I have a hunch on how to fix it for you, but I need to test it out first.

    – wentjun
    Mar 23 at 15:29











  • @wentjun Ok will do when I get home

    – Trace
    Mar 23 at 15:40











  • Sure! I have come up with a rough sketch of the solution on my answer. I will try to improvise once I have access to the demo.

    – wentjun
    Mar 23 at 15:44

















  • Hey, can you please reproduce it on jsfiddle or something? I have a hunch on how to fix it for you, but I need to test it out first.

    – wentjun
    Mar 23 at 15:29











  • @wentjun Ok will do when I get home

    – Trace
    Mar 23 at 15:40











  • Sure! I have come up with a rough sketch of the solution on my answer. I will try to improvise once I have access to the demo.

    – wentjun
    Mar 23 at 15:44
















Hey, can you please reproduce it on jsfiddle or something? I have a hunch on how to fix it for you, but I need to test it out first.

– wentjun
Mar 23 at 15:29





Hey, can you please reproduce it on jsfiddle or something? I have a hunch on how to fix it for you, but I need to test it out first.

– wentjun
Mar 23 at 15:29













@wentjun Ok will do when I get home

– Trace
Mar 23 at 15:40





@wentjun Ok will do when I get home

– Trace
Mar 23 at 15:40













Sure! I have come up with a rough sketch of the solution on my answer. I will try to improvise once I have access to the demo.

– wentjun
Mar 23 at 15:44





Sure! I have come up with a rough sketch of the solution on my answer. I will try to improvise once I have access to the demo.

– wentjun
Mar 23 at 15:44












1 Answer
1






active

oldest

votes


















1














I'm gonna answer just the question in the title ("how is the number of ticks on an axis defined?"), not the one you made at the end ("What If I want to space the ticks more evenly, for example, I want to see a tick on every 12 or 6 hours?"), which is not related and quite simple to fix (and, besides that, it's certainly a duplicate).



Your question demands a detective work. Our journey starts, of course, at d3.axisBottom(). If you look at the source code, you'll see that the number of ticks in the enter selection...



tick = selection.selectAll(".tick").data(values, scale).order()


...depends on values, which is:



var values = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain()) : tickValues


What this line tells us is that, if tickValues is null (no tickValues used), the code should use scale.ticks for scales that have a ticks method (continuous), our just the scale's domain for ordinal scales.



That leads us to the continuous scales. There, using a linear scale (which is the one you're using), we can see at the source code that scale.ticks returns this:



scale.ticks = function(count) 
var d = domain();
return ticks(d[0], d[d.length - 1], count == null ? 10 : count);
;


However, since ticks is imported from d3.array, we have to go there for seeing how the ticks are calculated. Also, since we didn't pass anything as count, count defaults to 10.



So, finally, we arrive at this:



start = Math.ceil(start / step);
stop = Math.floor(stop / step);
ticks = new Array(n = Math.ceil(stop - start + 1));
while (++i < n) ticks[i] = (start + i) * step;


Or this:



start = Math.floor(start * step);
stop = Math.ceil(stop * step);
ticks = new Array(n = Math.ceil(start - stop + 1));
while (++i < n) ticks[i] = (start - i) / step;


Depending on the value of steps. If you look at the tickIncrement function below, you can see that steps can only be 1, 2, 5 or 10 (and their negatives).



And that's all you need to know the length of the array in the variable ticks above. Depending on the start and stop values (i.e., depending on the domain), sometimes we have more than 10 ticks (16 in your case), sometimes we have less than 10, even if the default count is 10. Have a look here:






const s = d3.scaleLinear();

console.log(s.domain([1,12]).ticks().length);
console.log(s.domain([100,240]).ticks().length);
console.log(s.domain([10,10]).ticks().length);
console.log(s.domain([2,10]).ticks().length);
console.log(s.domain([1,4]).ticks().length);

<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>





The last example, as you can see, gives us 16 ticks.






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315220%2fhow-is-the-number-of-ticks-on-an-axis-defined%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I'm gonna answer just the question in the title ("how is the number of ticks on an axis defined?"), not the one you made at the end ("What If I want to space the ticks more evenly, for example, I want to see a tick on every 12 or 6 hours?"), which is not related and quite simple to fix (and, besides that, it's certainly a duplicate).



    Your question demands a detective work. Our journey starts, of course, at d3.axisBottom(). If you look at the source code, you'll see that the number of ticks in the enter selection...



    tick = selection.selectAll(".tick").data(values, scale).order()


    ...depends on values, which is:



    var values = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain()) : tickValues


    What this line tells us is that, if tickValues is null (no tickValues used), the code should use scale.ticks for scales that have a ticks method (continuous), our just the scale's domain for ordinal scales.



    That leads us to the continuous scales. There, using a linear scale (which is the one you're using), we can see at the source code that scale.ticks returns this:



    scale.ticks = function(count) 
    var d = domain();
    return ticks(d[0], d[d.length - 1], count == null ? 10 : count);
    ;


    However, since ticks is imported from d3.array, we have to go there for seeing how the ticks are calculated. Also, since we didn't pass anything as count, count defaults to 10.



    So, finally, we arrive at this:



    start = Math.ceil(start / step);
    stop = Math.floor(stop / step);
    ticks = new Array(n = Math.ceil(stop - start + 1));
    while (++i < n) ticks[i] = (start + i) * step;


    Or this:



    start = Math.floor(start * step);
    stop = Math.ceil(stop * step);
    ticks = new Array(n = Math.ceil(start - stop + 1));
    while (++i < n) ticks[i] = (start - i) / step;


    Depending on the value of steps. If you look at the tickIncrement function below, you can see that steps can only be 1, 2, 5 or 10 (and their negatives).



    And that's all you need to know the length of the array in the variable ticks above. Depending on the start and stop values (i.e., depending on the domain), sometimes we have more than 10 ticks (16 in your case), sometimes we have less than 10, even if the default count is 10. Have a look here:






    const s = d3.scaleLinear();

    console.log(s.domain([1,12]).ticks().length);
    console.log(s.domain([100,240]).ticks().length);
    console.log(s.domain([10,10]).ticks().length);
    console.log(s.domain([2,10]).ticks().length);
    console.log(s.domain([1,4]).ticks().length);

    <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>





    The last example, as you can see, gives us 16 ticks.






    share|improve this answer





























      1














      I'm gonna answer just the question in the title ("how is the number of ticks on an axis defined?"), not the one you made at the end ("What If I want to space the ticks more evenly, for example, I want to see a tick on every 12 or 6 hours?"), which is not related and quite simple to fix (and, besides that, it's certainly a duplicate).



      Your question demands a detective work. Our journey starts, of course, at d3.axisBottom(). If you look at the source code, you'll see that the number of ticks in the enter selection...



      tick = selection.selectAll(".tick").data(values, scale).order()


      ...depends on values, which is:



      var values = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain()) : tickValues


      What this line tells us is that, if tickValues is null (no tickValues used), the code should use scale.ticks for scales that have a ticks method (continuous), our just the scale's domain for ordinal scales.



      That leads us to the continuous scales. There, using a linear scale (which is the one you're using), we can see at the source code that scale.ticks returns this:



      scale.ticks = function(count) 
      var d = domain();
      return ticks(d[0], d[d.length - 1], count == null ? 10 : count);
      ;


      However, since ticks is imported from d3.array, we have to go there for seeing how the ticks are calculated. Also, since we didn't pass anything as count, count defaults to 10.



      So, finally, we arrive at this:



      start = Math.ceil(start / step);
      stop = Math.floor(stop / step);
      ticks = new Array(n = Math.ceil(stop - start + 1));
      while (++i < n) ticks[i] = (start + i) * step;


      Or this:



      start = Math.floor(start * step);
      stop = Math.ceil(stop * step);
      ticks = new Array(n = Math.ceil(start - stop + 1));
      while (++i < n) ticks[i] = (start - i) / step;


      Depending on the value of steps. If you look at the tickIncrement function below, you can see that steps can only be 1, 2, 5 or 10 (and their negatives).



      And that's all you need to know the length of the array in the variable ticks above. Depending on the start and stop values (i.e., depending on the domain), sometimes we have more than 10 ticks (16 in your case), sometimes we have less than 10, even if the default count is 10. Have a look here:






      const s = d3.scaleLinear();

      console.log(s.domain([1,12]).ticks().length);
      console.log(s.domain([100,240]).ticks().length);
      console.log(s.domain([10,10]).ticks().length);
      console.log(s.domain([2,10]).ticks().length);
      console.log(s.domain([1,4]).ticks().length);

      <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>





      The last example, as you can see, gives us 16 ticks.






      share|improve this answer



























        1












        1








        1







        I'm gonna answer just the question in the title ("how is the number of ticks on an axis defined?"), not the one you made at the end ("What If I want to space the ticks more evenly, for example, I want to see a tick on every 12 or 6 hours?"), which is not related and quite simple to fix (and, besides that, it's certainly a duplicate).



        Your question demands a detective work. Our journey starts, of course, at d3.axisBottom(). If you look at the source code, you'll see that the number of ticks in the enter selection...



        tick = selection.selectAll(".tick").data(values, scale).order()


        ...depends on values, which is:



        var values = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain()) : tickValues


        What this line tells us is that, if tickValues is null (no tickValues used), the code should use scale.ticks for scales that have a ticks method (continuous), our just the scale's domain for ordinal scales.



        That leads us to the continuous scales. There, using a linear scale (which is the one you're using), we can see at the source code that scale.ticks returns this:



        scale.ticks = function(count) 
        var d = domain();
        return ticks(d[0], d[d.length - 1], count == null ? 10 : count);
        ;


        However, since ticks is imported from d3.array, we have to go there for seeing how the ticks are calculated. Also, since we didn't pass anything as count, count defaults to 10.



        So, finally, we arrive at this:



        start = Math.ceil(start / step);
        stop = Math.floor(stop / step);
        ticks = new Array(n = Math.ceil(stop - start + 1));
        while (++i < n) ticks[i] = (start + i) * step;


        Or this:



        start = Math.floor(start * step);
        stop = Math.ceil(stop * step);
        ticks = new Array(n = Math.ceil(start - stop + 1));
        while (++i < n) ticks[i] = (start - i) / step;


        Depending on the value of steps. If you look at the tickIncrement function below, you can see that steps can only be 1, 2, 5 or 10 (and their negatives).



        And that's all you need to know the length of the array in the variable ticks above. Depending on the start and stop values (i.e., depending on the domain), sometimes we have more than 10 ticks (16 in your case), sometimes we have less than 10, even if the default count is 10. Have a look here:






        const s = d3.scaleLinear();

        console.log(s.domain([1,12]).ticks().length);
        console.log(s.domain([100,240]).ticks().length);
        console.log(s.domain([10,10]).ticks().length);
        console.log(s.domain([2,10]).ticks().length);
        console.log(s.domain([1,4]).ticks().length);

        <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>





        The last example, as you can see, gives us 16 ticks.






        share|improve this answer















        I'm gonna answer just the question in the title ("how is the number of ticks on an axis defined?"), not the one you made at the end ("What If I want to space the ticks more evenly, for example, I want to see a tick on every 12 or 6 hours?"), which is not related and quite simple to fix (and, besides that, it's certainly a duplicate).



        Your question demands a detective work. Our journey starts, of course, at d3.axisBottom(). If you look at the source code, you'll see that the number of ticks in the enter selection...



        tick = selection.selectAll(".tick").data(values, scale).order()


        ...depends on values, which is:



        var values = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain()) : tickValues


        What this line tells us is that, if tickValues is null (no tickValues used), the code should use scale.ticks for scales that have a ticks method (continuous), our just the scale's domain for ordinal scales.



        That leads us to the continuous scales. There, using a linear scale (which is the one you're using), we can see at the source code that scale.ticks returns this:



        scale.ticks = function(count) 
        var d = domain();
        return ticks(d[0], d[d.length - 1], count == null ? 10 : count);
        ;


        However, since ticks is imported from d3.array, we have to go there for seeing how the ticks are calculated. Also, since we didn't pass anything as count, count defaults to 10.



        So, finally, we arrive at this:



        start = Math.ceil(start / step);
        stop = Math.floor(stop / step);
        ticks = new Array(n = Math.ceil(stop - start + 1));
        while (++i < n) ticks[i] = (start + i) * step;


        Or this:



        start = Math.floor(start * step);
        stop = Math.ceil(stop * step);
        ticks = new Array(n = Math.ceil(start - stop + 1));
        while (++i < n) ticks[i] = (start - i) / step;


        Depending on the value of steps. If you look at the tickIncrement function below, you can see that steps can only be 1, 2, 5 or 10 (and their negatives).



        And that's all you need to know the length of the array in the variable ticks above. Depending on the start and stop values (i.e., depending on the domain), sometimes we have more than 10 ticks (16 in your case), sometimes we have less than 10, even if the default count is 10. Have a look here:






        const s = d3.scaleLinear();

        console.log(s.domain([1,12]).ticks().length);
        console.log(s.domain([100,240]).ticks().length);
        console.log(s.domain([10,10]).ticks().length);
        console.log(s.domain([2,10]).ticks().length);
        console.log(s.domain([1,4]).ticks().length);

        <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>





        The last example, as you can see, gives us 16 ticks.






        const s = d3.scaleLinear();

        console.log(s.domain([1,12]).ticks().length);
        console.log(s.domain([100,240]).ticks().length);
        console.log(s.domain([10,10]).ticks().length);
        console.log(s.domain([2,10]).ticks().length);
        console.log(s.domain([1,4]).ticks().length);

        <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>





        const s = d3.scaleLinear();

        console.log(s.domain([1,12]).ticks().length);
        console.log(s.domain([100,240]).ticks().length);
        console.log(s.domain([10,10]).ticks().length);
        console.log(s.domain([2,10]).ticks().length);
        console.log(s.domain([1,4]).ticks().length);

        <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 24 at 7:56

























        answered Mar 24 at 2:54









        Gerardo FurtadoGerardo Furtado

        69.7k75498




        69.7k75498





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315220%2fhow-is-the-number-of-ticks-on-an-axis-defined%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현