Commit ca278404 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Migrate server to flask (python)

parent b2af07ed
*/__pycache__
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.5.2 (/usr/bin/python3.5)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="6f64fbdd-2ff7-4c87-84d0-38027b4fc1bc" name="Default" comment="" />
<list default="true" id="6f64fbdd-2ff7-4c87-84d0-38027b4fc1bc" name="Default" comment="">
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/vcs.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/misc.xml" afterPath="$PROJECT_DIR$/.idea/misc.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/js/draw_graph.js" afterPath="$PROJECT_DIR$/js/draw_graph.js" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/load_file.php" afterPath="$PROJECT_DIR$/load_file.php" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
......@@ -11,11 +17,11 @@
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="prepare_paf.py" pinned="false" current-in-tab="true">
<file leaf-file-name="prepare_paf.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/prepare_paf.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="841">
<caret line="94" column="38" lean-forward="false" selection-start-line="94" selection-start-column="38" selection-end-line="94" selection-end-column="38" />
<state relative-caret-position="178">
<caret line="55" column="32" lean-forward="false" selection-start-line="55" selection-start-column="32" selection-end-line="55" selection-end-column="32" />
<folding>
<element signature="e#634#643#0" expanded="true" />
</folding>
......@@ -23,24 +29,108 @@
</provider>
</entry>
</file>
<file leaf-file-name="main.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/srv/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="476">
<caret line="28" column="50" lean-forward="true" selection-start-line="28" selection-start-column="50" selection-end-line="28" selection-end-column="50" />
<folding>
<element signature="e#24#33#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="parse_paf.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/parse_paf.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="408">
<caret line="57" column="52" lean-forward="false" selection-start-line="57" selection-start-column="52" selection-end-line="57" selection-end-column="52" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="draw_graph.js" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/js/draw_graph.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="271">
<caret line="146" column="40" lean-forward="false" selection-start-line="146" selection-start-column="22" selection-end-line="146" selection-end-column="40" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="style.css" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/css/style.css">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="index.html" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/srv/templates/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
<caret line="14" column="20" lean-forward="false" selection-start-line="14" selection-start-column="20" selection-end-line="14" selection-end-column="20" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="hello.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/srv/hello.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="HTML File" />
<option value="Python Script" />
</list>
</option>
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>sprintf</find>
<find>900</find>
<find>path.content-lines</find>
</findStrings>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/lib/prepare_paf.py" />
<option value="$PROJECT_DIR$/srv/templates/index.html" />
<option value="$PROJECT_DIR$/srv/main.py" />
<option value="$PROJECT_DIR$/lib/parse_paf.py" />
<option value="$PROJECT_DIR$/js/draw_graph.js" />
</list>
</option>
</component>
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsFlowSettings">
<service-enabled>true</service-enabled>
<exe-path />
<annotation-enable>false</annotation-enable>
<other-services-enabled>true</other-services-enabled>
<auto-save>true</auto-save>
</component>
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
<sorting>DEFINITION_ORDER</sorting>
......@@ -50,6 +140,7 @@
<option name="width" value="1233" />
<option name="height" value="716" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
......@@ -73,6 +164,32 @@
<item name="igenocomp" type="b2602c69:ProjectViewProjectNode" />
<item name="igenocomp" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="igenocomp" type="b2602c69:ProjectViewProjectNode" />
<item name="igenocomp" type="462c0819:PsiDirectoryNode" />
<item name="css" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="igenocomp" type="b2602c69:ProjectViewProjectNode" />
<item name="igenocomp" type="462c0819:PsiDirectoryNode" />
<item name="js" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="igenocomp" type="b2602c69:ProjectViewProjectNode" />
<item name="igenocomp" type="462c0819:PsiDirectoryNode" />
<item name="lib" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="igenocomp" type="b2602c69:ProjectViewProjectNode" />
<item name="igenocomp" type="462c0819:PsiDirectoryNode" />
<item name="srv" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="igenocomp" type="b2602c69:ProjectViewProjectNode" />
<item name="igenocomp" type="462c0819:PsiDirectoryNode" />
<item name="srv" type="462c0819:PsiDirectoryNode" />
<item name="templates" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
......@@ -83,6 +200,15 @@
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="DefaultHtmlFileTemplate" value="HTML File" />
<property name="settings.editor.selected.configurable" value="Settings.JavaScript" />
<property name="JavaScriptPreferStrict" value="false" />
<property name="JavaScriptWeakerCompletionTypeGuess" value="true" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/srv" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
......@@ -111,13 +237,14 @@
</component>
<component name="ToolWindowManager">
<frame x="58" y="0" width="1862" height="1080" extended-state="6" />
<editor active="true" />
<layout>
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25825992" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25825992" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
......@@ -164,15 +291,65 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/srv/hello.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/srv/templates/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
<caret line="14" column="20" lean-forward="false" selection-start-line="14" selection-start-column="20" selection-end-line="14" selection-end-column="20" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/css/style.css">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/prepare_paf.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="841">
<caret line="94" column="38" lean-forward="false" selection-start-line="94" selection-start-column="38" selection-end-line="94" selection-end-column="38" />
<state relative-caret-position="178">
<caret line="55" column="32" lean-forward="false" selection-start-line="55" selection-start-column="32" selection-end-line="55" selection-end-column="32" />
<folding>
<element signature="e#634#643#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/srv/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="476">
<caret line="28" column="50" lean-forward="true" selection-start-line="28" selection-start-column="50" selection-end-line="28" selection-end-column="50" />
<folding>
<element signature="e#24#33#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/parse_paf.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="408">
<caret line="57" column="52" lean-forward="false" selection-start-line="57" selection-start-column="52" selection-end-line="57" selection-end-column="52" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/draw_graph.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="271">
<caret line="146" column="40" lean-forward="false" selection-start-line="146" selection-start-column="22" selection-end-line="146" selection-end-column="40" />
<folding />
</state>
</provider>
</entry>
</component>
</project>
\ No newline at end of file
......@@ -27,11 +27,9 @@ d3.boxplot.posX = null;
d3.boxplot.posY = null;
d3.boxplot.old_translate = null;
d3.boxplot.full_pict = null;
d3.boxplot.init = function () {
$.get("load_file.php",
{},
$.post("/get_graph",
{"id": "araduvseve2"},
function (data) {
let res = null;
try {
......@@ -84,40 +82,41 @@ d3.boxplot.select_zone = function (x, y) {
//Compute X and Y scales to zoom into zone:
let x_len_zone = d3.boxplot.x_zones[x_zone][1] - d3.boxplot.x_zones[x_zone][0];
let y_len_zone = d3.boxplot.y_zones[y_zone][1] - d3.boxplot.y_zones[y_zone][0];
let scale_x = d3.boxplot.x_len / x_len_zone;
let scale_y = d3.boxplot.y_len / y_len_zone;
let lines_s = [];
let my_x_zone = [d3.boxplot.x_zones[x_zone][0] / d3.boxplot.scale * d3.boxplot.x_len, d3.boxplot.x_zones[x_zone][1] / d3.boxplot.scale * d3.boxplot.x_len];
let my_y_zone = [d3.boxplot.y_zones[y_zone][0] / d3.boxplot.scale * d3.boxplot.y_len, d3.boxplot.y_zones[y_zone][1] / d3.boxplot.scale * d3.boxplot.y_len];
for (let l in d3.boxplot.lines) {
let line = d3.boxplot.lines[l].slice(0);
if (((line[0] >= my_x_zone[0] && line[0] < my_x_zone[1]) || (line[1] >= my_x_zone[0] && line[1] < my_x_zone[1]))
&& ((line[2] >= my_y_zone[0] && line[2] < my_y_zone[1]) ||
(line[3] >= my_y_zone[0] && line[3] < my_y_zone[1]))) {
//console.log(line);
line[0] -= my_x_zone[0];
line[1] -= my_x_zone[0];
line[2] -= my_y_zone[0];
line[3] -= my_y_zone[0];
if (line[1] < 0)
console.log("WARN!!!", line[0]);
//console.log(line);
lines_s.push(line);
}
}
d3.selectAll("line.content-lines").remove();
d3.boxplot.draw_lines(lines_s, my_x_zone[1] - my_x_zone[0], my_y_zone[1] - my_y_zone[0]);
let scale_x = d3.boxplot.scale / x_len_zone;
let scale_y = d3.boxplot.scale / y_len_zone;
//
// let lines_s = [];
//
// let my_x_zone = [d3.boxplot.x_zones[x_zone][0] / d3.boxplot.scale * d3.boxplot.x_len, d3.boxplot.x_zones[x_zone][1] / d3.boxplot.scale * d3.boxplot.x_len];
// let my_y_zone = [d3.boxplot.y_zones[y_zone][0] / d3.boxplot.scale * d3.boxplot.y_len, d3.boxplot.y_zones[y_zone][1] / d3.boxplot.scale * d3.boxplot.y_len];
//
// for (let l in d3.boxplot.lines) {
// let line = d3.boxplot.lines[l].slice(0);
// if (((line[0] >= my_x_zone[0] && line[0] < my_x_zone[1]) || (line[1] >= my_x_zone[0] && line[1] < my_x_zone[1]))
// && ((line[2] >= my_y_zone[0] && line[2] < my_y_zone[1]) ||
// (line[3] >= my_y_zone[0] && line[3] < my_y_zone[1]))) {
// //console.log(line);
// line[0] -= my_x_zone[0];
// line[1] -= my_x_zone[0];
// line[2] -= my_y_zone[0];
// line[3] -= my_y_zone[0];
// if (line[1] < 0)
// console.log("WARN!!!", line[0]);
// //console.log(line);
// lines_s.push(line);
// }
// }
//
// d3.selectAll("line.content-lines").remove();
// d3.boxplot.draw_lines(lines_s, my_x_zone[1] - my_x_zone[0], my_y_zone[1] - my_y_zone[0]);
//Zoom in:
//d3.boxplot.container
// .attr("transform", "scale(" + scale_x + "," + scale_y + ")" +
// "translate(-" + (d3.boxplot.x_zones[x_zone][0]) + ",-" + (d3.boxplot.y_len - d3.boxplot.y_zones[y_zone][1]) + ")");
//Correct lines stroke width to be not impacted by the zoom:
//d3.selectAll("line.content-lines").attr("stroke-width", (d3.boxplot.x_len / 400) / Math.min(scale_x, scale_y));
d3.boxplot.container
.attr("transform", "scale(" + scale_x + "," + scale_y + ")" +
"translate(-" + (d3.boxplot.x_zones[x_zone][0]) + ",-" + (d3.boxplot.scale - d3.boxplot.y_zones[y_zone][1]) + ")");
// Correct lines stroke width to be not impacted by the zoom:
d3.selectAll(".content-lines").attr("stroke-width", (d3.boxplot.scale / 400) / Math.min(scale_x, scale_y));
d3.selectAll("line.break-lines").style("visibility", "hidden");
//Update left and bottom axis:
......@@ -139,13 +138,31 @@ d3.boxplot.select_zone = function (x, y) {
};
d3.boxplot.reset_scale = function () {
//Reset scale:
// d3.boxplot.container.attr("transform", "scale(1,1)translate(0,0)");
//
// //Restore lines stroke width:
// d3.selectAll("line.content-lines").attr("stroke-width", d3.boxplot.scale / 400);
// d3.selectAll("line.break-lines").style("visibility","visible");
// d3.selectAll("line.break-lines").attr("stroke-width", d3.boxplot.scale / 800);
$("#loading").show();
window.setTimeout(() => {
//Reset scale:
d3.boxplot.container.attr("transform", "scale(1,1)translate(0,0)");
//Restore lines stroke width:
d3.selectAll("path.content-lines").attr("stroke-width", d3.boxplot.scale / 400);
d3.selectAll("line.break-lines").style("visibility","visible");
d3.selectAll("line.break-lines").attr("stroke-width", d3.boxplot.scale / 800);
//Update left and bottom axis:
d3.boxplot.draw_left_axis(d3.boxplot.y_len);
d3.boxplot.draw_bottom_axis(d3.boxplot.x_len);
//Update top and right axis:
d3.boxplot.draw_top_axis();
d3.boxplot.draw_right_axis();
d3.boxplot.zone_selected = false;
$("#loading").hide();
//Re-enable zoom:
d3.boxplot.zoom_enabled = true;
}, 0);
//
// //Restore axis:
// d3.boxplot.draw_left_axis(d3.boxplot.y_len);
......@@ -156,15 +173,11 @@ d3.boxplot.reset_scale = function () {
// d3.selectAll("line.content-lines").remove();
// d3.boxplot.draw_lines(d3.boxplot.lines, d3.boxplot.x_len, d3.boxplot.y_len);
$("#loading").show();
window.setTimeout(() => {
d3.select(".container").html(d3.boxplot.full_pict);
$("#loading").hide();
}, 0);
//Re-enable zoom:
d3.boxplot.zoom_enabled = true;
// $("#loading").show();
// window.setTimeout(() => {
// d3.select(".container").html(d3.boxplot.full_pict);
// $("#loading").hide();
// }, 0);
};
d3.boxplot.draw_left_axis = function (y_max, y_min = 0) {
......@@ -538,7 +551,7 @@ d3.boxplot.mousedown = function() {
let old_transform = d3.boxplot.container.attr("transform");
d3.boxplot.old_translate = [0, 0];
if (old_transform !== null) {
let search_tr = old_transform.match(/translate\(([-\d.]+),([-\d.]+)\)/);
let search_tr = old_transform.match(/translate\(([-\d.]+),\s*([-\d.]+)\)/);
d3.boxplot.old_translate = [parseFloat(search_tr[1]), parseFloat(search_tr[2])];
}
}
......@@ -562,7 +575,8 @@ d3.boxplot.translate = function () {
let scale_x = 1;
let scale_y = 1;
if (old_transform) {
let scale = old_transform.match(/scale\(([-\d.]+)(,([-\d.]+))?\)/);
console.log(old_transform);
let scale = old_transform.match(/scale\(([-\d.]+)(,\s*([-\d.]+))?\)/);
scale_x = scale[1];
scale_y = scale[1];
if (scale[3] !== undefined)
......@@ -584,7 +598,7 @@ d3.boxplot.translate = function () {
else if (translate[1] > min_tr[1]) {
translate[1] = min_tr[1];
}
let new_transform = vsprintf("translate(%f,%f) scale(%f,%f)", [translate[0], translate[1], scale_x, scale_y]);
let new_transform = `translate(${translate[0]}, ${translate[1]}) scale(${scale_x}, ${scale_y})`;
d3.boxplot.container.attr("transform", new_transform);
//Update axis:
......@@ -662,8 +676,8 @@ d3.boxplot.zoom = function () {
let zoom_f = 1.2;
let old_transform = d3.boxplot.container.attr("transform");
if (old_transform !== null) {
let search_tr = old_transform.match(/translate\(([-\de.]+),([-\de.]+)\)/);
let search_sc = old_transform.match(/scale\(([-\de.]+)(,[-\de.]+)?\)/);
let search_tr = old_transform.match(/translate\(([-\de.]+),\s*([-\de.]+)\)/);
let search_sc = old_transform.match(/scale\(([-\de.]+)(,\s*[-\de.]+)?\)/);
old_transform = {
"scale": parseFloat(search_sc[1]),
"translate": [parseFloat(search_tr[1]), parseFloat(search_tr[2])]
......@@ -685,14 +699,12 @@ d3.boxplot.zoom = function () {
new_scale = 1;
}
}
let new_transform = vsprintf("translate(%f,%f) scale(%f)",
[old_transform["translate"][0],
old_transform["translate"][1],
new_scale]);
let new_transform = `translate(${old_transform["translate"][0]},${old_transform["translate"][1]})
scale(${new_scale})`;
d3.boxplot.container.attr("transform", new_transform);
//Correct lines stroke width to be not impacted by the zoom:
d3.selectAll("line.content-lines").attr("stroke-width", (d3.boxplot.scale / 400) / new_scale);
d3.selectAll("path.content-lines").attr("stroke-width", (d3.boxplot.scale / 400) / new_scale);
d3.selectAll("line.break-lines").attr("stroke-width", (d3.boxplot.scale / 800) / new_scale);
//Update axis:
......@@ -717,7 +729,6 @@ d3.boxplot._sort_lines = function(l1, l2) {
}
d3.boxplot.draw_lines = function (lines, x_len=d3.boxplot.x_len, y_len=d3.boxplot.y_len) {
lines = lines.sort(d3.boxplot._sort_lines);
let color_idy_generic = {
0.0: "#d60004",
0.1: "#e37700",
......@@ -741,39 +752,81 @@ d3.boxplot.draw_lines = function (lines, x_len=d3.boxplot.x_len, y_len=d3.boxplo
}
let nb_lines = 0;
for (let i = 0; i < lines.length; i++) {
nb_lines++;
if (nb_lines > 50000) {
break;
// for (let i = 0; i < lines.length; i++) {
// nb_lines++;
// if (nb_lines > 50000) {
// break;
// }
// let line = lines[i];
// let x1 = line[0] / x_len * d3.boxplot.scale;
// let x2 = line[1] / x_len * d3.boxplot.scale;
// let y1 = d3.boxplot.scale - (line[2] / y_len * d3.boxplot.scale);
// let y2 = d3.boxplot.scale - (line[3] / y_len * d3.boxplot.scale);
// let line_len = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
// let color = "#000";
// for (let part in color_idy) {
// if (line[4] >= part) {
// color = color_idy[part];
// }
// }
// d3.boxplot.container.append("line")
// .attr("x1", x1)
// .attr("y1", y1)
// .attr("x2", x2)
// .attr("y2", y2)
// .attr("class", "content-lines")
// .attr("stroke-width", d3.boxplot.scale / 400)
// .attr("stroke", line_len >= 1 ? color : "black");
// }
let lineFunction = function(d) {
let path = [];
for (let i=0; i < d.length; i++) {
let d_i = d[i];
let x1 = d_i[0] / x_len * d3.boxplot.scale;
let x2 = d_i[1] / x_len * d3.boxplot.scale;
let y1 = d3.boxplot.scale - (d_i[2] / y_len * d3.boxplot.scale);
let y2 = d3.boxplot.scale - (d_i[3] / y_len * d3.boxplot.scale);
path.push(`M${x1} ${y1},L${x2} ${y2}`);
}
let line = lines[i];
let x1 = line[0] / x_len * d3.boxplot.scale;
let x2 = line[1] / x_len * d3.boxplot.scale;
let y1 = d3.boxplot.scale - (line[2] / y_len * d3.boxplot.scale);
let y2 = d3.boxplot.scale - (line[3] / y_len * d3.boxplot.scale);
let line_len = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
let color = "#000";
for (let part in color_idy) {
if (line[4] >= part) {
color = color_idy[part];
}
}
d3.boxplot.container.append("line")
.attr("x1", x1)
.attr("y1", y1)
.attr("x2", x2)
.attr("y2", y2)
.attr("class", "content-lines")
.attr("stroke-width", d3.boxplot.scale / 400)
.attr("stroke", line_len >= 1 ? color : "black");
return path.join(",")
};
//lines = lines.sort(d3.boxplot._sort_lines);
if (lines["pos+"].length > 0) {
d3.boxplot.container.append("path")
.attr("d", lineFunction(lines["pos+"]))
.attr("class", "content-lines")
.attr("stroke-width", d3.boxplot.scale / 400)
.attr("stroke", "#0B610B");
}
if (lines["pos-"].length > 0) {
d3.boxplot.container.append("path")
.attr("d", lineFunction(lines["pos-"]))
.attr("class", "content-lines")
.attr("stroke-width", d3.boxplot.scale / 400)
.attr("stroke", "#43a743");
}
if (lines["neg+"].length > 0) {
d3.boxplot.container.append("path")
.attr("d", lineFunction(lines["neg+"]))
.attr("class", "content-lines")
.attr("stroke-width", d3.boxplot.scale / 400)
.attr("stroke", "#a55353");
}
if (