Commit c0e5b963 authored by Mike Bostock's avatar Mike Bostock
Browse files

Fix two sorting bugs in chord layout.

We still weren't sorting subgroups correctly. Also, we now sort chords by their
average value, rather than the source value, which works well with one-sided
chords (where either the source or target value is zero).
parent 2f6d2fa0
......@@ -10,7 +10,7 @@ try {
d3_style_setProperty.call(this, name, value + "", priority);
};
}
d3 = {version: "2.4.5"}; // semver
d3 = {version: "2.4.6"}; // semver
var d3_array = d3_arraySlice; // conversion for NodeLists
function d3_arrayCopy(pseudoarray) {
......
......@@ -116,7 +116,7 @@ d3.layout.chord = function() {
x = 0, i = -1; while (++i < n) {
x0 = x, j = -1; while (++j < n) {
var di = groupIndex[i],
dj = subgroupIndex[i][j],
dj = subgroupIndex[di][j],
v = matrix[di][dj];
subgroups[di + "-" + dj] = {
index: di,
......@@ -153,7 +153,9 @@ d3.layout.chord = function() {
function resort() {
chords.sort(function(a, b) {
return sortChords(a.target.value, b.target.value);
return sortChords(
(a.source.value + a.target.value) / 2,
(b.source.value + b.target.value) / 2);
});
}
......
This diff is collapsed.
This diff is collapsed.
{
"name": "d3",
"version": "2.4.5",
"version": "2.4.6",
"description": "A small, free JavaScript library for manipulating documents based on data.",
"keywords": [
"dom",
......
d3 = {version: "2.4.5"}; // semver
d3 = {version: "2.4.6"}; // semver
......@@ -58,7 +58,7 @@ d3.layout.chord = function() {
x = 0, i = -1; while (++i < n) {
x0 = x, j = -1; while (++j < n) {
var di = groupIndex[i],
dj = subgroupIndex[i][j],
dj = subgroupIndex[di][j],
v = matrix[di][dj];
subgroups[di + "-" + dj] = {
index: di,
......@@ -95,7 +95,9 @@ d3.layout.chord = function() {
function resort() {
chords.sort(function(a, b) {
return sortChords(a.target.value, b.target.value);
return sortChords(
(a.source.value + a.target.value) / 2,
(b.source.value + b.target.value) / 2);
});
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment