Script Query in Frappe Insights

How to create a chart using the script query in frappe insights . What is process of writing the code .