jquery.flot.stack.Test.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* eslint-disable */
  2. /* global $, describe, it, xit, xdescribe, after, afterEach, expect*/
  3. describe('stacking plugin', function() {
  4. var placeholder, plot, options;
  5. beforeEach(function() {
  6. options = {
  7. series: {
  8. stack: true,
  9. bars: {
  10. show: true,
  11. barWidth: 0.6
  12. }
  13. }
  14. };
  15. placeholder = setFixtures('<div id="test-container" style="width: 600px;height: 400px">')
  16. .find('#test-container');
  17. });
  18. it('should accumulate Y values', function () {
  19. var testData = [[[0, 1], [1, 2], [2, 3], [3, 4]], [[0, 4], [1, 3], [2, 2], [3, 1]]];
  20. plot = $.plot(placeholder, testData, options);
  21. var series = plot.getData();
  22. expect(series[0].datapoints.pointsize).toBe(3);
  23. expect(series[1].datapoints.pointsize).toBe(3);
  24. var points1 = series[0].datapoints.points;
  25. // Bottom points should be 0
  26. expect(points1).toEqual([0, 1, 0, 1, 2, 0, 2, 3, 0, 3, 4, 0]);
  27. var points2 = series[1].datapoints.points;
  28. // Bottom points are first series' Y values
  29. expect(points2).toEqual([0, 5, 1, 1, 5, 2, 2, 5, 3, 3, 5, 4]);
  30. });
  31. it('should format data when pointsize = 2', function () {
  32. options.series.flatdata = true;
  33. var testData = [[[0, 1], [1, 2], [2, 3], [3, 4]], [[0, 4], [1, 3], [2, 2], [3, 1]]];
  34. plot = $.plot(placeholder, testData, options);
  35. var series = plot.getData();
  36. expect(series[0].datapoints.pointsize).toBe(3);
  37. expect(series[1].datapoints.pointsize).toBe(3);
  38. expect(series[0].datapoints.points.length).toEqual(12);
  39. expect(series[1].datapoints.points.length).toEqual(12);
  40. });
  41. });