Skip to content

Commit

Permalink
Proper tick position for right positioned axis (chartjs#5401)
Browse files Browse the repository at this point in the history
* Proper tick position for right positioned axis
* Test for tick mark drawing
  • Loading branch information
etimberg committed Apr 11, 2018
1 parent 21a0108 commit 06a06b1
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/core.scale.js
Expand Up @@ -705,8 +705,8 @@ module.exports = Element.extend({
var itemsToDraw = [];

var axisWidth = me.options.gridLines.lineWidth;
var xTickStart = options.position === 'right' ? me.right : me.right - axisWidth - tl;
var xTickEnd = options.position === 'right' ? me.right + tl : me.right;
var xTickStart = options.position === 'right' ? me.left : me.right - axisWidth - tl;
var xTickEnd = options.position === 'right' ? me.left + tl : me.right;
var yTickStart = options.position === 'bottom' ? me.top + axisWidth : me.bottom - tl - axisWidth;
var yTickEnd = options.position === 'bottom' ? me.top + axisWidth + tl : me.bottom + axisWidth;

Expand Down
79 changes: 79 additions & 0 deletions test/fixtures/core.scale/tick-drawing.json
@@ -0,0 +1,79 @@
{
"config": {
"type": "horizontalBar",
"data": {
"labels": ["January", "February", "March", "April", "May", "June", "July"],
"datasets": []
},
"options": {
"legend": false,
"title": false,
"scales": {
"xAxes": [{
"type": "category",
"position": "top",
"id": "x-axis-1",
"ticks": {
"display": false
},
"gridLines":{
"drawOnChartArea": false,
"drawBorder": false,
"color": "rgba(0, 0, 0, 1)",
"zeroLineColor": "rgba(0, 0, 0, 1)"
}
}, {
"type": "category",
"position": "bottom",
"id": "x-axis-2",
"ticks": {
"display": false
},
"gridLines":{
"drawOnChartArea": false,
"drawBorder": false,
"color": "rgba(0, 0, 0, 1)",
"zeroLineColor": "rgba(0, 0, 0, 1)"
}
}],
"yAxes": [{
"position": "left",
"id": "y-axis-1",
"type": "linear",
"ticks": {
"display": false,
"min": -100,
"max": 100
},
"gridLines":{
"drawOnChartArea": false,
"drawBorder": false,
"color": "rgba(0, 0, 0, 1)",
"zeroLineColor": "rgba(0, 0, 0, 1)"
}
}, {
"type": "linear",
"id": "y-axis-2",
"position": "right",
"ticks": {
"display": false,
"min": 0,
"max": 50
},
"gridLines":{
"drawOnChartArea": false,
"drawBorder": false,
"color": "rgba(0, 0, 0, 1)",
"zeroLineColor": "rgba(0, 0, 0, 1)"
}
}]
}
}
},
"options": {
"canvas": {
"height": 256,
"width": 512
}
}
}
Binary file added test/fixtures/core.scale/tick-drawing.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 06a06b1

Please sign in to comment.