Ren*_*tto 1 primefaces chart.js
我正在使用Primefaces上的新ChartJS库创建图表,但是找不到在条形图或折线图上添加值作为标签的方法。
在互联网上看,我发现了一个名为chartjs-plugin-datalabels的JS插件!那就是我需要的。
如何在Java Primefaces应用程序上使用此插件?
尝试这个...
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@0.5.0"></script>
Run Code Online (Sandbox Code Playgroud)
chartModel.setExtender("chartExtender");
Run Code Online (Sandbox Code Playgroud)
function chartExtender() {
var options = {
plugins: [ChartDataLabels],
options: {
plugins: {
// Change options for ALL labels of THIS CHART
datalabels: {
color: '#36A2EB'
}
}
},
data: {
datasets: [{
// Change options only for labels of THIS DATASET
datalabels: {
color: '#FFCE56'
}
}]
}
};
//merge all options into the main chart options
$.extend(true, this.cfg.config, options);
};
Run Code Online (Sandbox Code Playgroud)
这全都基于他们的配置指南https://chartjs-plugin-datalabels.netlify.com/guide/getting-started.html#configuration 但这至少应该使插件开始运行。
| 归档时间: |
|
| 查看次数: |
527 次 |
| 最近记录: |