-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
|
||
CHART_ID="chart1" | ||
LAYOUT="Chart: [[data: [[0]], transform: numbers, id: $CHART_ID]]" | ||
|
||
start_page() | ||
{ | ||
# start the server, providing an initial layout | ||
awe start --open-browser --obj "${LAYOUT}" & | ||
|
||
# cleanup to stop server when script is done | ||
local server_pid=$? | ||
trap "kill ${server_pid}" EXIT | ||
} | ||
|
||
wait_for_started() | ||
{ | ||
for i in $(seq 5); do | ||
echo "waiting for page to start (attempt: $i)" | ||
awe --quiet status && break || sleep 1 | ||
done | ||
} | ||
|
||
add_data() | ||
{ | ||
# add points to chart in a loop | ||
for index in $(seq 1 10); do | ||
echo "index: $index" | ||
# data is a list of entries. in this case, because we are using the numbers transformer, | ||
# each entry is a list of numbers itself. | ||
awe -q call --element-id ${CHART_ID} -m add -k "data: [[$index]]" | ||
sleep 0.3 | ||
done | ||
} | ||
|
||
main() | ||
{ | ||
start_page | ||
wait_for_started | ||
add_data | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import time | ||
|
||
from awe import Page, APIClient | ||
|
||
|
||
def main(): | ||
chart_id = 'chart1' | ||
|
||
# normally, when using the API client, the page is started elsewhere. | ||
# for the sake of keeping this example simple, the page is started here. | ||
page = Page() | ||
page.new_chart(data=[[0]], transform='numbers', id=chart_id) | ||
page.start() | ||
|
||
# create an API client instance | ||
client = APIClient() | ||
|
||
# add points to the chart in a loop | ||
for i in range(10): | ||
# data is a list of entries. in this case, because we are using the numbers transformer, | ||
# each entry is a list of numbers itself. | ||
client.call_method(chart_id, 'add', {'data': [[i]]}) | ||
time.sleep(1) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |