title: highcharts: dynamically define colors in pie chart
body: <p>I'm trying to dynamically define color for each seria depending of their type.
  Below is my code which doesn't work but showing what I'm trying to do. I would like to define colour for certain type eg: </p>
  
  <pre><code>if type = 'IS' then color =  '#FFCACA'
  </code></pre>
  
  <p>I cannot expect that ret will have all types so I need to know which types are returned in ret and then asociate color to certain type.</p>
  
  <p>How to do that?</p>
  
  <p>this is code since data received:</p>
  
  <pre><code>success: function (ret) {
  
  
      $(function () {
          var chart;
          $(document).ready(function () {
              chart = new Highcharts.Chart({
                  chart: {
                      renderTo: 'divPie_' + id,
                      plotBackgroundColor: null,
                      plotBorderWidth: null,
                      plotShadow: true,
                      width: 350,
                      height: 350
                  },
                  title: {
                      text: refrigname
                  },
                  tooltip: {
                      pointFormat: '{series.name}: &lt;b&gt;{point.percentage}%&lt;/b&gt;',
                      percentageDecimals: 1
                  },
                  plotOptions: {
                      pie: {
                          allowPointSelect: true,
                          cursor: 'pointer',
                          dataLabels: {
                              enabled: false
                          },
                          showInLegend: true
                      }
                  },
                  series: [{
                      type: 'pie',
                      name: 'Current selection',
                      color: (function () {
                              switch (ret.type) {
                                  case 'AB': return '#C6F9D2'; 
                                  case 'BC': return '#CCCCB3'; 
                                  case 'CL': return '#CECEFF'; 
                                  case 'CI': return '#FFCAFF'; 
                                  case 'HB': return '#D0CCCD'; 
                                  case 'ON': return '#FFCC99'; 
                                  case 'PM': return '#FFCBB9'; 
                                  case 'SR': return '#EAEC93'; 
                                  case 'TS': return '#D7FBE6'; 
                                  case 'IS': return '#FFCACA'; 
                                  case 'FREE': return '#00FF00'; 
                              }
                      }),
                      data: (function () {
                          var arr = [];
                          $(ret).each(function () {
                              var labelname = "";
                              switch (this.type) {
                                  case "AB": labelname = "Antibodies"; break;
                                  case "BC": labelname = "Bacteria"; break;
                                  case "CL": labelname = "Cell lines"; break;
                                  case "CI": labelname = "Custom items"; break;
                                  case "HB": labelname = "Hybridoma"; break;
                                  case "ON": labelname = "Oligonucleotides"; break;
                                  case "PM": labelname = "Plasmids"; break;
                                  case "SR": labelname = "siRNA"; break;
                                  case "TS": labelname = "Tissue samples"; break;
                                  case "IS": labelname = "Isolates"; break;
                                  case "FREE": labelname = "Free space"; break;
                              }
                              arr.push([labelname, this.cnt]);
                          })
                          return arr;
                      })()
                  }]
              });
          });
      });
  
  
  }
  </code></pre>