forked from enviPath/enviPy
Merge remote-tracking branch 'origin/develop' into feature/frontend_update
This commit is contained in:
@ -646,8 +646,8 @@ function handleAssessmentResponse(depict_url, data) {
|
||||
var reactivityCentersImgSrc = null;
|
||||
|
||||
if (data['assessment']['node'] !== undefined) {
|
||||
functionalGroupsImgSrc = "<img width='400' src='" + data['assessment']['node']['image'] + "'>";
|
||||
reactivityCentersImgSrc = "<img width='400' src='" + data['assessment']['node']['image'] + "'>"
|
||||
functionalGroupsImgSrc = "<img width='400' src='" + data['assessment']['node']['image'] + "&highlight=true'>";
|
||||
reactivityCentersImgSrc = "<img width='400' src='" + data['assessment']['node']['image'] + "&highlightReactivity=true'>"
|
||||
} else {
|
||||
functionalGroupsImgSrc = "<img width='400' src=\"" + depict_url + "?smiles=" + encodeURIComponent(data['assessment']['smiles']) + "\">";
|
||||
reactivityCentersImgSrc = "<img width='400' src=\"" + depict_url + "?smiles=" + encodeURIComponent(data['assessment']['smiles']) + "\">"
|
||||
@ -784,4 +784,4 @@ function handleAssessmentResponse(depict_url, data) {
|
||||
|
||||
$("#appDomainAssessmentResultTable").append(res);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -444,6 +444,13 @@ function serializeSVG(svgElement) {
|
||||
line.setAttribute("fill", style.fill);
|
||||
});
|
||||
|
||||
svgElement.querySelectorAll("line.link_no_arrow").forEach(line => {
|
||||
const style = getComputedStyle(line);
|
||||
line.setAttribute("stroke", style.stroke);
|
||||
line.setAttribute("stroke-width", style.strokeWidth);
|
||||
line.setAttribute("fill", style.fill);
|
||||
});
|
||||
|
||||
const serializer = new XMLSerializer();
|
||||
let svgString = serializer.serializeToString(svgElement);
|
||||
|
||||
@ -455,7 +462,26 @@ function serializeSVG(svgElement) {
|
||||
return svgString;
|
||||
}
|
||||
|
||||
function shrinkSVG(svgSelector) {
|
||||
|
||||
const svg = d3.select(svgSelector);
|
||||
const node = svg.node();
|
||||
|
||||
// Compute bounding box of everything inside the SVG
|
||||
const bbox = node.getBBox();
|
||||
|
||||
const padding = 10;
|
||||
svg.attr("viewBox",
|
||||
`${bbox.x - padding} ${bbox.y - padding} ${bbox.width + 2 * padding} ${bbox.height + 2 * padding}`
|
||||
)
|
||||
.attr("width", bbox.width + 2 * padding)
|
||||
.attr("height", bbox.height + 2 * padding);
|
||||
|
||||
return bbox;
|
||||
}
|
||||
|
||||
function downloadSVG(svgElement, filename = 'chart.svg') {
|
||||
shrinkSVG("#" + svgElement.id);
|
||||
const svgString = serializeSVG(svgElement);
|
||||
const blob = new Blob([svgString], {type: 'image/svg+xml;charset=utf-8'});
|
||||
const url = URL.createObjectURL(blob);
|
||||
|
||||
Reference in New Issue
Block a user