I have 2 charts in the same page. I'd like to show legends just in one chart, not both, but I have just a global solution. Thats my javascript code:
$.jqplot.preDrawHooks.push(function () {
this.legend.show = true;});
and my xhtml:
<p:chart id="chart17" responsive="true" type="bar" model="#{chart17Bean.barModel}" />
<p:chart id="chart18" responsive="true" type="bar" model="#{chart18Bean.barModel}" />
Edited: I'm using Primefaces 6.1
Add this JS function on page
function removeLegend()
{
this.cfg.legend = {
show: false
};
}
and then in your managed bean add
barModel.setExtender("removeLegend");
where barModel is model of chart you want to have legend hidden.
Primefaces 8, Chart Js, you could set legend display to false
Legend legend = new Legend();
legend.setDisplay(false);
options.setLegend(legend);
Solved my issue
yourChart.options = {
legend: {
display: false,
}
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.