|
| 1 | +import { get } from '@antv/util'; |
| 2 | +import { Line } from '../../src'; |
| 3 | +import { createDiv } from '../utils/dom'; |
| 4 | + |
| 5 | +describe('#3804', () => { |
| 6 | + it('line label style with callback', () => { |
| 7 | + const line = new Line(createDiv(), { |
| 8 | + width: 400, |
| 9 | + height: 300, |
| 10 | + autoFit: false, |
| 11 | + data: [ |
| 12 | + { year: '1991', value: 3 }, |
| 13 | + { year: '1992', value: 4 }, |
| 14 | + { year: '1993', value: 3.5 }, |
| 15 | + { year: '1994', value: 5 }, |
| 16 | + { year: '1995', value: 4.9 }, |
| 17 | + { year: '1996', value: 6 }, |
| 18 | + { year: '1997', value: 7 }, |
| 19 | + { year: '1998', value: 9 }, |
| 20 | + { year: '1999', value: 13 }, |
| 21 | + ], |
| 22 | + xField: 'year', |
| 23 | + yField: 'value', |
| 24 | + label: { |
| 25 | + fields: ['year', 'value'], |
| 26 | + callback: (year, value) => { |
| 27 | + return { |
| 28 | + style: { |
| 29 | + text: value, |
| 30 | + fill: value > 10 ? '#f24' : '#000', |
| 31 | + }, |
| 32 | + }; |
| 33 | + }, |
| 34 | + }, |
| 35 | + }); |
| 36 | + line.render(); |
| 37 | + const geometry = line.chart.geometries[0]; |
| 38 | + expect(get(geometry, ['labelOption', 'fields'])).toEqual(['year', 'value']); |
| 39 | + line.destroy(); |
| 40 | + }); |
| 41 | +}); |
0 commit comments