Skip to content

Commit 1858e41

Browse files
added dash nivo, setup an api full calendar component example
1 parent 7a217b7 commit 1858e41

File tree

9 files changed

+781
-3
lines changed

9 files changed

+781
-3
lines changed

data/api.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import requests
2+
3+
4+
def get_events():
5+
url_events = "https://geomapindex.com/api/events"
6+
response = requests.get(url_events)
7+
return response.json()
8+
9+
10+
def format_event(event):
11+
return {
12+
"title": event['title'],
13+
"start": event['start'],
14+
"end": event['end'],
15+
"className": event['className'],
16+
"context": event['context']
17+
}
18+
19+
20+
def get_events_by_category(category):
21+
url_events = f"https://geomapindex.com/api/events/category/{category}"
22+
response = requests.get(url_events)
23+
if response.status_code == 200:
24+
events_data = response.json()
25+
formatted_events = [format_event(event) for event in events_data]
26+
return formatted_events
27+
else:
28+
return f"Error: {response.status_code}, {response.text}"
29+
30+
31+
if __name__ == "__main__":
32+
category = "Plotly" # or any other category
33+
events = get_events_by_category(category)
34+
35+
if isinstance(events, list):
36+
for event in events:
37+
print(event)
38+
else:
39+
print(events)

docs/dash_nivo/areabump.py

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
from dash import *
2+
from dash_nivo import AreaBump
3+
import json
4+
5+
data = [
6+
{
7+
"id": "JavaScript",
8+
"data": [
9+
{"x": 2000, "y": 17},
10+
{"x": 2001, "y": 28},
11+
{"x": 2002, "y": 10},
12+
{"x": 2003, "y": 29},
13+
{"x": 2004, "y": 13},
14+
{"x": 2005, "y": 15}
15+
]
16+
},
17+
{
18+
"id": "ReasonML",
19+
"data": [
20+
{"x": 2000, "y": 27},
21+
{"x": 2001, "y": 21},
22+
{"x": 2002, "y": 13},
23+
{"x": 2003, "y": 14},
24+
{"x": 2004, "y": 27},
25+
{"x": 2005, "y": 20}
26+
]
27+
},
28+
{
29+
"id": "TypeScript",
30+
"data": [
31+
{"x": 2000, "y": 22},
32+
{"x": 2001, "y": 23},
33+
{"x": 2002, "y": 20},
34+
{"x": 2003, "y": 23},
35+
{"x": 2004, "y": 17},
36+
{"x": 2005, "y": 13}
37+
]
38+
},
39+
{
40+
"id": "Elm",
41+
"data": [
42+
{"x": 2000, "y": 26},
43+
{"x": 2001, "y": 11},
44+
{"x": 2002, "y": 10},
45+
{"x": 2003, "y": 12},
46+
{"x": 2004, "y": 17},
47+
{"x": 2005, "y": 25}
48+
]
49+
},
50+
{
51+
"id": "CoffeeScript",
52+
"data": [
53+
{"x": 2000, "y": 22},
54+
{"x": 2001, "y": 20},
55+
{"x": 2002, "y": 14},
56+
{"x": 2003, "y": 28},
57+
{"x": 2004, "y": 15},
58+
{"x": 2005, "y": 28}
59+
]
60+
}
61+
]
62+
63+
64+
component = html.Div([
65+
AreaBump(
66+
id='area-bump',
67+
data=data,
68+
margin={'top': 40, 'right': 100, 'bottom': 40, 'left': 100},
69+
spacing=8,
70+
colors={'scheme': 'nivo'},
71+
blendMode='multiply',
72+
defs=[
73+
{
74+
'id': 'dots',
75+
'type': 'patternDots',
76+
'background': 'inherit',
77+
'color': '#38bcb2',
78+
'size': 4,
79+
'padding': 1,
80+
'stagger': True
81+
},
82+
{
83+
'id': 'lines',
84+
'type': 'patternLines',
85+
'background': 'inherit',
86+
'color': '#eed312',
87+
'rotation': -45,
88+
'lineWidth': 6,
89+
'spacing': 10
90+
}
91+
],
92+
fill=[
93+
{
94+
'match': {
95+
'id': 'CoffeeScript'
96+
},
97+
'id': 'dots'
98+
},
99+
{
100+
'match': {
101+
'id': 'TypeScript'
102+
},
103+
'id': 'lines'
104+
}
105+
],
106+
startLabel='id',
107+
endLabel='id',
108+
axisTop={
109+
'tickSize': 5,
110+
'tickPadding': 5,
111+
'tickRotation': 0,
112+
'legend': '',
113+
'legendPosition': 'middle',
114+
'legendOffset': -36
115+
},
116+
axisBottom={
117+
'tickSize': 5,
118+
'tickPadding': 5,
119+
'tickRotation': 0,
120+
'legend': '',
121+
'legendPosition': 'middle',
122+
'legendOffset': 32
123+
},
124+
),
125+
html.Div(id='click-data', style={'color': 'black'})
126+
], style={'backgroundColor': 'white', "color": "black"})
127+
128+
@callback(
129+
Output('click-data', 'children'),
130+
Input('area-bump', 'clickedPoint')
131+
)
132+
133+
def display_click_data(clickedPoint):
134+
if clickedPoint is None:
135+
return 'Click on a point to see its data'
136+
return f'Clicked point: {json.dumps(clickedPoint, indent=2)}'
137+

docs/dash_nivo/dash_nivo.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: Dash Nivo
3+
description: Dash Nivo is a Dash component library for Nivo visualizations.
4+
endpoint: /pip/dash_nivo
5+
package: dash_nivo
6+
icon: la:chart-line
7+
---
8+
9+
### Installation
10+
11+
```bash
12+
pip install dash-nivo
13+
```
14+
### Area Bump Example
15+
.. exec::docs.dash_nivo.areabump
16+
17+
### Responsive Circle Example
18+
.. exec::docs.dash_nivo.responsivecircle

0 commit comments

Comments
 (0)