Skip to content

Commit

Permalink
Make variable names consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
vladminsky committed Mar 10, 2016
1 parent 82f2f40 commit d753d24
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 34 deletions.
37 changes: 18 additions & 19 deletions src/elements/element.line.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -176,27 +176,27 @@ 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
});

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
});
}
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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({
Expand Down Expand Up @@ -304,15 +304,14 @@ export class Line extends Element {
}

highlightDataPoints(filter) {
var lineModel = this.lineModel;
const cssClass = 'i-data-anchor';
this.config
.options
.container
.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)}`)
});
}
}
20 changes: 10 additions & 10 deletions src/elements/element.path.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions src/elements/element.point.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,18 @@ 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,
sizeScale: this.size
});

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 () {
Expand Down

0 comments on commit d753d24

Please sign in to comment.