half finished download svg

This commit is contained in:
gauthiier
2019-12-31 10:14:40 +01:00
parent 4ebab083bf
commit 80926c0ff9
4 changed files with 13058 additions and 12369 deletions
+12367 -11781
View File
File diff suppressed because one or more lines are too long
+635 -587
View File
File diff suppressed because it is too large Load Diff
+55 -1
View File
@@ -28,6 +28,32 @@ $(document).ready(function(){
}); });
}); });
// $('#save').click(function(e){
// //get svg element.
// var svg = document.getElementById("svg");
// //get svg source.
// var serializer = new XMLSerializer();
// var source = serializer.serializeToString(svg);
// //add name spaces.
// if(!source.match(/^<svg[^>]+xmlns="http\:\/\/www\.w3\.org\/2000\/svg"/)){
// source = source.replace(/^<svg/, '<svg xmlns="http://www.w3.org/2000/svg"');
// }
// if(!source.match(/^<svg[^>]+"http\:\/\/www\.w3\.org\/1999\/xlink"/)){
// source = source.replace(/^<svg/, '<svg xmlns:xlink="http://www.w3.org/1999/xlink"');
// }
// //add xml declaration
// source = '<?xml version="1.0" standalone="no"?>\r\n' + source;
// //convert svg source to URI data scheme.
// var url = "data:image/svg+xml;charset=utf-8,"+encodeURIComponent(source);
// //set url value to a element's href attribute.
// document.getElementById("link").href = url;
// });
}); });
function search_result_archive(a, tags) { function search_result_archive(a, tags) {
@@ -140,7 +166,6 @@ function graph(data) {
} }
// console.log(vec);
var chart = c3.generate({ var chart = c3.generate({
bindto: '#graph', bindto: '#graph',
@@ -166,6 +191,35 @@ function graph(data) {
} }
} }
}); });
ex(chart);
}
function ex(chart) {
//get svg source.
var serializer = new XMLSerializer();
var source = serializer.serializeToString(chart.element);
//add name spaces.
if(!source.match(/^<svg[^>]+xmlns="http\:\/\/www\.w3\.org\/2000\/svg"/)){
source = source.replace(/^<svg/, '<svg xmlns="http://www.w3.org/2000/svg"');
}
if(!source.match(/^<svg[^>]+"http\:\/\/www\.w3\.org\/1999\/xlink"/)){
source = source.replace(/^<svg/, '<svg xmlns:xlink="http://www.w3.org/1999/xlink"');
}
//add xml declaration
source = '<?xml version="1.0" standalone="no"?>\r\n' + source;
//convert svg source to URI data scheme.
var url = "data:image/svg+xml;charset=utf-8,"+encodeURIComponent(source);
//set url value to a element's href attribute.
document.getElementById("link").href = url;
// $("a[href='nothing']").attr("href", "blabla");
} }
+1
View File
@@ -42,6 +42,7 @@
</tbody></table> </tbody></table>
</div> </div>
<div id="graph"></div> <div id="graph"></div>
<div id="export"><a id="link" href="">export</a></div>
<div id="results"></div> <div id="results"></div>
</body> </body>
</html> </html>