Skip to content

Commit 2629e60

Browse files
committed
add example minimal graphic
1 parent 40086f0 commit 2629e60

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Reference: Minimal Graphic
2+
3+
This is a minimal implementation of a Graphic.
4+
It contains the minimum required properties and methods to be a valid Graphic.
5+
6+
_Note: This is intended to be used when developing and validating renderer systems._
7+
_If you're looking for a good starting point for developing Graphics, use the [Standard example](../standard/) instead._
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
class Graphic extends HTMLElement {
2+
connectedCallback() {
3+
// Called when the element is added to the DOM
4+
// Note: Don't paint any pixels at this point, wait for load() to be called
5+
}
6+
7+
async load(params) {
8+
if (params.renderType !== "realtime")
9+
throw new Error("Only realtime rendering is supported by this graphic");
10+
11+
const elText = document.createElement("p");
12+
elText.style.backgroundColor = "#ffffff";
13+
elText.style.color = "#000000";
14+
elText.style.display = "inline-block";
15+
elText.style.padding = "10px";
16+
elText.style.border = "1px solid #000000";
17+
elText.innerHTML = "Hello world!";
18+
this.appendChild(elText);
19+
20+
// When everything is loaded we can return:
21+
return {
22+
statusCode: 200,
23+
};
24+
}
25+
async dispose(_params) {
26+
this.innerHTML = "";
27+
}
28+
async getStatus(_params) {
29+
return {
30+
statusCode: 200,
31+
status: {
32+
// nothing
33+
},
34+
};
35+
}
36+
async updateAction(_params) {
37+
// No actions are implemented in this minimal example
38+
}
39+
async playAction(_params) {
40+
// No actions are implemented in this minimal example
41+
}
42+
async stopAction(_params) {
43+
// No actions are implemented in this minimal example
44+
}
45+
async customAction(params) {
46+
// No actions are implemented in this minimal example
47+
}
48+
async goToTime(_payload) {
49+
throw new Error("Non-realtime not supported!");
50+
}
51+
async setActionsSchedule(_payload) {
52+
throw new Error("Non-realtime not supported!");
53+
}
54+
}
55+
56+
export default Graphic;
57+
58+
// Note: The renderer will render the component
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "https://ograf.ebu.io/v1-draft-0/specification/json-schemas/graphics/schema.json",
3+
"name": "Minimal Test Graphic",
4+
"description": "This Graphic includes the bare minimum required to be a valid OGraf Graphic. It displays a 'Hello World!' message.",
5+
"id": "minimal-example",
6+
"supportsRealTime": true,
7+
"supportsNonRealTime": false
8+
}

0 commit comments

Comments
 (0)