Skip to content

Instantly share code, notes, and snippets.

@jorgeyp
Last active August 2, 2016 07:39
Show Gist options
  • Save jorgeyp/8003df6ede122d6ae3d117dcca5e1874 to your computer and use it in GitHub Desktop.
Save jorgeyp/8003df6ede122d6ae3d117dcca5e1874 to your computer and use it in GitHub Desktop.
Proteus connector messages

Proteus connector messages

Rationale

We want the developers to be able to create charts from the backend code. In order to achieve that, Proteus-backend may send WebSocket messages containing a chart identifier along its data, visualisation type and aditional information like a label. With this design, the Proteus-charts library should be able to create new charts on demand for new charts from the backend.

Implementation

On the client side, the developer may set a container div where the library will create additional div containers for each new chart requested from the server.

Data format

The following is a proposed data format for the connector messages:

{
    "type": "linechart",
    "chart": "chart1",
    "label": "wow so charty, much data",
    "data": [{
        "key": "CO2",
        "values": [{
            "x": 1,
            "y": 10
        }]
    }, {
        "key": "SO2",
        "values": [{
            "x": 1,
            "y": 1.5
        }, {
            "x": 2,
            "y": 1.5
        }, {
            "x": 3,
            "y": 5
        }]
    }, {
        "key": "CO",
        "values": [{
            "x": 1,
            "y": 3
        }, {
            "x": 2,
            "y": 12
        }, {
            "x": 3,
            "y": 21
        }]
    }]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment