Radar.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. topSuite("Ext.chart.series.Radar", ['Ext.chart.*', 'Ext.data.ArrayStore'], function() {
  2. describe("center", function () {
  3. var chart, layoutDone;
  4. afterEach(function () {
  5. chart = Ext.destroy(chart);
  6. layoutDone = false;
  7. });
  8. it("should be set to a proper value when new series is added", function () {
  9. runs(function () {
  10. chart = new Ext.chart.PolarChart({
  11. renderTo: Ext.getBody(),
  12. width: 400,
  13. height: 400,
  14. innerPadding: 0,
  15. insetPadding: 0,
  16. store: {
  17. data: [
  18. {
  19. cat: 'A',
  20. priority: 12,
  21. other: 8,
  22. foo: 6
  23. },
  24. {
  25. cat: 'B',
  26. priority: 15,
  27. other: 10,
  28. foo: 17
  29. },
  30. {
  31. cat: 'C',
  32. priority: 10,
  33. other: 20,
  34. foo: 14
  35. }
  36. ]
  37. },
  38. axes: [
  39. {
  40. type: 'numeric',
  41. position: 'radial',
  42. grid: true
  43. },
  44. {
  45. type: 'category',
  46. position: 'angular',
  47. grid: true
  48. }
  49. ],
  50. series: [
  51. {
  52. type: 'radar',
  53. radiusField: 'priority',
  54. angleField: 'cat',
  55. style: {
  56. fillOpacity: 0.5
  57. }
  58. },
  59. {
  60. type: 'radar',
  61. radiusField: 'other',
  62. angleField: 'cat',
  63. style: {
  64. fillOpacity: 0.5
  65. }
  66. }
  67. ],
  68. listeners: {
  69. layout: function () {
  70. layoutDone = true;
  71. }
  72. }
  73. });
  74. });
  75. waitsFor(function () {
  76. return layoutDone;
  77. });
  78. runs(function () {
  79. layoutDone = false;
  80. chart.addSeries({
  81. type: 'radar',
  82. angleField: 'cat',
  83. radiusField: 'foo',
  84. style: {
  85. fillOpacity: 0.5
  86. }
  87. });
  88. });
  89. waitsFor(function () {
  90. return layoutDone;
  91. });
  92. runs(function () {
  93. layoutDone = false;
  94. var seriesList = chart.getSeries(),
  95. ln = seriesList.length,
  96. expectation = 200,
  97. i = 0,
  98. series, sprite, center;
  99. for (; i < ln; i++) {
  100. series = seriesList[i];
  101. center = series.getCenter();
  102. expect(center[0]).toBe(expectation);
  103. expect(center[1]).toBe(expectation);
  104. sprite = series.getSprites()[0];
  105. expect(sprite.attr.translationX).toBe(expectation);
  106. expect(sprite.attr.translationY).toBe(expectation);
  107. }
  108. });
  109. });
  110. });
  111. });