question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

integer only of the x,y axis

See original GitHub issue

how to make the axis tick to be integer only? qq 20141015141217

what I have tried is to use the tick option:

tick: {
    format: function(x) {
        return (x == Math.floor(x)) ? x : "";
    }
}

this can make the label only show integer, but the divid line on the axis still exits. qq 20141015141829

is there a way to control the axis tick?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
nnabinhcommented, Jun 16, 2017

Better version:

    axis: {
        y: {
            tick: {
                format: function(x) { return x % 1 === 0 ? x : ''; }
            }
        }
    }
7reactions
ryanacommented, Dec 28, 2015

FWIW, requiring knowing the internals of D3 and running JS seems really odd. I see that pattern a lot in these C3 issues: someone has a problem, and instead of offering a C3 option, 5-30 lines of javascript that manipulating the underlying SVG is with d3 is the accepted solution. I think in the long run that’s going to be a huge detriment to the adoption of C3.

For this issue in particular, a “axis.y.tick.integer_only” option would be of incredible value. I’d love to provide an extension to C3 for this. I see an example extension here. Is there an extension guide somewhere that can guide me?

Thanks!

Edit: grammar.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to force the Y axis to use only integers in Matplotlib?
Set the X-axis label using plt.xlabel() method. Set the Y-axis label using plt.ylabel() method. Set a title for the axes.
Read more >
How to force the Y axis to only use integers - Stack Overflow
I'm plotting a histogram using the matplotlib.pyplot module and I am wondering how I can force the y-axis labels to only show integers...
Read more >
Integer Values on Line Chart Category Axis - Peltier Tech
Although the category axis is defined by the line chart series, the XY series is not constrained by the whole-number-only restriction.
Read more >
MS Excel - How can I control whole number axis values to ...
I am trying to create a risk (5 by 5) matrix that only should show integer values for x and ...
Read more >
How to show only integers (no decimals) in chart API x/y-axis ...
Hi, When I create a chart, decimal values ​​are not, but on the y axis shows decimal values​​, how can I do to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found