title: sort chart bar by color with the correct value from the text file using HIGHCHART,PHP
body: <p>Suppose that I have the PHP function code as below:</p>
  
  <p><strong>function.php</strong></p>
  
  <pre><code> function PMTA_CHART($contentID, $chartName, $file, $order) {
      $cate = '';
      $total = '';
      $fail = '';
      $chart = array();
      $title = "";
      $PercentBlue = 0;
      $PercentRed = 0;
      if (file_exists($file)) {
          $files = fopen($file, 'r');
          while (!feof($files)) {
              $data = explode(";", fgets($files));
              if ($title == "") {
                  $title = $data[0];
              }
              if (!empty($data[5])) {
                  $cate = $data[5];
                  $PercentBlue = ((int)$data[6] - (int)$data[7]);
                  $PercentRed = (int)$data[7];
                  if (!empty($order)) {
                      $PercentBlue = (100 - (int)$data[8]);
                      $PercentRed = (int)$data[8];
                      $chart[] = array($PercentBlue, $PercentRed, $cate);
                  } else {
                      $PercentBlue = (100 - (int)$data[8]);
                      $PercentRed = (int)$data[8];
                      $chart[] = array($PercentRed, $PercentBlue, $cate);
                  }
              }
          }
          arsort($chart);
          $cate = '';
          $PercentBlue = 0;
          $PercentRed = 0;
          if (!empty($order)) {
              foreach ($chart as $arr) {
                  $cate.= ',' . "'$arr[2]'";
                  $PercentBlue.= ',' . $arr[0];
                  $PercentRed.= ',' . $arr[1];
              }
          } else {
              foreach ($chart as $arr) {
                  $cate.= ',' . "'$arr[2]'";
                  $PercentBlue.= ', ' . $arr[1];
                  $PercentRed.= ', ' . $arr[0];
              }
          }
          fclose($files);
      } else {
          echo "No such file";
      }
  ?&gt;       
  
      &lt;?php echo $chartName ?&gt; = new Highcharts.Chart({
      chart: {
          renderTo: '&lt;?php echo $contentID ?&gt;',
          type: 'column'
      },
      title: {
          text: '&lt;?php echo $title; ?&gt;'
      },
      xAxis: {
          categories: [&lt;?php echo substr($cate, 1); ?&gt;],
          labels: {
              rotation: 90,
              align: 'left'
          }
      },
      yAxis: {
          min: 0,
          title: {
              text: '% envoi'
          }
      },
      tooltip: {
          formatter: function() {
              return ''+
                  this.series.name +': '+ this.y +' ('+ Math.round(this.percentage) +'%)';
          }
      },
  
      plotOptions: {
          column: {
              stacking: 'percent'
          }
      },
          series: [{
          name: 'Total mail succesful',
          data: [&lt;?php echo substr($PercentBlue, 2); ?&gt;]
      }, {
          name: 'Total mail fail',
          data: [&lt;?php echo substr($PercentRed, 2); ?&gt;]
      }]
  });
  </code></pre>
  
     
  
  <p><strong>pmtaChart.php</strong></p>
  
  <pre><code>&lt;?php
  include('include/function.php');
  $pmta3_emetteur_file = '../stats_domain_emetteur.affinitead.net.'.date("Y-m-d").'.txt';
  $pmta4_emetteur_file = '../stats_domain_emetteur.switchcall.com.'.date("Y-m-d").'.txt';
  $pmta5_emetteur_file = '../stats_domain_emetteur.unitead.eu.'.date("Y-m-d").'.txt';
  $order = isset($_POST['txt_order_blue'])?$_POST['txt_order_blue']:'';
  
  ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Chart&lt;/title&gt;
  &lt;script type="text/javascript" src="js/jquery.min.js"&gt;&lt;/script&gt; 
  &lt;script type="text/javascript"&gt;
  $(function () {
  var chart3, chart4, chart5;
  $(document).ready(function() {
      &lt;?php PMTA_CHART('PMTA3', 'chart3', $pmta3_emetteur_file, $order); ?&gt;
      &lt;?php PMTA_CHART('PMTA4', 'chart4', $pmta4_emetteur_file, $order); ?&gt;
      &lt;?php PMTA_CHART('PMTA5', 'chart5', $pmta5_emetteur_file, $order); ?&gt;
  });
  
  });
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;script src="js/highcharts.js"&gt;&lt;/script&gt;
  &lt;script src="js/exporting.js"&gt;&lt;/script&gt;
  &lt;form action="pmtaEmetteur.php" method="post"&gt;
  &lt;input type="submit" name="txt_order_red" id="txt_order_red" title="Order Red" value="Order Red"/&gt;
  &lt;input type="submit" name="txt_order_blue" id="txt_order_blue" title="Order blue" value="Order blue"/&gt;
  &lt;/form&gt;
  &lt;div id="PMTA3" style="min-width: 400px; height: 400px; margin: 0 auto"&gt;&lt;/div&gt;
  &lt;div id="PMTA4" style="min-width: 400px; height: 400px; margin: 0 auto"&gt;&lt;/div&gt;
  &lt;div id="PMTA5" style="min-width: 400px; height: 400px; margin: 0 auto"&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>As you see in code I have 2 buttons, order red and order blue,when I click on button order red it will sort red,and click on button blue it will sort blue<a href="http://www.unitead.pro/kama/stats/pmta/Chart_v2/pmtaEmetteur.php" rel="nofollow">Please see this</a> but when I mouse over on the bar chart I need to display <code>Total mail successful : 700 (70 %)</code> and <code>Total mail fail 300(30%)</code> but in this chart it not the same what I need it displays <code>Total mail successful : 70(70%)</code> and <code>Total mail fail : 30(30%)</code>.</p>
  
  <p><strong>Note:</strong></p>
  
  <p>All data I read from the file as you see in my code.This is example text in file:</p>
  
  <pre><code>2012-12-19-0230;affinitead.net;557469;141107;25.31;boulevard-des-ventes.com;370873;116793;31.49
  2012-12-19-0230;affinitead.net;557469;141107;25.31;tendancity.com;53296;13121;24.61
  2012-12-19-0230;affinitead.net;557469;141107;25.31;friendcorp.fr;34365;4086;11.89
  2012-12-19-0230;affinitead.net;557469;141107;25.31;messengear.fr;32068;1227;3.82
  2012-12-19-0230;affinitead.net;557469;141107;25.31;affinimail.com;27415;2231;8.13
  2012-12-19-0230;affinitead.net;557469;141107;25.31;diffitalia.com;2;0;0
  .................................................................................
  .................................................................................
  .................................................................................
  </code></pre>
  
  <p>I can not find the solution, anyone know pleas help me, Thanks.</p>