2

I'm wondering is there a way to change the default pie-chart colors? the default random colors does not work in my scenario and we have our own set of colors like to implement in the pie-chart.

Here is my current code looks like:

<apex:pageBlockSectionItem >
   <apex:chart height="300" width="500" data="{!PieChartData}">
     <apex:pieSeries labelField="Colorpicker__c" dataField="data">
        <apex:chartLabel display="rotate" field="Colorpicker__c"/>
      </apex:pieSeries>
        <apex:legend position="right"/>
    </apex:chart>
</apex:pageBlockSectionItem> 

1 Answer 1

0

You can use colorset attribute documented here to provide custom colors

<apex:pageBlockSection title="Simple colorSet Demo">
<apex:chart data="{!pieData}" height="300" width="400" background="#F5F5F5">
    <apex:legend position="left"/>
    <apex:pieSeries labelField="name" dataField="data1"
        colorSet="#37241E,#94B3C8,#4D4E24,#BD8025,#816A4A,#F0E68C"/>
</apex:chart>

A colorSet is a string that is a comma-delimited list of HTML-style hexadecimal color definitions. For example, colorSet="#0A224E,#BF381A,#A0D8F1,#E9AF32,#E07628". Colors are used in sequence. When the end of the list is reached, the sequence starts over at the beginning

4
  • Is there a way to control colorset? Meaning that if the chart renders ABC then render red color
    – Nick
    Commented Sep 19, 2016 at 3:47
  • yes .The order in which you specify actually maps to your column in your dataset Commented Sep 19, 2016 at 3:51
  • Thanks hmmm but in my situation the order will be dynamic so not sure which comes first but can you do mapping or some sort?, sorry I should have put that in my question.
    – Nick
    Commented Sep 19, 2016 at 4:01
  • The thing is order of list is always fixed .So you can trust the rendering engine of column .To be sure sort your list by name Commented Sep 19, 2016 at 4:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .