1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| <!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>Exports 01</title>
<link href="https://playground.anychart.com/GzVSrjUE/iframe" rel="canonical">
<meta content="Bar Chart,Bar Graph,Column Chart,Vertical Chart" name="keywords">
<meta content="AnyChart - JavaScript Charts designed to be embedded and integrated" name="description">
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<link href="https://cdn.anychart.com/releases/8.11.0/css/anychart-ui.min.css?hcode=a0c21fc77e1449cc86299c5faa067dc4" rel="stylesheet" type="text/css">
<style>html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
button {
margin: 10px 0 0 10px;
}
#container {
position: absolute;
width: 100%;
top: 35px;
bottom: 0;
}</style>
</head>
<body>
<button onclick="png()">PNG</button>
<button onclick="svg()">SVG</button>
<button onclick="jpg()">JPG</button>
<div id="container"></div>
<script src="https://cdn.anychart.com/releases/8.11.0/js/anychart-base.min.js?hcode=a0c21fc77e1449cc86299c5faa067dc4"></script>
<script src="https://cdn.anychart.com/releases/8.11.0/js/anychart-exports.min.js?hcode=a0c21fc77e1449cc86299c5faa067dc4"></script>
<script src="https://cdn.anychart.com/releases/8.11.0/js/anychart-ui.min.js?hcode=a0c21fc77e1449cc86299c5faa067dc4"></script>
<script type="text/javascript">anychart.onDocumentReady(function () {
// data
var data = [
["Chocolate paste", 5],
["White honey", 2],
["Strawberry jam", 2],
["Condensed milk", 1]
];
// set chart type
chart = anychart.bar(data);
// set chart title
chart.title("Save as Image Buttons");
// display chart
chart.container("container").draw();
});
// save the chart as png
function png() {
chart.saveAsPng({"width": 360,
"height": 500,
"quality": 0.3,
"filename": "My Chart PNG"});
};
// save the chart as svg
function svg() {
chart.saveAsSvg({"paperSize": "A4",
"landscape": false,
"filename": "My Chart SVG"});
};
// save the chart as jpg
function jpg() {
chart.saveAsJpg({"width": 360,
"height": 500,
"quality": 0.3,
"forceTransparentWhite": false,
"filename": "My Chart JPG"});
};</script>
</body>
</html> |
Partager