Prerequisite : django installation
With the growth of data, data visualization in become a import part here we will implement chart for our data in our web apps using chartjs with django. Django is a high-level Python Web framework based web framework and chartjs is an easy way to include animated, interactive graphs.
Modules required :
- django : install django
$ pip install djangorestframework
basic setup :
Start a project by the following command –
$ django-admin startproject charts
Change directory to charts –
$ cd charts
Start the server- Start the server by typing following command in terminal –
$ python manage.py runserver
To check whether the server is running or not go to a web browser and enter http://127.0.0.1:8000/ as URL.
Now stop the server by pressing ctrl+C
Let’s create an app now.
$ python manage.py startapp chartjs
Goto chartjs/ folder by doing:
$ cd chartjs
and create a folder with index.html file: templates/chartjs/index.html
$ mkdir -p templates/chartjs && cd templates/chartjs && touch index.html
Open the project folder using a text editor. The directory structure should look like this :
Now add chartjs app and rest_framework in your charts in settings.py.
Edit urls.py file in charts :
Edit views.py in chartjs :
Navigate to templates/chartjs/index.html and edit it.
Make migrations and migrate it :
$ python manage.py makemigrations $ python manage.py migrate
Now you can run the server to see your app :
$ python manage.py runserver
- Difference Between Data Mining and Data Visualization
- Difference Between Data Visualization and Data Analytics
- How Data Visualization Enables us to Monitor COVID-19 Data?
- Why Data Visualization Matters in Data Analytics?
- Python - Data visualization using Bokeh
- COVID-19 Data Visualization using matplotlib in Python
- Interactive visualization of data using Bokeh
- Animated Data Visualization using Plotly Express
- Data Visualization using Turicreate in Python
- Data analysis and Visualization with Python
- Data Analysis and Visualization with Python | Set 2
- What is Tableau and its Importance in Data Visualization?
- Data visualization with different Charts in Python
- Pandas Built-in Data Visualization | ML
- 10 Best Data Visualization Tools in 2020
- Top R Libraries for Data Visualization in 2020
- Top 8 Python Libraries for Data Visualization
- Insertion Sort Visualization using Matplotlib in Python
- Visualization of Quick sort using Matplotlib
- Visualization of Merge sort using Matplotlib
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.