Commit 086f80c7 authored by marc duez's avatar marc duez

graph.js : use approximate value for paths

parent cc645746
......@@ -561,7 +561,7 @@ Graph.prototype = {
y = (p[m][1] * this.resizeH + this.marge5)
if (isNaN(x)) return ' M 0,' + this.resizeH;
if (isNaN(y)) return ' M 0,' + this.resizeH;
tab.push([x,y]);
tab.push([x.toFixed(3),y.toFixed(3)]);
}
return this.lineGenerator(tab);
......@@ -647,7 +647,7 @@ Graph.prototype = {
y = (p[m][1] * self.resizeH + self.marge5)
if (isNaN(x)) return ' M 0,' + self.resizeH;
if (isNaN(y)) return ' M 0,' + self.resizeH;
tab.push([x,y]);
tab.push([x.toFixed(3),y.toFixed(3)]);
}
return this.lineGenerator(tab);
}else{
......
......@@ -11,9 +11,10 @@ QUnit.test("svg path builder", function(assert) {
var graph = new Graph("visu",m)
graph.max_ratio_between_deltas = 1.0
graph.init()
graph.lineGenerator = d3.line().curve(d3.curveLinear);
assert.equal(graph.constructPath(0), "M70.02,40.565412010323904C70.03,40.565412010323904,70.03999999999999,40.565412010323904,70.05,40.565412010323904C70.14999999999999,40.565412010323904,70.25,40.434587989676096,70.35,40.434587989676096C70.45,40.434587989676096,70.55,40.488884864051364,70.65,40.488884864051364C70.75,40.488884864051364,70.85000000000001,40.35806084340355,70.95,40.35806084340355C70.96000000000001,40.35806084340355,70.97,40.35806084340355,70.98,40.35806084340355")
assert.equal(graph.constructPathR(5), "M70,41.1C70,41.1,70,40.69623603097172,70,40.69623603097172C70.01666666666667,40.69623603097172,70.03333333333333,40.69623603097172,70.05,40.69623603097172C70.14999999999999,40.69623603097172,70.25,40.565412010323904,70.35,40.565412010323904C70.45,40.565412010323904,70.55,40.69623603097172,70.65,40.69623603097172C70.75,40.69623603097172,70.85000000000001,40.565412010323904,70.95,40.565412010323904C70.96666666666667,40.565412010323904,70.98333333333333,40.565412010323904,71,40.565412010323904C71,40.565412010323904,71,41.1,71,41.1")
assert.equal(graph.constructPath(0), "M70.02,40.565L70.05,40.565L70.35,40.435L70.65,40.489L70.95,40.358L70.98,40.358")
assert.equal(graph.constructPathR(5), "M70,41.1L70,40.696L70.05,40.696L70.35,40.565L70.65,40.696L70.95,40.565L71,40.565L71,41.1")
var stack = new Stack(m)
stack.compute();
assert.equal(graph.constructStack(1, stack), " M 70.05,40.95 L 70.35,40.9 L 70.65,40.925 L 70.95,40.85 L 70.95,40.75 L 70.65,40.875 L 70.35,40.7 L 70.05,40.85 Z", "path stack clone 1")
......@@ -28,6 +29,7 @@ QUnit.test("init", function(assert) {
var graph = new Graph("visu",m)
graph.max_ratio_between_deltas = 1.0
graph.init()
graph.lineGenerator = d3.line().curve(d3.curveLinear);
graph.initData()
assert.deepEqual(graph.data_data[0], {"active": false,
......@@ -40,7 +42,7 @@ QUnit.test("init", function(assert) {
assert.deepEqual(graph.data_clone[0], {
"id": 0,
"name": "line0",
"path": "M70.02,40.565412010323904C70.03,40.565412010323904,70.03999999999999,40.565412010323904,70.05,40.565412010323904C70.14999999999999,40.565412010323904,70.25,40.434587989676096,70.35,40.434587989676096C70.45,40.434587989676096,70.55,40.488884864051364,70.65,40.488884864051364C70.75,40.488884864051364,70.85000000000001,40.35806084340355,70.95,40.35806084340355C70.96000000000001,40.35806084340355,70.97,40.35806084340355,70.98,40.35806084340355"
"path": "M70.02,40.565L70.05,40.565L70.35,40.435L70.65,40.489L70.95,40.358L70.98,40.358"
},
"initClones")
......@@ -48,7 +50,7 @@ QUnit.test("init", function(assert) {
assert.deepEqual(graph.data_res[0], {
"id": 7,
"name": "resolution1",
"path": "M70,41.1C70,41.1,70,41,70,41C70.01666666666667,41,70.03333333333333,41,70.05,41C70.14999999999999,41,70.25,40.869175979352185,70.35,40.869175979352185C70.45,40.869175979352185,70.55,41,70.65,41C70.75,41,70.85000000000001,40.869175979352185,70.95,40.869175979352185C70.96666666666667,40.869175979352185,70.98333333333333,40.869175979352185,71,40.869175979352185C71,40.869175979352185,71,41.1,71,41.1"
"path": "M70,41.1L70,41L70.05,41L70.35,40.869L70.65,41L70.95,40.869L71,40.869L71,41.1"
},
"initRes")
......
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