Skip to content

Commit

Permalink
Draw the rightmost grid line when offsetGridLines is true (#6326)
Browse files Browse the repository at this point in the history
* Draw the rightmost grid line when offsetGridLines is true

* Refactor based on feedback

* Replace helpers.each with for loop

* Minor refactoring

* Refactor _computeItemsToDraw
  • Loading branch information
nagix authored and etimberg committed Jul 18, 2019
1 parent 28fdffb commit 626d8cc
Show file tree
Hide file tree
Showing 8 changed files with 205 additions and 150 deletions.
329 changes: 192 additions & 137 deletions src/core/core.scale.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/scales/scale.radialLinear.js
Expand Up @@ -18,7 +18,7 @@ var defaultConfig = {

angleLines: {
display: true,
color: 'rgba(0, 0, 0, 0.1)',
color: 'rgba(0,0,0,0.1)',
lineWidth: 1,
borderDash: [],
borderDashOffset: 0.0
Expand Down
12 changes: 6 additions & 6 deletions test/specs/core.scale.tests.js
Expand Up @@ -89,12 +89,12 @@ describe('Core.scale', function() {
labels: ['tick1', 'tick2', 'tick3', 'tick4', 'tick5'],
offsetGridLines: true,
offset: false,
expected: [-63.5, 64.5, 192.5, 320.5, 448.5]
expected: [64.5, 192.5, 320.5, 448.5]
}, {
labels: ['tick1', 'tick2', 'tick3', 'tick4', 'tick5'],
offsetGridLines: true,
offset: true,
expected: [0.5, 102.5, 204.5, 307.5, 409.5]
expected: [0.5, 102.5, 204.5, 307.5, 409.5, 512.5]
}, {
labels: ['tick1'],
offsetGridLines: false,
Expand All @@ -109,16 +109,16 @@ describe('Core.scale', function() {
labels: ['tick1'],
offsetGridLines: true,
offset: false,
expected: [-511.5]
expected: [512.5]
}, {
labels: ['tick1'],
offsetGridLines: true,
offset: true,
expected: [0.5]
expected: [0.5, 512.5]
}];

gridLineTests.forEach(function(test) {
it('should get the correct pixels for ' + test.labels.length + ' gridLine(s) for the horizontal scale when offsetGridLines is ' + test.offsetGridLines + ' and offset is ' + test.offset, function() {
it('should get the correct pixels for gridLine(s) for the horizontal scale when offsetGridLines is ' + test.offsetGridLines + ' and offset is ' + test.offset, function() {
var chart = window.acquireChart({
type: 'line',
data: {
Expand Down Expand Up @@ -163,7 +163,7 @@ describe('Core.scale', function() {
});

gridLineTests.forEach(function(test) {
it('should get the correct pixels for ' + test.labels.length + ' gridLine(s) for the vertical scale when offsetGridLines is ' + test.offsetGridLines + ' and offset is ' + test.offset, function() {
it('should get the correct pixels for gridLine(s) for the vertical scale when offsetGridLines is ' + test.offsetGridLines + ' and offset is ' + test.offset, function() {
var chart = window.acquireChart({
type: 'line',
data: {
Expand Down
2 changes: 1 addition & 1 deletion test/specs/scale.category.tests.js
Expand Up @@ -13,7 +13,7 @@ describe('Category scale tests', function() {
display: true,

gridLines: {
color: 'rgba(0, 0, 0, 0.1)',
color: 'rgba(0,0,0,0.1)',
drawBorder: true,
drawOnChartArea: true,
drawTicks: true, // draw ticks extending towards the label
Expand Down
2 changes: 1 addition & 1 deletion test/specs/scale.linear.tests.js
Expand Up @@ -11,7 +11,7 @@ describe('Linear Scale', function() {
display: true,

gridLines: {
color: 'rgba(0, 0, 0, 0.1)',
color: 'rgba(0,0,0,0.1)',
drawBorder: true,
drawOnChartArea: true,
drawTicks: true, // draw ticks extending towards the label
Expand Down
2 changes: 1 addition & 1 deletion test/specs/scale.logarithmic.tests.js
Expand Up @@ -10,7 +10,7 @@ describe('Logarithmic Scale tests', function() {
expect(defaultConfig).toEqual({
display: true,
gridLines: {
color: 'rgba(0, 0, 0, 0.1)',
color: 'rgba(0,0,0,0.1)',
drawBorder: true,
drawOnChartArea: true,
drawTicks: true,
Expand Down
4 changes: 2 additions & 2 deletions test/specs/scale.radialLinear.tests.js
Expand Up @@ -13,7 +13,7 @@ describe('Test the radial linear scale', function() {
expect(defaultConfig).toEqual({
angleLines: {
display: true,
color: 'rgba(0, 0, 0, 0.1)',
color: 'rgba(0,0,0,0.1)',
lineWidth: 1,
borderDash: [],
borderDashOffset: 0.0
Expand All @@ -22,7 +22,7 @@ describe('Test the radial linear scale', function() {
display: true,
gridLines: {
circular: false,
color: 'rgba(0, 0, 0, 0.1)',
color: 'rgba(0,0,0,0.1)',
drawBorder: true,
drawOnChartArea: true,
drawTicks: true,
Expand Down
2 changes: 1 addition & 1 deletion test/specs/scale.time.tests.js
Expand Up @@ -58,7 +58,7 @@ describe('Time scale tests', function() {
expect(defaultConfig).toEqual({
display: true,
gridLines: {
color: 'rgba(0, 0, 0, 0.1)',
color: 'rgba(0,0,0,0.1)',
drawBorder: true,
drawOnChartArea: true,
drawTicks: true,
Expand Down

0 comments on commit 626d8cc

Please sign in to comment.