Skip to content

Commit

Permalink
transitions enabled after plot is initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
mwasiluk committed Aug 30, 2016
1 parent 01c15a0 commit abc8781
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 23 deletions.
29 changes: 18 additions & 11 deletions dist/odc-d3.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/odc-d3.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/odc-d3.min.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ export class Chart {

this._attached[attachmentName].update(attachmentData);
}
console.log('base uppdate');
return this;
}

Expand Down Expand Up @@ -355,4 +354,8 @@ export class Chart {
this.plot.width = Utils.availableWidth(this.config.width, this.getBaseContainer(), this.plot.margin);
this.plot.height = Utils.availableHeight(this.config.height, this.getBaseContainer(), this.plot.margin);
}

transitionEnabled(){
return this._isInitialized && this.config.transition;
}
}
8 changes: 6 additions & 2 deletions src/histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,18 @@ export class Histogram extends Chart{
.append("rect")
.attr("x", 1);

bar.attr("transform", function(d) { return "translate(" + plot.x.scale(d.x) + "," + (plot.y.scale(d.y)) + ")"; });

var barRect = bar.select("rect");

var barRectT = barRect;
if (self.config.transition) {
var barT = bar;
if (this.transitionEnabled()) {
barRectT = barRect.transition();
barT = bar.transition();
}

barT.attr("transform", function(d) { return "translate(" + plot.x.scale(d.x) + "," + (plot.y.scale(d.y)) + ")"; });

barRectT
.attr("width", plot.x.scale(plot.histogramBins[0].dx) - plot.x.scale(0)- 1)
.attr("height", d => plot.height - plot.y.scale(d.y));
Expand Down
4 changes: 2 additions & 2 deletions src/regression.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export class Regression extends ScatterPlot{


var lineT = line;
if (self.config.transition) {
if (self.transitionEnabled()) {
lineT = line.transition();
}

Expand All @@ -285,7 +285,7 @@ export class Regression extends ScatterPlot{
var area = regression.select("path."+confidenceAreaClass);

var areaT = area;
if (self.config.transition) {
if (self.transitionEnabled()) {
areaT = area.transition();
}
areaT.attr("d", r => r.confidence.area(r.confidence.points));
Expand Down
6 changes: 3 additions & 3 deletions src/scatterplot.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class ScatterPlot extends Chart{
.attr("transform", "translate(0," + plot.height + ")");

var axisT = axis;
if (self.config.transition) {
if (self.transitionEnabled()) {
axisT = axis.transition().ease("sin-in-out");
}

Expand All @@ -184,7 +184,7 @@ export class ScatterPlot extends Chart{
var axis = self.svgG.selectOrAppend("g."+self.prefixClass('axis-y')+"."+self.prefixClass('axis')+(self.config.guides ? '' : '.'+self.prefixClass('no-guides')));

var axisT = axis;
if (self.config.transition) {
if (self.transitionEnabled()) {
axisT = axis.transition().ease("sin-in-out");
}

Expand Down Expand Up @@ -224,7 +224,7 @@ export class ScatterPlot extends Chart{
.attr("class", dotClass);

var dotsT = dots;
if (self.config.transition) {
if (self.transitionEnabled()) {
dotsT = dots.transition();
}

Expand Down

0 comments on commit abc8781

Please sign in to comment.