PieChartModel primefaces 13.0.0 #73
-
Hello, With primefaces version 13.0.0, I have a ChartPieModel and I want to be able to show a different content to the value in the tooltip of each option. I know that in previous versions of primefaces it was possible to add to the Data a text and a value. Now it is only possible to add a numeric value. I don't think they have gone backwards in this aspect but I have already tried several things and I can't find a way to do what I am saying. Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Don't you just want to customize the Tooltip of the Chart using the Charts.JS tooltip? https://www.chartjs.org/docs/latest/configuration/tooltip.html PrimeFaces is just sitting on top of ChartsJS. |
Beta Was this translation helpful? Give feedback.
-
I finally solved it by redefining the client-side tooltip: <p:barChart model="#{infInformeClientes.stackedBarLlamadasTiempoConversadoModel}" style="width: 100%; height: 500px;" widgetVar="stackedBarLlamadasTiempoConversadoModelWgt"/> |
Beta Was this translation helpful? Give feedback.
I finally solved it by redefining the client-side tooltip:
<p:barChart model="#{infInformeClientes.stackedBarLlamadasTiempoConversadoModel}" style="width: 100%; height: 500px;" widgetVar="stackedBarLlamadasTiempoConversadoModelWgt"/>
<script>
PrimeFaces.widgets.stackedBarLlamadasTiempoConversadoModelWgt.cfg.config.options.plugins.tooltip = {
callbacks: {
label: function(context) {
let label = context.label || '';
if (label) {
label += ': ';
}
if (context.raw !== null) {
const horasMinutos = segundosAHorasYMinutos(context.raw);
label += (horasMinutos.horas + ":" + horasMinutos.minutos);
}
return label;
}
}
};
PrimeFaces.widgets.stackedBarLlamadasTiempoConversadoModelWgt.refresh(PrimeFaces.…