简体   繁体   中英

How to change color in primefaces bar chart for every column of the same series?

I have a problem with changing the color of the columns in my bar chart. I know how to change them if I have more series

<p:barChart id="outboxOfferChart" value="#{offerStatisticsBean.outboxOfferStatistics}" 
xaxisAngle="-70" datatipFormat="#{offerStatisticsBean.datatipFormat}" min="0" 
max="#{offerStatisticsBean.maxYAxis}" **seriesColors="FB5E09, CA04F1, 5EDD03, 04F655, 13FBC1, FC5560, FBFB18, B7FB09, 04C1FB, 034ED8, E704C1, FB0467, FC211D"** 
style="height:370px; width:380px;"/>

, but what if I have only 1 series, and want to change the color of every column to the same series? Help is much appreciated!

Complete your primefaces chart with an extender attribute:

<h:outputScript>
function ext() {
  this.cfg.seriesDefaults.rendererOptions.varyBarColor = true;
}                               
</h:outputScript>       

<p:barChart ... extender="ext"/>

By default, a bar chart from a single series will have all the bar colors the same. But you can use different colors for each bar with varyBarColor property:

http://www.jqplot.com/deploy/dist/examples/multipleBarColors.html

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM