在d3.js中设置日志缩放的基数 [英] setting the base for log scale in d3.js

查看:103
本文介绍了在d3.js中设置日志缩放的基数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是d3的新手,只是得到它的挂起。我的要求很简单。我想要将x轴对数缩放到某个十进制数的基数。默认日志标度的基数为10.并且精简引用API和web hasnt让我有一种改变基础的方法。可能是我缺少一些基本的关于d3。但我似乎不能超越这个障碍。理想情况下,应该有一个log.base()类似于power.exponent()的幂级别

I'm new to d3, and just getting the hang of it. My requirement is pretty simple. I want the x-axis to be log scaled to a base of some decimal number. The default log scale has a base of 10. And scouring the reference API and the web hasnt yielded me a way of changing the base. Might be i'm missing something basic about d3. But i cant seem to get past this obstacle. Ideally, shouldnt there be a log.base() similar to the pow.exponent() for the power scale

推荐答案

这样的功能(虽然它不会太难添加一个)。你最好的办法是编写自己的函数,做你指定的必要的对数转换,然后将结果传递到一个正常的线性尺度,得到最终的值。

There isn't such a function (although it wouldn't be too hard to add one). Your best bet is to write your own function that does the necessary log transformation you specify and then passes the result on to a normal linear scale to get the final value.

这篇关于在d3.js中设置日志缩放的基数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆