Skip to content

Commit

Permalink
delete top if breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
pdgago committed May 29, 2015
1 parent 6115d0e commit a6d137f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
11 changes: 11 additions & 0 deletions charicharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,17 @@ var p_axes = PClass.extend({
.attr('class', 'yaxis left')
.call(model.axis);

// Remove last tick if touches the top axis
if (this.opts.xaxis.top.enabled) {
try {
var lastTick = _.last(model.el.selectAll('.tick')[0]);
var lastTickY = Number(lastTick.attributes.transform.textContent.match(/,(.*)\)$/)[1]);
if (lastTickY < 20) {
lastTick.remove();
}
} catch (e) {}
}

this._renderYLabel('left');
},

Expand Down
4 changes: 2 additions & 2 deletions charicharts.min.js

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions demo/charicharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,17 @@ var p_axes = PClass.extend({
.attr('class', 'yaxis left')
.call(model.axis);

// Remove last tick if touches the top axis
if (this.opts.xaxis.top.enabled) {
try {
var lastTick = _.last(model.el.selectAll('.tick')[0]);
var lastTickY = Number(lastTick.attributes.transform.textContent.match(/,(.*)\)$/)[1]);
if (lastTickY < 20) {
lastTick.remove();
}
} catch (e) {}
}

this._renderYLabel('left');
},

Expand Down
3 changes: 2 additions & 1 deletion demo/simple-chart-date.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
}
svg,
body {
margin-top: 20px;
background: white;
}
text {
Expand Down Expand Up @@ -70,7 +71,7 @@

var options = {
target: d3.select('body').node(),
margin: '60 10 25 30',
margin: '100 10 25 30',
yaxis: {
fit: true,
textMarginTop: -10,
Expand Down
11 changes: 11 additions & 0 deletions src/parts/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ var p_axes = PClass.extend({
.attr('class', 'yaxis left')
.call(model.axis);

// Remove last tick if touches the top axis
if (this.opts.xaxis.top.enabled) {
try {
var lastTick = _.last(model.el.selectAll('.tick')[0]);
var lastTickY = Number(lastTick.attributes.transform.textContent.match(/,(.*)\)$/)[1]);
if (lastTickY < 20) {
lastTick.remove();
}
} catch (e) {}
}

this._renderYLabel('left');
},

Expand Down

0 comments on commit a6d137f

Please sign in to comment.