mirror of
https://github.com/hanzoai/jube-fork.git
synced 2026-11-02 14:29:36 +00:00
155 lines
5.1 KiB
HTML
Executable File
155 lines
5.1 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Export</title>
|
|
<meta charset="utf-8">
|
|
<link href="../content/shared/styles/examples-offline.css" rel="stylesheet">
|
|
<link href="../../styles/kendo.common.min.css" rel="stylesheet">
|
|
<link href="../../styles/kendo.rtl.min.css" rel="stylesheet">
|
|
<link href="../../styles/kendo.default.min.css" rel="stylesheet">
|
|
<link href="../../styles/kendo.default.mobile.min.css" rel="stylesheet">
|
|
<script src="../../js/jquery.min.js"></script>
|
|
<script src="../../js/jszip.min.js"></script>
|
|
<script src="../../js/kendo.all.min.js"></script>
|
|
<script src="../content/shared/js/console.js"></script>
|
|
<script>
|
|
|
|
</script>
|
|
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<a class="offline-button" href="../index.html">Back</a>
|
|
|
|
<div id="example">
|
|
<div class="configurator">
|
|
<div class="header">Export options</div>
|
|
<div class="box-col">
|
|
<button class='export-pdf'>Export as PDF</button>
|
|
</div>
|
|
<div class="box-col">
|
|
<button class='export-img'>Export as Image</button>
|
|
</div>
|
|
<div class="box-col">
|
|
<button class='export-svg'>Export as SVG</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="map"></div>
|
|
|
|
<!-- Load Pako ZLIB library to enable PDF compression -->
|
|
<script src="https://kendo.cdn.telerik.com/2017.3.913/js/pako_deflate.min.js"></script>
|
|
|
|
<!-- Chroma.js used to colorize the map in the demo -->
|
|
<script src="../content/dataviz/map/js/chroma.min.js"></script>
|
|
|
|
<script>
|
|
$(".export-pdf").click(function () {
|
|
// Convert the DOM element to a drawing using kendo.drawing.drawDOM
|
|
kendo.drawing.drawDOM($("#map"))
|
|
.then(function (group) {
|
|
// Render the result as a PDF file
|
|
return kendo.drawing.exportPDF(group, {
|
|
paperSize: "auto",
|
|
margin: { left: "1cm", top: "1cm", right: "1cm", bottom: "1cm" }
|
|
});
|
|
})
|
|
.done(function (data) {
|
|
// Save the PDF file
|
|
kendo.saveAs({
|
|
dataURI: data,
|
|
fileName: "Map.pdf",
|
|
proxyURL: "https://demos.telerik.com/kendo-ui/service/export"
|
|
});
|
|
});
|
|
});
|
|
|
|
$(".export-img").click(function () {
|
|
// Convert the DOM element to a drawing using kendo.drawing.drawDOM
|
|
kendo.drawing.drawDOM($("#map"))
|
|
.then(function (group) {
|
|
// Render the result as a PNG image
|
|
return kendo.drawing.exportImage(group);
|
|
})
|
|
.done(function (data) {
|
|
// Save the image file
|
|
kendo.saveAs({
|
|
dataURI: data,
|
|
fileName: "Map.png",
|
|
proxyURL: "https://demos.telerik.com/kendo-ui/service/export"
|
|
});
|
|
});
|
|
});
|
|
|
|
$(".export-svg").click(function () {
|
|
// Convert the DOM element to a drawing using kendo.drawing.drawDOM
|
|
kendo.drawing.drawDOM($("#map"))
|
|
.then(function (group) {
|
|
// Render the result as a SVG document
|
|
return kendo.drawing.exportSVG(group);
|
|
})
|
|
.done(function (data) {
|
|
// Save the SVG document
|
|
kendo.saveAs({
|
|
dataURI: data,
|
|
fileName: "Map.svg",
|
|
proxyURL: "https://demos.telerik.com/kendo-ui/service/export"
|
|
});
|
|
});
|
|
});
|
|
|
|
function createMap() {
|
|
$("#map").kendoMap({
|
|
center: [30.2681, -97.7448],
|
|
zoom: 3,
|
|
layers: [{
|
|
type: "shape",
|
|
dataSource: {
|
|
type: "geojson",
|
|
transport: {
|
|
read: "../content/dataviz/map/countries-users.geo.json"
|
|
}
|
|
},
|
|
style: {
|
|
fill: {
|
|
opacity: 0.7
|
|
}
|
|
}
|
|
}],
|
|
shapeCreated: onShapeCreated,
|
|
shapeMouseEnter: onShapeMouseEnter,
|
|
shapeMouseLeave: onShapeMouseLeave
|
|
});
|
|
}
|
|
|
|
var scale = chroma
|
|
.scale(["white", "green"])
|
|
.domain([1, 1000]);
|
|
|
|
function onShapeCreated(e) {
|
|
var shape = e.shape;
|
|
var users = shape.dataItem.properties.users;
|
|
if (users) {
|
|
var color = scale(users).hex();
|
|
shape.options.fill.set("color", color);
|
|
}
|
|
}
|
|
|
|
function onShapeMouseEnter(e) {
|
|
e.shape.options.set("fill.opacity", 1);
|
|
}
|
|
|
|
function onShapeMouseLeave(e) {
|
|
e.shape.options.set("fill.opacity", 0.7);
|
|
}
|
|
|
|
$(document).ready(createMap);
|
|
</script>
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|