Skip to content

Commit 24c7839

Browse files
committed
feat: Update example to 3.10.1 and publish readme.
1 parent 33bdc3e commit 24c7839

File tree

5 files changed

+99
-52
lines changed

5 files changed

+99
-52
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.lowdefy/**
2+
.env

LICENCE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Lowdefy Inc.
3+
Copyright (c) 2021 Lowdefy Inc.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
11
# Lowdefy Reporting Example
22

3-
This example show patterns that can be used to implement a BI report/dashboard.
3+
This example demonstrate useful paterns for building a BI report/dashboard pages in Lowdefy. It connects to a MongoDB database with the Atlas Movies sample dataset pre-loaded.
44

5-
It assumes that it is connected to a MongoDB database with the Atlas sample dataset loaded.
5+
Three additional block types is loaded for this examples:
6+
7+
- `AmChartsXY` and `AmChartsPie` from [@lowdefy/blocks-amcharts](https://github.com/lowdefy/blocks-amcharts).
8+
- `AgGridAlpine`, from [@lowdefy/blocks-aggrid](https://github.com/lowdefy/blocks-aggrid).
69

710
## Running this example
11+
12+
- Create a [MongoDB Atlas](https://www.mongodb.com/try) free tier cluster and select to load the sample dataset.
13+
- Add a database user to the MongoDB database and generate a connection uri containing the database username and password. Be sure to create the database user with read privileges for the sample database. Read more about using [the Lowdefy MongoDB connector](https://docs.lowdefy.com/MongoDB).
814
- Clone this repository.
9-
- Set up a MongoDB Atlas database and set the connection uri as secret `lowdefy_examples_mdb`.
10-
- Run the Lowdefy CLI from the cloned repository.
15+
- Create a `.env` file in your project folder and set your MongoDB database connector URI as a variable in the `.env` file: `LOWDEFY_SECRET_EXAMPLES_MDB="{{ your_mongodb_connection_uri }}"`
16+
17+
- In the command console, navigate to your project folder and run the Lowdefy CLI: `npx lowdefy@latest dev`.
18+
19+
## More Lowdefy resources
20+
21+
- Getting started with Lowdefy - https://docs.lowdefy.com/tutorial-start
22+
- Lowdefy docs - https://docs.lowdefy.com
23+
- Lowdefy website - https://lowdefy.com
24+
- Community forum - https://github.com/lowdefy/lowdefy/discussions
25+
- Bug reports and feature requests - https://github.com/lowdefy/lowdefy/issues
1126

1227
## Licence
1328

14-
This example configuration is licensed under the MIT license. See the LICENSE.md file for license rights and limitations.
29+
[MIT](https://github.com/lowdefy/lowdefy-example-reporting/blob/main/LICENSE)

lowdefy.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11

22
name: Lowdefy Reporting Example
3-
version: 0.0.6
3+
lowdefy: 3.10.1
44
licence: MIT
5-
description: |
6-
This example show patterns that can be used to implement a BI report/dashboard.
75

8-
It assumes that it is connected to a MongoDB database with the Atlas sample dataset loaded.
6+
# description
7+
# This example show patterns that can be used to implement a BI report/dashboard.
8+
# It assumes that it is connected to a MongoDB database with the Atlas sample dataset loaded.
9+
10+
types:
11+
AmChartsXY:
12+
url: https://blocks-cdn.lowdefy.com/v3.10.1/blocks-amcharts/meta/AmChartsXY.json
13+
AmChartsPie:
14+
url: https://blocks-cdn.lowdefy.com/v3.10.1/blocks-amcharts/meta/AmChartsPie.json
15+
AgGridAlpine:
16+
url: https://blocks-cdn.lowdefy.com/v3.10.1/blocks-aggrid/meta/AgGridAlpine.json
917

1018
# Define all the data connections, in this case the brands and products MongoDB collections
1119
connections:
@@ -15,7 +23,7 @@ connections:
1523
databaseName: sample_mflix # The database name
1624
collection: movies # The collection name
1725
databaseUri:
18-
_secret: lowdefy_examples_mdb # The database connection uri that is stored as a secret and accessed using the _secret operator
26+
_secret: EXAMPLES_MDB # The database connection uri that is stored as a secret and accessed using the _secret operator
1927

2028
# Menus used in the app can be listed here
2129
# By default, the menu with id default, or the first menu defined is used.

report.yaml

Lines changed: 62 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ properties:
44
title: Report
55
layout:
66
contentGutter: 16 # Set a gutter of 16px between all the cards on the page
7-
87
requests:
98
# Request for the bar and pie charts
109
- id: scores_by_genre
@@ -25,7 +24,7 @@ requests:
2524
- Action
2625
- $group:
2726
_id: $genres # Group data by the genre field
28-
# Calculate the average IMDB, and Rotten Tomatoes viewer and critic ratings for each genre.
27+
# Calculate the average Rotten Tomatoes viewer and critic ratings for each genre.
2928
viewerRating:
3029
$avg: $tomatoes.viewer.rating
3130
criticRating:
@@ -42,7 +41,7 @@ requests:
4241
count: -1 # Sort by descending count
4342

4443
# Request for the table
45-
- id: top_100_movies
44+
- id: top_100_score_difference_movies
4645
type: MongoDBAggregation # MongoDB Aggregation to get the data
4746
connectionId: movies_mongodb
4847
properties:
@@ -82,6 +81,14 @@ requests:
8281
- $sort:
8382
difference: -1 # Sort by biggest difference
8483
- $limit: 100 # Only return the first 100 results
84+
events:
85+
# A list of actions that gets completed when this page is first loaded.
86+
onInitAsync:
87+
- id: fetch_data # Fetch the request data before the page renders in order to populate the charts
88+
type: Request
89+
params:
90+
- scores_by_genre
91+
- top_100_score_difference_movies
8592

8693
blocks:
8794
- id: title # Title on page
@@ -91,16 +98,13 @@ blocks:
9198
level: 4
9299
- id: genre_counts_bar_chart_card
93100
type: Card
101+
properties:
102+
title: Comparison of Critic and Viewer Ratings by Genre
94103
layout:
95104
span: 16 # Make the card span 2 thirds of the screen
96105
blocks:
97-
- id: title # Add a title
98-
type: Markdown
99-
properties:
100-
content: "#### Comparison of Critic and Viewer Ratings by Genre"
101-
level: 4
102106
- id: genre_counts_bar_chart
103-
type: AmCharts4XY # AmCharts4XY is used for all charts with x and y axis
107+
type: AmChartsXY # AmCharts4XY is used for all charts with x and y axis
104108
properties:
105109
data:
106110
_request: scores_by_genre # Use scores_by_genre request for chart data
@@ -117,7 +121,7 @@ blocks:
117121
renderer:
118122
grid:
119123
disabled: true # Disable vertical grid lines
120-
minGridDistance: 20 # Reduce the minimum grid distance so that more category labels can be shown the x axis
124+
minGridDistance: 20 # Reduce the minimum grid distance so that more category labels can be shown on the x axis
121125
labels: # Rotate the labels
122126
contentAlign: right # Align against x axis
123127
rotation: -60
@@ -154,14 +158,11 @@ blocks:
154158
type: Card
155159
layout:
156160
span: 8
161+
properties:
162+
title: Genre Counts
157163
blocks:
158-
- id: title
159-
type: Markdown
160-
properties:
161-
content: "#### Genre Counts"
162-
level: 4
163164
- id: pie_chart
164-
type: AmCharts4Pie
165+
type: AmChartsPie
165166
properties:
166167
height: 400
167168
data:
@@ -188,20 +189,17 @@ blocks:
188189
- '#5A8DF8'
189190
- '#7EABFF'
190191

191-
192192
- id: table_card
193193
type: Card
194+
properties:
195+
title: 100 Movies with Largest Difference between Critic and Viewer Ratings
194196
blocks:
195-
- id: title
196-
type: Markdown
197-
properties:
198-
content: "#### 100 Movies with Largest Difference between Critic and Viewer Ratings"
199197
- id: table
200-
type: AgGrid
198+
type: AgGridAlpine
201199
properties:
202200
theme: basic
203201
rowData:
204-
_request: top_100_movies
202+
_request: top_100_score_difference_movies
205203
defaultColDef: # Define default column definitions that apply to all the defined columns
206204
sortable: true # Enables sorting on the columns when the header is clicked
207205
resizable: true # Enables resizing of column widths
@@ -213,39 +211,63 @@ blocks:
213211
- headerName: Year
214212
field: year
215213
width: 100
214+
- headerName: Difference
215+
field: difference
216+
width: 160
217+
type: numericColumn # Setting this aligns the number on the right
218+
valueFormatter:
219+
_function: # Provide a fprmatter function to pretty render the data value.
220+
__format.intlNumberFormat:
221+
on:
222+
__args: 0.value
223+
params:
224+
options:
225+
minimumFractionDigits: 1 # Format the number with 1 decimal place
216226
- headerName: Viewer Rating
217227
field: viewerRating
218228
width: 160
219-
type: numericColumn # Setting this aligns the number on the right
229+
type: numericColumn
220230
valueFormatter:
221-
type: intlNumberFormat # Format the number with 1 decimal place
222-
properties:
223-
options:
224-
maximumFractionDigits: 1
231+
_function:
232+
__format.intlNumberFormat:
233+
on:
234+
__args: 0.value
235+
params:
236+
options:
237+
maximumFractionDigits: 1
225238
- headerName: Critic Rating
226239
field: criticRating
227240
width: 160
228241
type: numericColumn
229242
valueFormatter:
230-
type: intlNumberFormat
231-
properties:
232-
options:
233-
maximumFractionDigits: 1
243+
_function:
244+
__format.intlNumberFormat:
245+
on:
246+
__args: 0.value
247+
params:
248+
options:
249+
maximumFractionDigits: 1
234250
- headerName: Viewer Reviews
235251
field: viewerReviews
236252
width: 160
237253
type: numericColumn
238254
valueFormatter:
239-
type: intlNumberFormat # Format the number with 0 decimal places
240-
properties:
241-
options:
242-
maximumFractionDigits: 0
255+
_function:
256+
__format.intlNumberFormat:
257+
on:
258+
__args: 0.value
259+
params:
260+
options:
261+
maximumFractionDigits: 0
243262
- headerName: Critic Reviews
244263
field: criticReviews
245264
width: 160
246265
type: numericColumn
247266
valueFormatter:
248-
type: intlNumberFormat
249-
properties:
250-
options:
251-
maximumFractionDigits: 1
267+
_function:
268+
__format.intlNumberFormat:
269+
on:
270+
__args: 0.value
271+
params:
272+
options:
273+
maximumFractionDigits: 0

0 commit comments

Comments
 (0)