Я пытаюсь сэкономить целую диаграмму пирога флота в PDF. Я использую jQuery/FLOT для рисования диаграммы пирога и диаграммы, я хотел бы, чтобы пользователь мог загрузить PDF-версию графиков флота.Сохраните график пирога в формате PDF
Любые идеи, пожалуйста, я ценю это.
Вот мой код
var data = [
{ label: "studentsCount", color: "#4572A7" ,data: <?php echo $studentsCount; ?>},
{ label: "lecturesCount", color: "#ED47E2" , data: <?php echo $lecturesCount; ?>}
];
$(document).ready(function() {
$.plot($("#placeholder"), data, {
series: {
pie: {
show: true,
radius: 1,
label: {
show: true,
radius:0.7,
formatter: function(label, series) {
var result =[ <?php echo $studentsCount; ?> , <?php echo $witnessedCount; ?>
];
if (label == "unwitnssedCount")
{
return '<div style="font-size:15px; text-align:center; left:-90px; top:-18px;
position:absolute; color:white;">'+label+'<br/>'+(result[0])+'</div>';
}
else if (label == "lecturesCount")
{
return '<div style="font-size:17px; text-align:center; left:-33px; top:-18px;
position:absolute; color:white;">'+label+'<br/>'+(result[1])+'</div>';
}
},
background: {
opacity: 0.8,
}
}
}
},
grid: {
clickable: true
},
legend: {
labelBoxBorderColor: "none"
}
});
$("#placeholder").bind("plotclick", pieHover);
$("#toPdf").on("click", function(e) {
e.preventDefault();
html2canvas($("#pdf").get(0), {
onrendered: function(canvas) {
document.body.appendChild(canvas);
var imgData = canvas.toDataURL('image/png');
console.log('Report Image URL: '+imgData);
var doc = new jsPDF('landscape');
doc.addImage(imgData, 'PNG', 10, 10, 190, 95);
doc.save('charts.pdf');
}
});
});
});
function pieHover(event, pos, obj) {
if (!obj)
return;
var links = ['../../Charts/students/studentsCount.php', '../../Charts/students/lecturesCount.php'];
var result =[ <?php echo $studentsCount; ?> , <?php echo $lecturesCount; ?>
];
if (obj.series.label == "studentsCount")
{
$("#pieHover").html('<span style="font-weight: bold; color:
'+obj.series.color+'">'+obj.series.label+' ('+result[0]+')</span>');
window.open(links[0], '_blank');
console.log(obj);
}
else if (obj.series.label == "lecturesCount")
{
$("#pieHover").html('<span style="font-weight: bold; color:
'+obj.series.color+'">'+obj.series.label+' ('+result[1]+')</span>');
window.open(links[1], '_blank');
console.log(obj);
}
}
HTML код
body { font-family: Verdana, Arial, sans-serif; font-size: 14px; }
#placeholder { width: 500px; height: 300px;top: -680px; left:0px;}
.legend table, .legend > div { height: 122px !important; opacity: 1 !important; left: -60px;
width:
100px !important; }
.legend table { border: 1px solid #555; padding: 5px; }
.form-actions {top: -90px;}
</style>
<!-- HTML -->
<div id="flot-placeholder" style="width:450px;height:300px;margin:0 auto"></div>
</script>
</head>
<body>
<div style="width:450px;height:300px;text-align:center;margin:10px">
<div id="flot-placeholder" style="width:100%;height:100%;"></div>
</div>
<div id="container" style="min-width: 295px; height:300px; max-width: 400px; margin: 0 auto;
position: absolute;right: 80px; top: 147px; "></div>
<div id="placeholder">
</div>
<canvas class="flot-base" width="250" height="150" style="direction: ltr; position: absolute;
right: 20px; top: 0px; width: 250px; height: 150px;"></canvas>
<canvas class="flot-overlay" width="250" height="250" style="direction: ltr; position: absolute;
right: 20px; top: -20px; width: 250px; height: 150px;"></canvas>
Спасибо,
вы могли посмотреть на мой вопрос, пожалуйста, вы можете быть в состоянии помочь мне с этой проблемой http://stackoverflow.com/questions/27443398/how-do-i-display -Несколько уложенных-колонки-для-каждой-дата-диапазона-в-ан-сложенной-бар/27452930 # 27452930 –