Area.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /* global expect, Ext */
  2. topSuite("Ext.chart.series.Area", ['Ext.chart.*', 'Ext.data.ArrayStore'], function() {
  3. var chart;
  4. beforeEach(function() {
  5. // Silence warnings regarding Sencha download server
  6. spyOn(Ext.log, 'warn');
  7. });
  8. afterEach(function() {
  9. Ext.destroy(chart);
  10. });
  11. describe('renderer', function () {
  12. it('should work on markers with style.step = false', function () {
  13. var red = '#ff0000',
  14. green = '#ff0000',
  15. layoutDone;
  16. run(function () {
  17. chart = new Ext.chart.CartesianChart({
  18. renderTo: Ext.getBody(),
  19. width: 300,
  20. height: 300,
  21. store: {
  22. data: [{
  23. month: 'JAN',
  24. data1: 12
  25. }, {
  26. month: 'FEB',
  27. data1: 14
  28. }, {
  29. month: 'MAR',
  30. data1: 10
  31. }, {
  32. month: 'APR',
  33. data1: 18
  34. }, {
  35. month: 'MAY',
  36. data1: 17
  37. }]
  38. },
  39. axes: [{
  40. type: 'numeric',
  41. position: 'left'
  42. }, {
  43. type: 'category',
  44. position: 'bottom'
  45. }],
  46. series: [{
  47. type: 'area',
  48. renderer: function (sprite, config, rendererData, index) {
  49. return {
  50. fillStyle: index % 2 ? red : green
  51. };
  52. },
  53. xField: 'month',
  54. yField: 'data1',
  55. marker: true
  56. }],
  57. listeners: {
  58. layout: function () {
  59. layoutDone = true;
  60. }
  61. }
  62. });
  63. });
  64. waitFor(function () {
  65. return layoutDone;
  66. });
  67. runs(function () {
  68. var seriesSprite = chart.getSeries()[0].getSprites()[0],
  69. markerCategory = seriesSprite.getId(),
  70. markers = seriesSprite.getMarker('markers');
  71. expect(markers.getMarkerFor(markerCategory, 0).fillStyle).toBe(green);
  72. expect(markers.getMarkerFor(markerCategory, 1).fillStyle).toBe(red);
  73. expect(markers.getMarkerFor(markerCategory, 2).fillStyle).toBe(green);
  74. expect(markers.getMarkerFor(markerCategory, 3).fillStyle).toBe(red);
  75. });
  76. });
  77. it('should work on markers with style.step = true', function () {
  78. var red = '#ff0000',
  79. green = '#ff0000',
  80. layoutDone;
  81. run(function () {
  82. chart = new Ext.chart.CartesianChart({
  83. renderTo: Ext.getBody(),
  84. width: 300,
  85. height: 300,
  86. store: {
  87. data: [{
  88. month: 'JAN',
  89. data1: 12
  90. }, {
  91. month: 'FEB',
  92. data1: 14
  93. }, {
  94. month: 'MAR',
  95. data1: 10
  96. }, {
  97. month: 'APR',
  98. data1: 18
  99. }, {
  100. month: 'MAY',
  101. data1: 17
  102. }]
  103. },
  104. axes: [{
  105. type: 'numeric',
  106. position: 'left'
  107. }, {
  108. type: 'category',
  109. position: 'bottom'
  110. }],
  111. series: [{
  112. type: 'area',
  113. style: {
  114. step: true
  115. },
  116. renderer: function (sprite, config, rendererData, index) {
  117. return {
  118. fillStyle: index % 2 ? red : green
  119. };
  120. },
  121. xField: 'month',
  122. yField: 'data1',
  123. marker: true
  124. }],
  125. listeners: {
  126. layout: function () {
  127. layoutDone = true;
  128. }
  129. }
  130. });
  131. });
  132. waitFor(function () {
  133. return layoutDone;
  134. });
  135. run(function () {
  136. var seriesSprite = chart.getSeries()[0].getSprites()[0],
  137. markerCategory = seriesSprite.getId(),
  138. markers = seriesSprite.getMarker('markers');
  139. expect(markers.getMarkerFor(markerCategory, 0).fillStyle).toBe(green);
  140. expect(markers.getMarkerFor(markerCategory, 1).fillStyle).toBe(red);
  141. expect(markers.getMarkerFor(markerCategory, 2).fillStyle).toBe(green);
  142. expect(markers.getMarkerFor(markerCategory, 3).fillStyle).toBe(red);
  143. });
  144. });
  145. });
  146. });