mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-20 23:26:53 +01:00
Enable bounds option to all cartesian axes (#8060)
This commit is contained in:
@@ -475,4 +475,33 @@ describe('Category scale tests', function() {
|
||||
expect(yScale.getPixelForValue(3)).toBeCloseToPixel(426);
|
||||
expect(yScale.getPixelForValue(4)).toBeCloseToPixel(538);
|
||||
});
|
||||
|
||||
it('Should bound to ticks/data', function() {
|
||||
var chart = window.acquireChart({
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: ['a', 'b', 'c', 'd'],
|
||||
datasets: [{
|
||||
data: {b: 1, c: 99}
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
x: {
|
||||
type: 'category',
|
||||
bounds: 'data'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
expect(chart.scales.x.min).toEqual(1);
|
||||
expect(chart.scales.x.max).toEqual(2);
|
||||
|
||||
chart.options.scales.x.bounds = 'ticks';
|
||||
chart.update();
|
||||
|
||||
expect(chart.scales.x.min).toEqual(0);
|
||||
expect(chart.scales.x.max).toEqual(3);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -759,6 +759,28 @@ describe('Linear Scale', function() {
|
||||
expect(getLabels(chart.scales.y)).toEqual(['0.3', '0.8', '1.3', '1.8', '2.3', '2.8']);
|
||||
});
|
||||
|
||||
it('Should bound to data', function() {
|
||||
var chart = window.acquireChart({
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: ['a', 'b'],
|
||||
datasets: [{
|
||||
data: [1, 99]
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
y: {
|
||||
bounds: 'data'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
expect(chart.scales.y.min).toEqual(1);
|
||||
expect(chart.scales.y.max).toEqual(99);
|
||||
});
|
||||
|
||||
it('Should build labels using the user supplied callback', function() {
|
||||
var chart = window.acquireChart({
|
||||
type: 'bar',
|
||||
|
||||
@@ -1142,4 +1142,27 @@ describe('Logarithmic Scale tests', function() {
|
||||
expect(chart.scales.y.min).toBe(10);
|
||||
expect(chart.scales.y.max).toBe(100);
|
||||
});
|
||||
|
||||
it('Should bound to data', function() {
|
||||
var chart = window.acquireChart({
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: ['a', 'b'],
|
||||
datasets: [{
|
||||
data: [1.1, 99]
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
y: {
|
||||
type: 'logarithmic',
|
||||
bounds: 'data'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
expect(chart.scales.y.min).toEqual(1.1);
|
||||
expect(chart.scales.y.max).toEqual(99);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user