Skip to content

Commit 2e9b015

Browse files
committed
DOCS - Rename Charts
1 parent febb721 commit 2e9b015

File tree

3 files changed

+16
-127
lines changed

3 files changed

+16
-127
lines changed

docs/charts-template-view.md

Lines changed: 0 additions & 111 deletions
This file was deleted.
File renamed without changes.

docs/charts.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
## Charts
1+
## Charts template view
22

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.
63

7-
![Rocket Django - Styled with Tailwind-Flowbite AppSeed](https://github.com/app-generator/dummy/assets/57325382/7988e817-841d-4e88-8a10-726cad0ae3c7)
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.
85

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.
107

118
![Rocket Django Charts Page - Styled with Tailwind-Flowbite AppSeed](https://github.com/app-generator/dummy/assets/57325382/5b18f498-7cfc-4270-86f8-e77b2fb80e08)
129

@@ -21,16 +18,14 @@ Key Benefits:
2118

2219
- Customized Chart Appearance: Customize the appearance and behaviour of your charts using the readily available template located at `templates/apps/charts.html`.
2320

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-
2621

2722
## How it works
2823

2924
> Codebase: related app, model, template, js
3025
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.
3227

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.
3429
```py
3530
# apps/charts/views.py
3631
from django.shortcuts import render
@@ -48,7 +43,10 @@ def index(request):
4843
```
4944
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.
5045

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
5250
```py
5351
from django.urls import path
5452

@@ -62,6 +60,12 @@ urlpatterns = [
6260
- 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.
6361
```html
6462
// templates/apps/charts.html
63+
// line 183
64+
<div class="flex gap-5 items-center justify-between">
65+
<div class="w-full" id="products-bar-chart"></div>
66+
<div class="w-full" id="products-pie-chart"></div>
67+
</div>
68+
6569
// line 271
6670
<script>
6771
@@ -95,11 +99,7 @@ The data from the context is parsed into a JavaScript object using the code:
9599
const products = JSON.parse('{{ products | safe }}');
96100
```
97101

98-
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.
103103

104104

105105
## Conclusion

0 commit comments

Comments
 (0)