What is the most efficient method for setting the x domain of an nvd3 chart to display a specific time period, such as the last hour, in a real-time line chart? Essentially, I need to continuously add new data points (y values with corresponding timestamps) every second while ensuring that the x axis only displays the past hour. Currently, I am updating the forceX property with each new data point, but this approach seems inefficient.
var startDate = (new Date()).getTime();
startDate = startDate-3600000;
options.chart.forceX = [startDate,new Date()];
data[0].values.push({x: new Date(), y: newValue});
api.update();
Is there a more effective way to achieve this?