mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 20:29:12 +02:00
Merge pull request #2870 from chartjs/fix/2802
Consider left and top when determining value from pixel in category s…
This commit is contained in:
commit
44a9866bd8
@ -81,6 +81,8 @@ module.exports = function(Chart) {
|
||||
var innerDimension = horz ? me.width - (me.paddingLeft + me.paddingRight) : me.height - (me.paddingTop + me.paddingBottom);
|
||||
var valueDimension = innerDimension / offsetAmt;
|
||||
|
||||
pixel -= horz ? me.left : me.top;
|
||||
|
||||
if (me.options.gridLines.offsetGridLines) {
|
||||
pixel -= (valueDimension / 2);
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ describe('Category scale tests', function() {
|
||||
|
||||
expect(scale.getPixelForValue(0, 4, 0, false)).toBe(452);
|
||||
expect(scale.getPixelForValue(0, 4, 0, true)).toBe(505);
|
||||
expect(scale.getValueForPixel(452)).toBe(4);
|
||||
expect(scale.getValueForPixel(453)).toBe(4);
|
||||
expect(scale.getValueForPixel(505)).toBe(4);
|
||||
|
||||
config.gridLines.offsetGridLines = false;
|
||||
@ -282,7 +282,7 @@ describe('Category scale tests', function() {
|
||||
|
||||
expect(scale.getPixelForValue(0, 4, 0, false)).toBe(161);
|
||||
expect(scale.getPixelForValue(0, 4, 0, true)).toBe(180);
|
||||
expect(scale.getValueForPixel(161)).toBe(4);
|
||||
expect(scale.getValueForPixel(162)).toBe(4);
|
||||
|
||||
config.gridLines.offsetGridLines = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user