block by boeric 3b57a788a4b96e1af211

D3 Based Real Time Chart

Full Screen

D3 Based Real Time Chart

The real time chart is a resuable Javascript component that accepts real time data. The chart’s time domain is moving with the passage of time, which means that any data placed in the chart eventually will age out and leave the chart. In addition to the main chart, the component also manages a “focus” window with a viewport (d3.brush) that can moved and sized to view an arbitrary portion of the time series data.

The component adheres to the pattern described in Towards Reusable Chart.

The following options are currently supported:

Future options will include:

Use the component like so:

// create the real time chart
var chart = realTimeChart()
    .title("Chart Title")
    .yTitle("Y Scale")
    .xTitle("X Scale")

// invoke the chart
var chartDiv ="#viewDiv").append("div")
    .attr("id", "chartDiv")

// create new data item and inject into chart
var now = new Date();
var obj = {
  value: 50
  time: now,
  color: "red",
  ts: now.getTime(),
  interval: timeout

// send the datum to the chart