Skip to content

Commit

Permalink
Release 0.9.89
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaime del Palacio committed Jun 17, 2014
1 parent 6903f70 commit eeb19ee
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
36 changes: 20 additions & 16 deletions dist/contour.js
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@

})();

Contour.version = '0.9.88';
Contour.version = '0.9.89';
(function () {

var helpers = {
Expand Down Expand Up @@ -3387,15 +3387,24 @@ Contour.export('nullVis', _.noop);

(function () {

function normalizeDataSet(dataSet) {
var all = _.flatten(_.pluck(dataSet, 'data'));
var isLinear = all.length && _.isNumber(all[0].x);
var normalizer = function (d, i) { return { x: i, y: d.y }; }

function ctor(data, layer, options) {
return isLinear ? all : _.map(all, normalizer);
}

function ctor(raw, layer, options) {
this.checkDependencies('cartesian');
var data = normalizeDataSet(raw);
var duration = options.chart.animations.duration != null ? options.chart.animations.duration : 400;
var shouldAnimate = options.chart.animations && options.chart.animations.enable;
var x = _.bind(function(d) { return this.xScale(d) + this.rangeBand / 2; }, this);
var y = _.bind(function(d) { return this.yScale(d); }, this);
var regression = _.nw.linearRegression(_.flatten(_.pluck(data, 'data')));
var regression = _.nw.linearRegression(data);
var domain = d3.extent(this.xScale.domain());
var numericDomain = d3.extent(data, function(p) { return p.x; });
var lineY = function (x) { return regression.intercept + regression.slope * x; };

var line = layer.selectAll('.trend-line')
Expand All @@ -3404,25 +3413,20 @@ Contour.export('nullVis', _.noop);
line.enter().append('line')
.attr('class', 'trend-line')
.attr('x1', x(domain[0]))
.attr('y1', y(lineY(domain[0])))
.attr('y1', y(lineY(numericDomain[0])))
.attr('x2', x(domain[0]))
.attr('y2', y(lineY(domain[0])));
.attr('y2', y(lineY(numericDomain[0])));

line.exit().remove();

if (shouldAnimate) {
line.transition().duration(duration)
.attr('x1', x(domain[0]))
.attr('y1', y(lineY(domain[0])))
.attr('x2', x(domain[1]))
.attr('y2', y(lineY(domain[1])));
} else {
line
.attr('x1', x(domain[0]))
.attr('y1', y(lineY(domain[0])))
.attr('x2', x(domain[1]))
.attr('y2', y(lineY(domain[1])));
line = line.transition().duration(duration);
}

line.attr('x1', x(domain[0]))
.attr('y1', y(lineY(numericDomain[0])))
.attr('x2', x(domain[1]))
.attr('y2', y(lineY(numericDomain[1])));
}

ctor.defaults = {};
Expand Down
6 changes: 3 additions & 3 deletions dist/contour.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/contour.min.map

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,7 +1,7 @@
{
"name": "Contour",
"description": "Forio's Visualization Library",
"version": "0.9.88",
"version": "0.9.89",
"dependencies": {
"lodash": "~2.4.1",
"d3": "~3.3.0"
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/core/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Contour.version = '0.9.88';
Contour.version = '0.9.89';

0 comments on commit eeb19ee

Please sign in to comment.