graph2D.helper.ts 1.2 KB
Newer Older
1
2
export interface Animation {
	data?: any,
3
	init: boolean,
4
	currentFrame: number,
5
	fps: number,
6
	playing: boolean,
7
8
9
	timeout?: any,
	animationFrame?: any,
	speedX: number,
10
11
	boton: boolean,
	zoo: number,
12
}
13

14
15
16
17
18
19
export interface Setting {
	axis: boolean,
	grid: boolean,
	tip: boolean
}

20
21
22
23
24
25
26
27
28
export function toJSON(data: string) : string {
	console.log('data',data);
	const regexPts = /(?:\"pts\"\:\[(?:\((x),(y)\))+,?\])/g;
	var dataJSON = data.replace(regexPts, (match, x, y) => {
		return `"points": [[${x},${y}]]`
	})
	console.log('dataJSON', dataJSON);
	return dataJSON;
}
leonelrosano's avatar
leonelrosano committed
29
30
31
32
33
34
35
36
37
/**************para borrar***************** */
// export function JSONRepair(data: string): string {
// 	const regex = /\"sets\"\ : \[(\"+.*)\]\, \"bdy\"/g;
  
// 	return data.replace(regex, (match, content) => {
// 	  return `"sets": [{ ${content} }], "bdy"`
// 	})
//   }
  /**************fin para borrar***************** */
38
39
40
41
42
43
44

export function triggerDownload(imgURI: string) {
	var evt = new MouseEvent('click', {
		view: window,
		bubbles: false,
		cancelable: true
	});
45

46
47
48
49
	var a = document.createElement('a');
	a.setAttribute('download', 'Matefun_2D_plot.png');
	a.setAttribute('href', imgURI);
	a.setAttribute('target', '_blank');
50

51
52
	a.dispatchEvent(evt);
}