github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/webapp/javascript/components/TimelineChart/extractRange.ts (about) 1 /* eslint-disable */ 2 /** 3 * @remarks 4 * function taken from built-in markings support in Flot 5 * @param plot - plot instance 6 * @param coord - 'x' | 'y' 7 * 8 * @returns params of X or Y axis 9 * 10 */ 11 export default function extractRange(plot: jquery.flot.plot, coord: 'x' | 'y') { 12 const axes = plot.getAxes(); 13 var axis, from, to, key; 14 var ranges: { [x: string]: any } = axes; 15 16 for (var k in axes) { 17 // @ts-ignore:next-line 18 axis = axes[k]; 19 if (axis.direction == coord) { 20 key = coord + axis.n + 'axis'; 21 if (!ranges[key] && axis.n == 1) key = coord + 'axis'; // support x1axis as xaxis 22 if (ranges[key]) { 23 from = ranges[key].from; 24 to = ranges[key].to; 25 break; 26 } 27 } 28 } 29 30 // backwards-compat stuff - to be removed in future 31 if (!ranges[key as string]) { 32 axis = coord == 'x' ? plot.getXAxes()[0] : plot.getYAxes()[0]; 33 from = ranges[coord + '1']; 34 to = ranges[coord + '2']; 35 } 36 37 // auto-reverse as an added bonus 38 if (from != null && to != null && from > to) { 39 var tmp = from; 40 from = to; 41 to = tmp; 42 } 43 44 return { from: from, to: to, axis: axis }; 45 }