diff --git a/src/elements/element.line.js b/src/elements/element.line.js index b756487f8..cad941205 100644 --- a/src/elements/element.line.js +++ b/src/elements/element.line.js @@ -138,14 +138,14 @@ export class Line extends Element { var fullData = frames.reduce(((memo, f) => memo.concat(f.part())), []); - var lineModel = this.buildModel({ + var model = this.buildModel({ xScale: this.xScale, yScale: this.yScale, sizeScale: this.size, colorScale: this.color, textScale: this.text }); - this.lineModel = lineModel; + this.model = model; var widthCss = guide.widthCssClass || getLineClassesByWidth(options.width); var countCss = getLineClassesByCount(frames.length); @@ -154,7 +154,7 @@ export class Line extends Element { const pointPref = `${CSS_PREFIX}dot-line dot-line i-role-element ${datumClass} ${CSS_PREFIX}dot `; const linePref = `${CSS_PREFIX}line i-role-element line ${widthCss} ${countCss} ${guide.cssClass} `; - var d3Line = d3.svg.line().x(lineModel.x).y(lineModel.y); + var d3Line = d3.svg.line().x(model.x).y(model.y); if (guide.interpolate) { d3Line.interpolate(guide.interpolate); @@ -176,14 +176,14 @@ export class Line extends Element { self.subscribe(path, function (rows) { var m = d3.mouse(this); - return lineModel.matchRowInCoordinates(rows, {x: m[0], y: m[1]}); + return model.matchRowInCoordinates(rows, {x: m[0], y: m[1]}); }); if (guide.showAnchors && !this.empty()) { var anch = elementDecoratorShowAnchors({ - xScale: lineModel.scaleX, - yScale: lineModel.scaleY, + xScale: model.scaleX, + yScale: model.scaleY, guide, container: this }); @@ -191,12 +191,12 @@ export class Line extends Element { self.subscribe(anch); } - if (lineModel.scaleText.dim && !this.empty()) { + if (model.scaleText.dim && !this.empty()) { elementDecoratorShowText({ guide, - xScale: lineModel.scaleX, - yScale: lineModel.scaleY, - textScale: lineModel.scaleText, + xScale: model.scaleX, + yScale: model.scaleY, + textScale: model.scaleText, container: this }); } @@ -205,10 +205,10 @@ export class Line extends Element { var updatePoints = function () { var attr = { - r: ({data:d}) => lineModel.size(d), - cx: ({data:d}) => lineModel.x(d), - cy: ({data:d}) => lineModel.y(d), - class: ({data:d}) => (`${pointPref} ${lineModel.color(d)}`) + r: ({data:d}) => model.size(d), + cx: ({data:d}) => model.x(d), + cy: ({data:d}) => model.y(d), + class: ({data:d}) => (`${pointPref} ${model.color(d)}`) }; var dots = this @@ -229,11 +229,11 @@ export class Line extends Element { return function () { this.attr('class', ({data: f}) => - `${linePref} ${lineModel.color(f.data[0])} ${x} frame-${f.hash}`) + `${linePref} ${model.color(f.data[0])} ${x} frame-${f.hash}`) .call(function () { if (isLine) { - if (guide.color.fill && !lineModel.scaleColor.dim) { + if (guide.color.fill && !model.scaleColor.dim) { this.style({ fill: guide.color.fill, stroke: guide.color.fill @@ -248,7 +248,7 @@ export class Line extends Element { }; }; - var groups = _.groupBy(fullData, lineModel.group); + var groups = _.groupBy(fullData, model.group); var fibers = Object.keys(groups).reduce( (memo, k) => { return memo.concat({ @@ -304,7 +304,6 @@ export class Line extends Element { } highlightDataPoints(filter) { - var lineModel = this.lineModel; const cssClass = 'i-data-anchor'; this.config .options @@ -312,7 +311,7 @@ export class Line extends Element { .selectAll(`.${cssClass}`) .attr({ r: (d) => (filter(d) ? 3 : this.config.guide.anchorSize), - class: (d) => (`${cssClass} ${lineModel.color(d)}`) + class: (d) => (`${cssClass} ${this.model.color(d)}`) }); } } \ No newline at end of file diff --git a/src/elements/element.path.js b/src/elements/element.path.js index b20132314..593d4caf6 100644 --- a/src/elements/element.path.js +++ b/src/elements/element.path.js @@ -78,29 +78,29 @@ export class Path extends Element { var self = this; var args = {xScale, yScale, sizeScale, colorScale, dataSource}; - var model = this + var pathModel = this .decorators .filter(x => x) .reduce(((model, transform) => transform(model, args)), (new PathModel())); return { - scaleX: model.scaleX, - scaleY: model.scaleY, + scaleX: pathModel.scaleX, + scaleY: pathModel.scaleY, scaleColor: colorScale, scaleText: textScale, - x: model.xi, - y: model.yi, - size: model.size, - group: model.group, - color: model.color, + x: pathModel.xi, + y: pathModel.yi, + size: pathModel.size, + group: pathModel.group, + color: pathModel.color, matchRowInCoordinates(rows, {x, y}) { // d3.invert doesn't work for ordinal axes var nearest = self .unpackFrameData(rows) .map((row) => { - var rx = model.xi(row); - var ry = model.yi(row); + var rx = pathModel.xi(row); + var ry = pathModel.yi(row); return { x: rx, y: ry, diff --git a/src/elements/element.point.js b/src/elements/element.point.js index dc6069a6d..4d2d17120 100644 --- a/src/elements/element.point.js +++ b/src/elements/element.point.js @@ -96,7 +96,7 @@ export class Point extends Element { var prefix = `${CSS_PREFIX}dot dot i-role-element i-role-datum`; - var pointModel = this.buildModel({ + var model = this.buildModel({ xScale: this.xScale, yScale: this.yScale, colorScale: this.color, @@ -104,10 +104,10 @@ export class Point extends Element { }); var attr = { - r: (({data:d}) => pointModel.size(d)), - cx: (({data:d}) => pointModel.x(d)), - cy: (({data:d}) => pointModel.y(d)), - class: (({data:d}) => `${prefix} ${pointModel.color(d)}`) + r: (({data:d}) => model.size(d)), + cx: (({data:d}) => model.x(d)), + cy: (({data:d}) => model.y(d)), + class: (({data:d}) => `${prefix} ${model.color(d)}`) }; var enter = function () {