regression: in d3.bin, values next to a threshold go into the wrong bin

オープン
#295 コメント 0 件 リアクション 1 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Fil がすでに取り組んでいます。

2026年11月9日 から。

  • #296 @Fil による — オープン

評価

この issue はまだ評価されていません。

説明

d3.bin().domain([0, 1]).thresholds(10)([0.3 * 3]) // 0.3 * 3 is 0.8999999999999999

puts the value in the bin [0.9, 1] instead of [0.8, 0.9]. With the same thresholds passed explicitly, d3.bin().domain([0, 1]).thresholds(d3.ticks(0, 1, 10).slice(1, -1)), it goes into [0.8, 0.9].

The same happens with an integer step: d3.bin().domain([-10, 10]).thresholds(10)([1.9999999999999998]) puts the value in [2, 4] instead of [0, 2].

Since 3.1.3 (#220), when the domain is aligned with the thresholds, bin computes the index of a value's bin as Math.floor((x - x0) / step) (or Math.floor((x0 - x) * step) for a fractional step). This division or multiplication can round across an integer. Only the underestimate is corrected, and only for fractional steps. 3.1.2 put these values in the correct bins.

主要言語
JavaScript
スター
465
フォーク
193
平均マージ
5時間 46分
マージ済み PR(30日)
1

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

d3/d3-array のほかの issue

d3/d3-array の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。