37
| <![CDATA[<script>var tempData = {
labels: [
"Requerimentos",
"Moções",
"Projetos",
],
datasets: [{
label: "Status",
data: [
75, 12, 3, ],
backgroundColor: ["#3e95cd", "#8e5ea2", "#3cba9f", "#e8c3b9", "#c45850"]
}]
};
var options = {
title: {
display: true,
fontsize: 14,
text: 'Gráfico dos Processos Legislativos do Vereador'
},
legend: {
display: true,
position: 'top',
labels: {
generateLabels: function(chart) {
var data = chart.data;
if (data.labels.length && data.datasets.length) {
return data.labels.map(function(label, i) {
var meta = chart.getDatasetMeta(0);
var ds = data.datasets[0];
var arc = meta.data[i];
var custom = arc && arc.custom || {};
var getValueAtIndexOrDefault = Chart.helpers.getValueAtIndexOrDefault;
var arcOpts = chart.options.elements.arc;
var fill = custom.backgroundColor ? custom.backgroundColor : getValueAtIndexOrDefault(ds.backgroundColor, i, arcOpts.backgroundColor);
var stroke = custom.borderColor ? custom.borderColor : getValueAtIndexOrDefault(ds.borderColor, i, arcOpts.borderColor);
var bw = custom.borderWidth ? custom.borderWidth : getValueAtIndexOrDefault(ds.borderWidth, i, arcOpts.borderWidth);
var value = chart.config.data.datasets[arc._datasetIndex].data[arc._index];
return {
text: label + " : " + value,
fillStyle: fill,
strokeStyle: stroke,
lineWidth: bw,
hidden: isNaN(ds.data[i]) || meta.data[i].hidden,
index: i
};
});
} else {
return [];
}
}
}
},
bezierCurve: false,
animation: {
duration: 0
}
}
// Trecho que gera a imagem canvas
var ctx = document.getElementById("pie-chart");
var chartInstance = new Chart(ctx, {
type: 'pie',
data: tempData,
options: options
});
// Trecho que gera a copia do canvas em img
function done() {
var url = chartInstance.toBase64Image();
document.getElementById("url").src = url;
var anchor = document.getElementById("pie-chart");
var att = document.createAttribute("data");
att.value = url;
anchor.setAttributeNode(att);
}
var myLine = new Chart(document.getElementById("pie-chart").getContext("2d"), {
data: tempData,
type: "pie",
options: options
});</script>]]>
|