Last active
January 7, 2016 19:12
-
-
Save panda01/eb120050eabdacef3438 to your computer and use it in GitHub Desktop.
Charts!!!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Vector = require('vector'); | |
const Tangible = require('tangible') | |
class Chart extends Tangible { | |
constructor(options) { | |
super(null, new Vector(options.width, options.height)); | |
} | |
get margin() { return this._margin; } | |
set margin(obj) { | |
// only do a partial update if necessary | |
this._margin = _.assign({}, this.margin, obj); | |
} | |
get xAxis() { return this._xAxis; } | |
set xAxis(axis) { | |
this._xAxis = axis; | |
} | |
get yAxis() { return this._yAxis; } | |
set yAxis(axis) { | |
this._yAxis = axis; | |
} | |
get xScale() { return this._xScale; } | |
set xScale(scale) { | |
this._xScale = scale; | |
} | |
get yScale() { return this._yScale; } | |
set yScale(scale) { | |
this._yScale = scale; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Vector = require('vector'); | |
class Tangible { | |
constructor(position, dimension) { | |
this.pos = position; | |
this.dim = dimension; | |
} | |
get pos() { return this._pos; } | |
set pos(vector) { | |
this._pos = vector ? vector : new Vector(); | |
} | |
get dim() { return this._dim; } | |
set dim(vector) { | |
this._dim = vector ? vector : new Vector(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Vector { | |
constructor(x, y) { | |
this.x = x; | |
this.y = y; | |
} | |
get x() { return this._x; } | |
set x(val) { | |
// Should these accept decimals? | |
this._x = val ? parseInt(val, 10) : 0; | |
} | |
get y() { return this._y; } | |
set y(val) { | |
this._y = val ? parseInt(val, 10) : 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment