You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/charts.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,9 @@
1
-
## Charts
1
+
## Charts template view
2
2
3
-
**Rocket Django** empowers you to create interactive charts effortlessly using [Apexcharts](https://apexcharts.com/). Rocket Django simplifies integrating data from Django's ORM into Apexcharts, making it easier than ever to visualize your data.
4
-
5
-
The home page features a static line chart and several bar charts that can customized as you see fit.
6
3
7
-

4
+
**Rocket Django** empowers you to create interactive charts effortlessly using [Apexcharts](https://apexcharts.com/). Rocket Django simplifies integrating data from Django's ORM into Apexcharts, making it easier than ever to visualize your data.
8
5
9
-
Under the App menu in the sidebar, you will see a new route called `Charts`. This page features a dynamic bar chart and pie chart utilizing data from the database.
6
+
Under the App menu in the sidebar, you will see a new route called `Charts`. This page features a dynamic bar chart and pie chart under the Charts (Template View) section utilizing data from the database.
10
7
11
8

12
9
@@ -21,16 +18,14 @@ Key Benefits:
21
18
22
19
- Customized Chart Appearance: Customize the appearance and behaviour of your charts using the readily available template located at `templates/apps/charts.html`.
23
20
24
-
- Chart Creation using API data: Create charts using API data in specific pages or sections of your application. Static charts `static/assets/charts.js`.
25
-
26
21
27
22
## How it works
28
23
29
24
> Codebase: related app, model, template, js
30
25
31
-
Charts in Rocket Django are created in the `charts` app and rendered as views, with model data sent as context to the template of the page.
26
+
Charts in Rocket Django can be created in the `charts` app and rendered as views, with model data sent as context to the template of the page.
32
27
33
-
- To create a dynamic chart in Rocket Django, create the function to render the page in `apps/charts/views.py`. Model data that is used for the chart can be obtained by importing the model into the module used in creating the chart. Data from the `Product` model in `apps/common/models.py` is used to create the chart.
28
+
- To create a dynamic chart using the template view in Rocket Django, create the function to render the page in `apps/charts/views.py`. Model data that is used for the chart can be obtained by importing the model into the module used in creating the chart. Data from the `Product` model in `apps/common/models.py` is used to create the chart.
34
29
```py
35
30
# apps/charts/views.py
36
31
from django.shortcuts import render
@@ -48,7 +43,10 @@ def index(request):
48
43
```
49
44
Model data is serialized into json format and passed with with the context dictionary. The data is serialized to make it easy to parse and render on the user interface.
50
45
51
-
- Add the path to the chart to `apps/charts/urls.py` to make the chart accessible from the browser.
46
+
- Add the path to the chart view just created to `apps/charts/urls.py` to make the chart accessible from the browser.
47
+
- For charts rendered using the API data, the elements are named `products-bar-chart-api` and `products-pie-chart-api`. The data for the chart is pulled and rendered using functions in `static/assets/charts.js`.
48
+
49
+
- Charts on the homepage are rendered using the `getMainChartOptions`, `getVisitorsChartOptions`, and `getSignupsChartOptions` functions. You can customize these functions to better align with the requirements of your specific application
52
50
```py
53
51
from django.urls import path
54
52
@@ -62,6 +60,12 @@ urlpatterns = [
62
60
- The chart is rendered using `templates/apps/charts.html`. The data from the context is parsed into a javascript object and used to render the bar chart and pie chart.
The `getProductsBarChart` and `getProductsPieChart` functions are used to insert the data from the model to their respective charts, and then the data is rendered on the element with the `products-bar-chart` and `products-pie-chart` IDs respectively. This can be altered to suit your use case and can also be extended to add other chart options.
99
-
100
-
- For charts rendered using the API data, the elements are named `products-bar-chart-api` and `products-pie-chart-api`. The data for the chart is pulled and rendered using functions in `static/assets/charts.js`.
101
-
102
-
- Charts on the homepage are rendered using the `getMainChartOptions`, `getVisitorsChartOptions`, and `getSignupsChartOptions` functions. You can customize these functions to better align with the requirements of your specific application.
102
+
The `getProductsBarChart` and `getProductsPieChart` functions are used to insert the data from the model to their respective charts, and then the data is rendered on the HTML element with the `products-bar-chart` and `products-pie-chart` IDs respectively. This can be altered to suit your use case and can also be extended to add other chart options.
0 commit comments