Please follow the tutorial https://roytuts.com/ajax-jquery-based-xchart-example-using-python-flask-mysql/