I´ve got some code from previous Ignition Vision project I´m trying to refactor into the new Ignition Perspective project.
¿What are some good strategies to refactor the code?

Vision Script example:
if event.propertyName == 'data':
	if (event.source.data.rowCount > 0) and (event.source.data.getValueAt(0, 0) != 0):
		TPyRowData = []
		for col in range(event.source.data.columnCount):
			TPyRowData.append("")
		
		event.source.data = system.dataset.addRow(event.source.data, 0, TPyRowData)
		
		TData = event.source.data	
		for row in range(1, TData.rowCount):
			nTotal = 0
			for col in range(2, TData.columnCount):
				nTotal += TData.getValueAt(row, col)	
			
			TData = system.dataset.setValue(TData, row, 1, int(nTotal))
		
		event.source.data = TData	
		
		graph = event.source.parent.getComponent('graphStats1')
		graph.data = system.dataset.deleteRows(graph.data, range(graph.data.getRowCount()))
		for row in range(1, TData.rowCount):
			graph.data = system.dataset.addRow(graph.data, [TData.getValueAt(row, 0), TData.getValueAt(row, 1)])
			
	
	if (event.source.data.rowCount > 0):
		event.source.RecordCount = event.source.data.rowCount - 1
	else:
		event.source.RecordCount = 0
	#Ajusta textos de cabecera
	listText = [ \
	'<html><p>Equipos de</p><p>PCI</p>', \
	'<html><p>Instalacion</p><p>electrica</p>', \
	'<html><p>Señalizacion</p><p>PCI</p>', \
	'<html><p>Iluminacion</p><p>emergencia</p>', \
	'<html><p>Salidas y</p><p>vias evac.</p>', \
	'<html><p>Señalizacion</p><p>evacuacion y</p><p>emergencia</p>', \
	'<html><p>Señalizacion</p><p>riesgo elect.</p>', \
	'<html><p>Caida de</p><p>personas</p><p>mismo nivel</p>', \
	'<html><p>Escalas</p><p>fijas</p>', \
	'<html><p>Escaleras</p><p>portatiles</p><p>de mano</p>', \
	'<html><p>Iluminacion</p><p>PVD</p>', \
	'<html><p>Iluminacion</p><p>resto</p><p>(no emerg.)</p>', \
	'<html><p>Climatiz.</p><p>(Temp.)</p>', \
	'<html><p>Climatiz.</p><p>(Hr)</p>', \
	'<html><p>Climatiz.</p><p>(CO2)</p>', \
	'<html><p>Caida de</p><p>objetos</p><p>desprendidos</p>', \
	'<html><p>Atropellos</p>', \
	'<html><p>Transito por</p><p>cubierta</p>', \
	'<html><p>Otros riesgos</p><p>detallar)</p>' \
	]
	
	tabla = event.source.parent.getComponent('tblStats')
	TData = tabla.columnAttributesData
	for row in range(TData.rowCount):
		if TData.getValueAt(row, 0)[1:7] == 'RIL':		
			TData = system.dataset.setValue(TData, row, 6, listText[int(TData.getValueAt(row, 0)[7:11]) - 1])
		
	tabla.columnAttributesData = TData