|
| 1 | +import { Chart } from '../../src/'; |
| 2 | +import { createDiv } from '../util/dom'; |
| 3 | + |
| 4 | +describe('3079', () => { |
| 5 | + it('3079', () => { |
| 6 | + const data = [ |
| 7 | + { month: 'Jan', city: 'Tokyo', temperature: 7 }, |
| 8 | + { month: 'Jan', city: 'London', temperature: 3.9 }, |
| 9 | + { month: 'Feb', city: 'Tokyo', temperature: 6.9 }, |
| 10 | + { month: 'Feb', city: 'London', temperature: 4.2 }, |
| 11 | + { month: 'Mar', city: 'Tokyo', temperature: 9.5 }, |
| 12 | + { month: 'Mar', city: 'London', temperature: 5.7 }, |
| 13 | + { month: 'Apr', city: 'Tokyo', temperature: 14.5 }, |
| 14 | + { month: 'Apr', city: 'London', temperature: 8.5 }, |
| 15 | + { month: 'May', city: 'Tokyo', temperature: 18.4 }, |
| 16 | + { month: 'May', city: 'London', temperature: 11.9 }, |
| 17 | + { month: 'Jun', city: 'Tokyo', temperature: 21.5 }, |
| 18 | + { month: 'Jun', city: 'London', temperature: 15.2 }, |
| 19 | + { month: 'Jul', city: 'Tokyo', temperature: 25.2 }, |
| 20 | + { month: 'Jul', city: 'London', temperature: 17 }, |
| 21 | + { month: 'Aug', city: 'Tokyo', temperature: 26.5 }, |
| 22 | + { month: 'Aug', city: 'London', temperature: 16.6 }, |
| 23 | + { month: 'Sep', city: 'Tokyo', temperature: 23.3 }, |
| 24 | + { month: 'Sep', city: 'London', temperature: 14.2 }, |
| 25 | + { month: 'Oct', city: 'Tokyo', temperature: 18.3 }, |
| 26 | + { month: 'Oct', city: 'London', temperature: 10.3 }, |
| 27 | + { month: 'Nov', city: 'Tokyo', temperature: 13.9 }, |
| 28 | + { month: 'Nov', city: 'London', temperature: 6.6 }, |
| 29 | + { month: 'Dec', city: 'Tokyo', temperature: 9.6 }, |
| 30 | + { month: 'Dec', city: 'London', temperature: 4.8 }, |
| 31 | + ]; |
| 32 | + |
| 33 | + const chart = new Chart({ |
| 34 | + container: createDiv(), |
| 35 | + limitInPlot: true, |
| 36 | + height: 500, |
| 37 | + width: 500, |
| 38 | + }); |
| 39 | + |
| 40 | + chart.data(data); |
| 41 | + |
| 42 | + chart.scale({ |
| 43 | + month: { |
| 44 | + range: [0, 1], |
| 45 | + }, |
| 46 | + temperature: { |
| 47 | + nice: true, |
| 48 | + min: 10, |
| 49 | + }, |
| 50 | + }); |
| 51 | + |
| 52 | + chart.tooltip({ |
| 53 | + showCrosshairs: true, |
| 54 | + shared: true, |
| 55 | + }); |
| 56 | + |
| 57 | + chart.line().position('month*temperature').color('city').shape('smooth'); |
| 58 | + chart.point().position('month*temperature').color('city').shape('circle'); |
| 59 | + |
| 60 | + chart.render(); |
| 61 | + |
| 62 | + const point = chart.getXY({ month: 'Nov', city: 'London', temperature: 6.6 }); |
| 63 | + |
| 64 | + chart.showTooltip(point); |
| 65 | + |
| 66 | + const tooltipMarkerGroup = chart.foregroundGroup.findAllByName('tooltipMarkersGroup')[0]; |
| 67 | + |
| 68 | + expect(chart.limitInPlot).toBe(true); |
| 69 | + expect(!!tooltipMarkerGroup.cfg.clipShape).toBe(true); |
| 70 | + }); |
| 71 | +}); |
0 commit comments