Change the label color of a chart in PrimeFaces

3

I have a graph and the labels that are on the x axis are very dark color and I would like to change this color, I already tried to change the color property of the graph, but only the title changes.

<p:chart  type="bar" model="#{graficoBarraBean.barModel}" style="height:300px;color:green" />

The graph looks like this:

Noticethatyoucanbarelyseethenamesbeneaththechart.

UPDATE:SeeItrytochangethecolorforthebrowser'sdevelopermodeanditstilldoesnotwork.

    
asked by anonymous 20.07.2015 / 18:46

2 answers

7

Changing the color of the labels

We need to access the jqplot options via javaScript, add it to your page or javaScript on your screen:

Note: Atera the X axis and Y axis

function alterarTextoLabel() { 
  this.cfg.axes.yaxis.tickOptions = { 
   textColor : 'sua cor desejada' 
 }; 
this.cfg.axes.xaxis.tickOptions = { 
   textColor : 'sua cor desejada' 
 }; 
} 

1 # option in the bean of your Chart add:

barModel.setExtender("alterarTextoLabel");

2 # option You can also add extender as an attribute of P: chart

 <p:chart extender="alterarTextoLabel">

Note 2: The extender attribute was changed in version 5.0 of primefaces , so the second option is only available in the lower ones.

Bonus: Changing the background color on the chart

.jqplot-base-canvas { 
background:"cor desejada"; 
} 
    
24.07.2015 / 19:38
0

You'll have to override the css, try this:

.jqplot-series-canvas {
  background:green;
}

Editing:

Then try the following:

.jqplot-title{
    color: #FF0000;
}
.jqplot-xaxis-label{
    color: #FF0000; 
}
.jqplot-yaxis-label{
    color: #FF0000;
}
    
20.07.2015 / 19:41