mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 12:19:08 +02:00
Tests for suggestedMin and suggestedMax options
This commit is contained in:
parent
3aaa3e27f3
commit
07b052cfab
@ -283,6 +283,37 @@ describe('Linear Scale', function() {
|
||||
expect(scale.max).toBe(1);
|
||||
});
|
||||
|
||||
it('Should use the suggestedMin and suggestedMax options', function() {
|
||||
var scaleID = 'myScale';
|
||||
|
||||
var mockData = {
|
||||
datasets: [{
|
||||
yAxisID: scaleID,
|
||||
data: [1, 1, 1, 2, 1, 0]
|
||||
}]
|
||||
};
|
||||
|
||||
var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('linear'));
|
||||
config.ticks.suggestedMin = -10;
|
||||
config.ticks.suggestedMax = 10;
|
||||
|
||||
var Constructor = Chart.scaleService.getScaleConstructor('linear');
|
||||
var scale = new Constructor({
|
||||
ctx: {},
|
||||
options: config,
|
||||
data: mockData,
|
||||
id: scaleID
|
||||
});
|
||||
|
||||
// Set arbitrary width and height for now
|
||||
scale.width = 50;
|
||||
scale.height = 400;
|
||||
|
||||
scale.buildTicks();
|
||||
expect(scale.min).toBe(-10);
|
||||
expect(scale.max).toBe(10);
|
||||
});
|
||||
|
||||
it('should forcibly include 0 in the range if the beginAtZero option is used', function() {
|
||||
var scaleID = 'myScale';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user