Skip to content

Commit

Permalink
Deal with case of a single point in trichart, dotchart, add_points, a…
Browse files Browse the repository at this point in the history
…nd add_curves

 - Fixes Issue kbroman/qtlcharts#76
  • Loading branch information
kbroman committed Jul 20, 2021
1 parent 60214b8 commit d9f68e6
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 4 deletions.
10 changes: 9 additions & 1 deletion d3panels.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
!function() { // encapsulate d3panels functions
var d3panels = {
version: "1.6.4"
version: "1.7.1"
};
"use strict";

Expand Down Expand Up @@ -3472,6 +3472,8 @@ d3panels.dotchart = function (chartOpts) {

return results;
}();
group = d3panels.expand2vector(group, x.length); // force it to be a vector not scalar

ngroup = d3.max(group);

group = function () {
Expand Down Expand Up @@ -4585,6 +4587,8 @@ d3panels.add_curves = function (chartOpts) {

return results;
}();
group = d3panels.expand2vector(group, n_ind); // force it to be a vector not scalar

ngroup = d3.max(group);

group = function () {
Expand Down Expand Up @@ -4781,6 +4785,8 @@ d3panels.add_points = function (chartOpts) {

return results;
}();
group = d3panels.expand2vector(group, x.length); // force it to be a vector not scalar

ngroup = d3.max(group);

group = function () {
Expand Down Expand Up @@ -6086,6 +6092,8 @@ d3panels.trichart = function (chartOpts) {

return results;
}();
group = d3panels.expand2vector(group, n); // force it to be a vector not scalar

ngroup = d3.max(group);

group = function () {
Expand Down
2 changes: 1 addition & 1 deletion d3panels.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "d3panels",
"version": "1.6.4",
"version": "1.7.1",
"description": "D3-based graphics panels",
"author": "Karl Broman <[email protected]> (https://kbroman.org)",
"repository": "github:kbroman/d3panels",
Expand Down
1 change: 1 addition & 0 deletions src/add_curves.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ d3panels.add_curves = (chartOpts) ->
d3panels.displayError("add_curves: data.indID.length (#{indID.length}) != data.y.length (#{n_ind})")

group = data?.group ? (1 for i of y)
group = d3panels.expand2vector(group, n_ind) # force it to be a vector not scalar
ngroup = d3.max(group)
group = ((if g? then g-1 else g) for g in group) # changed from (1,2,3,...) to (0,1,2,...)
if d3panels.sumArray(g < 0 or g > ngroup-1 for g in group) > 0
Expand Down
1 change: 1 addition & 0 deletions src/add_points.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ d3panels.add_points = (chartOpts) ->

# groups of colors
group = data?.group ? (1 for i in x)
group = d3panels.expand2vector(group, x.length) # force it to be a vector not scalar
ngroup = d3.max(group)
group = ((if g? then g-1 else g) for g in group) # changed from (1,2,3,...) to (0,1,2,...)
if d3panels.sumArray(g < 0 or g > ngroup-1 for g in group) > 0
Expand Down
2 changes: 1 addition & 1 deletion src/d3panels_top.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!function() { // encapsulate d3panels functions
var d3panels = {
version: "1.6.4"
version: "1.7.1"
};
1 change: 1 addition & 0 deletions src/dotchart.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ d3panels.dotchart = (chartOpts) ->

# groups of colors
group = data?.group ? (1 for i in x)
group = d3panels.expand2vector(group, x.length) # force it to be a vector not scalar
ngroup = d3.max(group)
group = ((if g? then g-1 else g) for g in group) # changed from (1,2,3,...) to (0,1,2,...)
if d3panels.sumArray(g < 0 or g > ngroup-1 for g in group) > 0
Expand Down
1 change: 1 addition & 0 deletions src/trichart.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ d3panels.trichart = (chartOpts) ->

# groups of colors
group = data?.group ? (1 for i of p)
group = d3panels.expand2vector(group, n) # force it to be a vector not scalar
ngroup = d3.max(group)
group = ((if g? then g-1 else g) for g in group) # changed from (1,2,3,...) to (0,1,2,...)
if d3panels.sumArray(g < 0 or g > ngroup-1 for g in group) > 0
Expand Down

0 comments on commit d9f68e6

Please sign in to comment.