Configuration API for PubNub EON Chart SDK
Configuration
eon.chart
instance is storage for user-provided information which describe further PubNub client behavior. Configuration instance contain additional set of properties which allow to perform precise PubNub client configuration.
Method(s)
To create configuration
instance you can use the following function in the EON Chart SDK:
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
channels | Array | Optional | false | An array of PubNub channels to subscribe to. Either channels or channelGroups must be supplied. |
channelGroups | Array | Optional | false | An array of PubNub channel groups to subscribe to. Either channels or channelGroups must be supplied. |
generate | undefined | Your C3 chart generation config. | ||
flow | false | Used to update spline charts over time series. | ||
limit | 10 | The size of your buffer. How many values to display on the chart before shifting the first value off and appending a new value. This is not native to C3. | ||
rate | 1000 | Interval at which new datapoints are drawn on the chart in milliseconds. | ||
history | false | Fill the buffer by using PubNub history call to retrieve last limit messages. Requires Message Persistence to be enabled. | ||
xType | auto | Your x axis configuration. Can be auto , custom , category , or false . Read more about xType below. | ||
xId | x | Your x axis source if xType == "custom" . | ||
message | function(message, env, channel){} | A function to call everytime a PubNub message is recieved. See PubNub subscribe. | ||
transform | function(m){return m} | Method for changing the payload format of your stream. See example. | ||
connect | function(){} | A function to call when PubNub makes a connection. See PubNub subscribe | ||
pubnub | Instance | Yes | false | An instance of the PubNub javascript global. This is required when using your own keys. |
debug | false | Log EON events to console as they happen |
Basic Usage
Required UUID
Always set the UUID
to uniquely identify the user or device that connects to PubNub. This UUID
should be persisted, and should remain unchanged for the lifetime of the user or the device. If you don't set the UUID
, you won't be able to connect to PubNub.
eon.chart({
pubnub: pubnub,
channels: ["c3-spline"], // the pubnub channel for real time data
generate: { // c3 chart object
bindto: '#chart'
},
});
X Axis Configuration
Automatic
eon-chart will automatically use the PubNub message timestamp for chart x values. This timestamp is recorded when a message is published to PubNub servers. This is the case when xType
is set to "auto"
.
Custom
If you'd like to supply your own Javascript timestamp, set xType
to custom
. Then, set xId
to the x value that appears within your published messages. Any custom x
must be a microtime date like 1465417017340
.
Required UUID
Always set the UUID
to uniquely identify the user or device that connects to PubNub. This UUID
should be persisted, and should remain unchanged for the lifetime of the user or the device. Not setting the UUID
can significantly impact your billing if your account uses the Monthly Active Users (MAUs) based pricing model, and can also lead to unexpected behavior if you have Presence enabled.
let pubnub = new PubNub({
publishKey: 'demo', // replace with your own pub-key
subscribeKey: 'demo' // replace with your own sub-key
});
eon.chart({
pubnub: pubnub,
channels: ["c3-spline"], // the pubnub channel for real time data
generate: { // c3 chart object
bindto: '#chart'
},
xType: 'custom',
xId: 'x'
});