-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathchart.pug
48 lines (33 loc) · 1.63 KB
/
chart.pug
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
extends layout.pug
block content
h1 Embedding charts with signed parameters
p This is an example of an embedded chart with a signed parameter. Signed parameters are question parameters that must be signed by the embedding application.
p The parameter is "User ID". This parameter marked as "Locked". This means that the embedding application's server process must specify a value and sign the request. This prevents an end user of the application from changing the url and seeing other user's charts or dashboards. There is no reference to this ID in the embedded iframe, and it is kept a secret from the end user.
p To embed this graph in a webpage (as below), you'll need to generate a url on the server by signing a dictionary specifying the resource and its signed parameters as below
pre.
payload = {
"resource": {"question": 6},
"params": {
"user_id": user_id
}
}
token = jwt.encode(payload, METABASE_SECRET_KEY, algorithm="HS256")
iframeUrl = METABASE_SITE_URL + "/embed/question/" + token + "#bordered=true"
p In the place you want to embed the chart in your HTML, insert the below:
pre.
<iframe
src="#{iframeUrl}"
frameborder="0"
width="800"
height="600"
allowtransparency
/></iframe>
a(href="/") Go back to a global view
p The above code results should give you:
h1 Orders for User: #{userId}</h1>
iframe(
src=iframeUrl
frameborder="0"
width="800"
height="600"
allowtransparency)