简体   繁体   中英

ticks start douplicating on zooming d3js

I implemented zoom in a d3 line chart.Working fine. But after zooming at some level.The ticks in y axis started to come in decimal number like ( 3.400000001) then I added the code

.tickFormat(d3.format(",.0f"))

Then the problem was solved the number became whole number. But now another problem arises that on zooming on some level the same number started to repeat on y-axis. How to solve that problem

Or tell me a way to limit the ticks in y-axis to two decimal places.

This is my code for Yaxis

var yAxis = d3.svg.axis().scale(y).tickFormat(d3.format(",.0f")).ticks(10).orient("left");

尝试这样:

var yAxis = d3.svg.axis().orient("left").scale(y).ticks(10, d3.format(",d")).tickSubdivide(4).tickSize(6, 3, 0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM