Commit 2337f4eb authored by Arne Johanson's avatar Arne Johanson

modified addDataPoint

parent 836a1729
......@@ -180,12 +180,12 @@ CanvasDataPlot.prototype.addDataSet = function(uniqueID, label, dataSet, colorSt
}
};
CanvasDataPlot.prototype.addDataPoint = function(uniqueID, dataPoint, updateDomains) {
CanvasDataPlot.prototype.addDataPoint = function(uniqueID, dataPoint, updateDomains, copyData) {
var i = this.dataIDs.indexOf(uniqueID);
if(i < 0 || (this.data[i].length > 0 && this.data[i][this.data[i].length-1][0] > dataPoint[0])) {
return;
}
this.data[i].push(dataPoint);
this.data[i].push(copyData ? dataPoint.slice(0) : dataPoint);
if(updateDomains) {
this.updateDomains(this.calculateXDomain(), this.calculateYDomain(), true);
......
......@@ -30,7 +30,7 @@ $(document).ready(function() {
});
plot1.addDataSet("ds1", "Test 1", data1, "orange", true, false);
plot1.addDataPoint("ds1", [15,0]); // Will not be added! (x values have to be in ascending order)
plot1.addDataPoint("ds1", [20,10]); // Will be added
plot1.addDataPoint("ds1", [20,10]); // Will be added.
plot1.addDataPoint("ds1", [21,0]);
plot1.updateDomains([-2,22], [-60,15], true);
// Since we told addDataSet() not to copy our data, data1 is mutated by addDataPoint().
......@@ -59,7 +59,9 @@ $(document).ready(function() {
time.setHours(101);
// Since we told addDataSet() to copy our data, ts1 is not mutated by addDataPoint().
// Cf. the plot of ts1 in the plot group below.
plot2.addDataPoint("ds1", [time, 1.5], true);
var newDataPoint = [time, 1.5];
plot2.addDataPoint("ds1", newDataPoint, true, true);
newDataPoint[1] = 3.0; // Has no effect since we told addDataPoint() to copy the new value.
var tsPlotGroup = new CanvasDataPlotGroup(d3.select("#maincontainer"), [550, 350], true, true, {});
tsPlotGroup.addDataSet("CanvasTimeSeriesPlot", "ds1", "Signal 1", ts1, "orange", {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment