Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Bubbles マップに D3.js DataMaps を使用しています。私のマップの問題は、最大のバブルが他のすべてのバブルの上に積み上げられていることです。半径に基づいてこれらのバブルをソートするにはどうすればよいですか??
バブルデータはオブジェクトの配列であるため、このようなカスタムソート関数を使用できます
myBubblesData.sort(function(a, b){ if (a.radius < b.radius) { return 1; } if (a.radius > b.radius) { return -1; } return 0; });
逆の順序でソートされたオブジェクトを返すには、'1' と '-1' の return ステートメントを逆にします。