Change the Label color of a chart in Primefaces

Asked

Viewed 1,109 times

3

I have a chart and the labels which are on the x-axis are with a very dark color and I would like to change this color, I have 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: inserir a descrição da imagem aqui

Notice that can barely see the names under the chart.


UPDATE: Note that I try to change the color by browser developer mode and it still doesn’t work.

inserir a descrição da imagem aqui

  • you can paste the generated HTML into a fiddle?

2 answers

7


Changing the color of the colors

We need to access the options of jqplot via Avascript, add to your page or screen Avascript:

Note: Ground the X axis and the 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 the extender as an attribute of P:Chart

 <p:chart extender="alterarTextoLabel">

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

Bonus: Changing the background color in Chart

.jqplot-base-canvas { 
background:"cor desejada"; 
} 
  • Thank you very much for your help.

  • We’re here for this, @Techies, for whom downvote could explain why?

  • I guess it was because you hadn’t completed the answer yet.

  • I think that’s right :(

0

You’ll have to overwrite 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;
}
  • Hasn’t worked yet. :/

  • Only the title color changed to red, the labels remain the same color

  • @Techies take a look at this part here from documentation on where and apply css to change colors and other things. I believe the latter can serve you.

  • Already looked, I try to use and the color doesn’t change anyway rsrs

  • tried to put ! Important ?

  • not yet, I’ll try

  • Also did not give ..

  • I put it in the template’s CSS, and only the title changes color rs

  • I just tried to do that, edited the question with an image, a look.

  • I already tried to clean the cash, I took the css chunk that was in the system.css file and tried to change the color by the browser. Only the color of the title changes, the rest does not.

Show 5 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.