gc_plot2_out_test.html 2.11 KB
Newer Older
1 2 3
<html>
  <head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
incardon's avatar
incardon committed
4
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
5 6 7 8
    <script type="text/javascript">
      google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(drawVisualization);

incardon's avatar
incardon committed
9 10 11 12 13 14 15 16 17 18
function exportToSVG(i)
{
var e = document.getElementById('chart_div'+i);
var svg = e.getElementsByTagName('svg')[0].parentNode.innerHTML;
var pos = svg.lastIndexOf("</svg>");
pos += 6;
svg = svg.substring(0,4)  + " xmlns='http://www.w3.org/2000/svg' xmlns:xlink= 'http://www.w3.org/1999/xlink' " + svg.substring(4,pos);
svgData = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg);
$(this).attr({'href': svgData,'target': '_blank'});
}
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45

      function drawVisualization() {
var data0 = new google.visualization.DataTable();
data0.addColumn('string','X Axis');
data0.addColumn('number','line0');
data0.addColumn('number','line1');
data0.addColumn('number','line2');
data0.addColumn('number','line3');
data0.addColumn('number','line4');
data0.addColumn('number','line5');
data0.addColumn('number','line6');
data0.addColumn('number','line7');
data0.addColumn('number','line8');
data0.addRows([
['colum1',0.1,0.2,0.19,0.22,0.195,0.215,0.35,0.34,0.36],
['colum2',0.11,0.21,0.18,0.22,0.19,0.215,0.36,0.35,0.37],
['colum3',0.12,0.22,0.21,0.23,0.215,0.225,0.35,0.34,0.36],
['colum4',0.15,0.25,0.2,0.26,0.22,0.255,0.36,0.35,0.37],
['colum5',0.09,0.29,0.25,0.3,0.26,0.295,0.35,0.34,0.36],
['colum6',0.08,0.28,0.27,0.29,0.275,0.285,0.36,0.35,0.37],
]);
var options0= {
title : 'Example',
vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'},
curveType: 'function',
lineWidth: 1,
Pietro Incardona's avatar
Pietro Incardona committed
46
intervals: { 'style':'area' }};
incardon's avatar
incardon committed
47
$("#export_svg0").on("click", function (event) {exportToSVG.apply(this,[0]);});
incardon's avatar
incardon committed
48 49
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));
chart.draw(data0, options0);
50 51 52
}</script>
</head>
<body>
incardon's avatar
incardon committed
53
<a href="#" download="graph1.svg" id="export_svg0"><button>Export data into svg</button></a><div id="chart_div0" style="width: 900px; height: 500px;"></div>
54 55
</body>
</html>