zoom-spec.ts 1.5 KB

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