| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- topSuite("Ext.chart.series.Bar", ['Ext.chart.*', 'Ext.data.ArrayStore'], function() {
- describe("x axis range", function () {
- var chart, layoutDone;
- afterEach(function () {
- chart = Ext.destroy(chart);
- layoutDone = false;
- });
- it("should be expanded on both sides by half bar width in case of two bars", function () {
- runs(function () {
- chart = Ext.create({
- xtype: 'cartesian',
- renderTo: document.body,
- width: 300,
- height: 200,
- store: {
- data: [{
- name: 'one',
- value: 1
- }, {
- name: 'two',
- value: 2
- }]
- },
- axes: [{
- type: 'numeric',
- position: 'left'
- }, {
- type: 'category',
- position: 'bottom'
- }],
- series: {
- type: 'bar',
- xField: 'name',
- yField: 'value'
- },
- listeners: {
- layout: function () {
- layoutDone = true;
- }
- }
- });
- });
- waitsFor(function () {
- return layoutDone;
- });
- runs(function () {
- var range = chart.getAxes()[1].getRange();
- // Original range of [0, 1] is expanded to fit the left side
- // of the left bar and the right side of the right bar.
- expect(range[0]).toBe(-0.5);
- expect(range[1]).toBe(1.5);
- });
- });
- it("should be expanded on both sides by half bar width in case of multiple bars", function () {
- runs(function () {
- chart = Ext.create({
- xtype: 'cartesian',
- renderTo: document.body,
- width: 300,
- height: 200,
- store: {
- data: [{
- name: 'one',
- value: 1
- }, {
- name: 'two',
- value: 2
- }, {
- name: 'three',
- value: 3
- }]
- },
- axes: [{
- type: 'numeric',
- position: 'left'
- }, {
- type: 'category',
- position: 'bottom'
- }],
- series: {
- type: 'bar',
- xField: 'name',
- yField: 'value'
- },
- listeners: {
- layout: function () {
- layoutDone = true;
- }
- }
- });
- });
- waitsFor(function () {
- return layoutDone;
- });
- runs(function () {
- var range = chart.getAxes()[1].getRange();
- // Original range of [0, 1] is expanded to fit the left side
- // of the left bar and the right side of the right bar.
- expect(range[0]).toBe(-0.5);
- expect(range[1]).toBe(2.5);
- });
- });
- it("should not be expanded in case of a single bar", function () {
- runs(function () {
- chart = Ext.create({
- xtype: 'cartesian',
- renderTo: document.body,
- width: 300,
- height: 200,
- store: {
- data: [{
- name: 'one',
- value: 1
- }]
- },
- axes: [{
- type: 'numeric',
- position: 'left'
- }, {
- type: 'category',
- position: 'bottom'
- }],
- series: {
- type: 'bar',
- xField: 'name',
- yField: 'value'
- },
- listeners: {
- layout: function () {
- layoutDone = true;
- }
- }
- });
- });
- waitsFor(function () {
- return layoutDone;
- });
- runs(function () {
- var range = chart.getAxes()[1].getRange();
- // Original range of [0, 1] is expanded to fit the left side
- // of the left bar and the right side of the right bar.
- expect(range[0]).toBe(-0.5);
- expect(range[1]).toBe(0.5);
- });
- });
- });
- });
|