How to calculate the scale's result?

后端 未结 2 577
耶瑟儿~
耶瑟儿~ 2020-12-11 20:50

I am new to d3.js library, and I am trying to understand the concept of domain and ranges.

I read Scott Murray\'s book, but I don\'t know how to calculate it.

<
2条回答
  •  猫巷女王i
    2020-12-11 21:36

    Yes I will try to explain why you get 180.

    We have that 300 is the value that ideally divide your domain into two subdomains of the same size, so we can do: 500 - 100 / 2 = 200 (this is the subdomain size), this implies that the middle value is located at:
    200 + 100 = 300 (note that we add the starting point 100)

    So with the range we do the same:
    350 - 10 / 2 = 170 and then we add the starting point 170 + 10 = 180

提交回复
热议问题