|
| 1 | +import { Line, Area, Radar } from '../../src'; |
| 2 | +import { createDiv } from '../utils/dom'; |
| 3 | + |
| 4 | +const data = [ |
| 5 | + { |
| 6 | + type: '家具家电', |
| 7 | + sales: 38, |
| 8 | + }, |
| 9 | + { |
| 10 | + type: '粮油副食', |
| 11 | + sales: 52, |
| 12 | + }, |
| 13 | +]; |
| 14 | + |
| 15 | +describe('#2064', () => { |
| 16 | + it('#2064 line', () => { |
| 17 | + const plot = new Line(createDiv(), { |
| 18 | + width: 400, |
| 19 | + height: 400, |
| 20 | + data, |
| 21 | + xField: 'type', |
| 22 | + yField: 'sales', |
| 23 | + point: {}, |
| 24 | + label: {}, |
| 25 | + }); |
| 26 | + |
| 27 | + plot.render(); |
| 28 | + |
| 29 | + const line = plot.chart.geometries.find((geom) => geom.type === 'line'); |
| 30 | + const point = plot.chart.geometries.find((geom) => geom.type === 'point'); |
| 31 | + |
| 32 | + expect(line.labelsContainer.getChildren()).toHaveLength(data.length); |
| 33 | + expect(point.labelsContainer.getChildren()).toHaveLength(0); |
| 34 | + |
| 35 | + plot.destroy(); |
| 36 | + }); |
| 37 | + |
| 38 | + it('#2064 area', () => { |
| 39 | + const plot = new Area(createDiv(), { |
| 40 | + width: 400, |
| 41 | + height: 400, |
| 42 | + data, |
| 43 | + xField: 'type', |
| 44 | + yField: 'sales', |
| 45 | + line: {}, |
| 46 | + point: {}, |
| 47 | + label: {}, |
| 48 | + }); |
| 49 | + |
| 50 | + plot.render(); |
| 51 | + |
| 52 | + const area = plot.chart.geometries.find((geom) => geom.type === 'area'); |
| 53 | + const line = plot.chart.geometries.find((geom) => geom.type === 'line'); |
| 54 | + const point = plot.chart.geometries.find((geom) => geom.type === 'point'); |
| 55 | + |
| 56 | + expect(area.labelsContainer.getChildren()).toHaveLength(data.length); |
| 57 | + expect(line.labelsContainer.getChildren()).toHaveLength(0); |
| 58 | + expect(point.labelsContainer.getChildren()).toHaveLength(0); |
| 59 | + |
| 60 | + plot.destroy(); |
| 61 | + }); |
| 62 | + |
| 63 | + it('#2064 radar', () => { |
| 64 | + const plot = new Radar(createDiv(), { |
| 65 | + width: 400, |
| 66 | + height: 400, |
| 67 | + data, |
| 68 | + xField: 'type', |
| 69 | + yField: 'sales', |
| 70 | + area: {}, |
| 71 | + point: {}, |
| 72 | + label: {}, |
| 73 | + radius: 0.8, |
| 74 | + }); |
| 75 | + |
| 76 | + plot.render(); |
| 77 | + |
| 78 | + const area = plot.chart.geometries.find((geom) => geom.type === 'area'); |
| 79 | + const line = plot.chart.geometries.find((geom) => geom.type === 'line'); |
| 80 | + const point = plot.chart.geometries.find((geom) => geom.type === 'point'); |
| 81 | + |
| 82 | + expect(area.labelsContainer.getChildren()).toHaveLength(0); |
| 83 | + expect(line.labelsContainer.getChildren()).toHaveLength(data.length); |
| 84 | + expect(point.labelsContainer.getChildren()).toHaveLength(0); |
| 85 | + }); |
| 86 | +}); |
0 commit comments