Skip to content

Commit ca8cbf8

Browse files
committed
make band optional
1 parent 8d6cee7 commit ca8cbf8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/marks/linearRegression.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {create, extent, range, sum, area as shapeArea} from "d3";
2-
import {identity, indexOf, maybeZ} from "../options.js";
2+
import {identity, indexOf, isNone, maybeZ, number} from "../options.js";
33
import {Mark} from "../plot.js";
44
import {qt} from "../stats.js";
55
import {applyDirectStyles, applyGroupedChannelStyles, applyIndirectStyles, applyTransform, groupZ, offset} from "../style.js";
@@ -30,9 +30,9 @@ class LinearRegression extends Mark {
3030
defaults
3131
);
3232
this.z = z;
33-
this.p = +p;
33+
this.p = number(p);
3434
this.precision = +precision;
35-
if (!(0 < this.p && this.p < 0.5)) throw new Error(`invalid p; not in (0, 0.5): ${p}`);
35+
if (this.p !== null && !(0 < this.p && this.p < 0.5)) throw new Error(`invalid p; not in [0, 0.5): ${p}`);
3636
if (!(this.precision > 0)) throw new Error(`invalid precision: ${precision}`);
3737
}
3838
render(I, {x, y}, channels, dimensions) {
@@ -44,11 +44,11 @@ class LinearRegression extends Mark {
4444
.call(g => g.selectAll()
4545
.data(Z ? groupZ(I, Z, this.z) : [I])
4646
.enter()
47-
.call(enter => enter.append("path")
47+
.call(this.p && !isNone(this.fill) ? enter => enter.append("path")
4848
.attr("stroke", "none")
4949
.call(applyDirectStyles, this)
5050
.call(applyGroupedChannelStyles, this, {...channels, stroke: null, strokeOpacity: null, strokeWidth: null})
51-
.attr("d", I => this._renderBand(I, X, Y)))
51+
.attr("d", I => this._renderBand(I, X, Y)) : () => {})
5252
.call(enter => enter.append("path")
5353
.attr("fill", "none")
5454
.call(applyDirectStyles, this)

0 commit comments

Comments
 (0)