zoom-spec.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. describe('c3 chart zoom', function () {
  2. 'use strict';
  3. var chart;
  4. var args = {
  5. data: {
  6. columns: [
  7. ['data1', 30, 200, 100, 400, 3150, 250],
  8. ['data2', 50, 20, 10, 40, 15, 6025]
  9. ]
  10. },
  11. zoom: {
  12. enabled: true,
  13. initialRange: [1, 2]
  14. },
  15. subchart: {
  16. show: true
  17. }
  18. };
  19. beforeEach(function (done) {
  20. chart = window.initChart(chart, args, done);
  21. });
  22. describe('default extent', function () {
  23. describe('main chart domain', function () {
  24. it('should have original y domain', function () {
  25. var yDomain = chart.internal.y.domain(),
  26. expectedYDomain = [-591.5, 6626.5];
  27. expect(yDomain[0]).toBe(expectedYDomain[0]);
  28. expect(yDomain[1]).toBe(expectedYDomain[1]);
  29. });
  30. });
  31. describe('main chart domain', function () {
  32. it('should have original y domain in subchart', function () {
  33. var yDomain = chart.internal.y.domain(),
  34. subYDomain = chart.internal.subY.domain();
  35. expect(subYDomain[0]).toBe(yDomain[0]);
  36. expect(subYDomain[1]).toBe(yDomain[1]);
  37. });
  38. });
  39. describe('main chart domain', function () {
  40. it('should have specified brush extent', function () {
  41. var brushSelection = chart.internal.brush.selectionAsValue(),
  42. expectedBrushSelection = [1, 2];
  43. expect(brushSelection[0]).toBeCloseTo(expectedBrushSelection[0], 1);
  44. expect(brushSelection[1]).toBeCloseTo(expectedBrushSelection[1], 1);
  45. });
  46. });
  47. });
  48. });