<!-- Client Side Code -->
<script type="text/javascript">
window.onload = function() {
//1. Get the Highcharts Graph from the Div containing it
var chart = $('#IDOfDivContainingHighchartsGraph').highcharts();
//2. Get SVG from Hicharts Export Service
var svgString = chart.getSVGForExport();
//3. Save it client side div to manipulate the fetched string
$('#exportedSVG').html(svgString);
//4. LOGIC TO REMOVE THE DUPLICATE TSPAN TAG
var svgTSPAN_TextElement=$("#exportedSVG text");
for(i=0;i<svgTSPAN_TextElement.length;i++){
childTspanElements=$(svgTSPAN_TextElement[i]).children("tspan");
if(childTspanElements.length==2){
childTspanElements[1].remove();
}
}
//5. Get the maniupluated object as string
svgString=$("#exportedSVG svg").get(0).outerHTML;
//6. POST Maniiulated SVG string
var url= '/URL/To/Server/Side.php';
$.ajax({
type: 'POST',
data: {svgString:svgString, upload:1},
url: url,
async: false,
success: function(data){
//Nothing here
}
});
}
</script>
//Server Side Code
<?php
if(isset($_POST["upload"])){
$SVGData=$_POST["svgString"];
$locationToSaveFile = "/location/to/Save/SVGFILE.svg";
file_put_contents($locationToSaveFile, $SVGData);
exit();
}
//By the end of this code you would have created the svg file of the hicharts on the server side
?>