[svn:p5ee] r8090 - p5ee/trunk/App-Widget-ChartDirector/lib/App/Widget

[email protected]
Newsgroups perl.cvs.p5ee
Message-ID <[email protected]>
Author: spadkins
Date: Mon Nov 20 08:25:57 2006
New Revision: 8090

Modified:
   p5ee/trunk/App-Widget-ChartDirector/lib/App/Widget/ChartDirector.pm

Log:
set the colors explicitly

Modified: p5ee/trunk/App-Widget-ChartDirector/lib/App/Widget/ChartDirector.pm
==============================================================================
--- p5ee/trunk/App-Widget-ChartDirector/lib/App/Widget/ChartDirector.pm	(original)
+++ p5ee/trunk/App-Widget-ChartDirector/lib/App/Widget/ChartDirector.pm	Mon Nov 20 08:25:57 2006
@@ -499,6 +499,12 @@
     # $c->xAxis()->setLinearScale(0, $noOfPoints - 1, $labels);
     # $c->xAxis()->setLinearScale(0, 2, $x);
 
+#############  
+    my @color_set = ("0xFF0000", "0xFF00",     "0xFFFD00", "0xFF00FF", "0x6E641E", "0xA5BF8",  "0xFFC0CB",
+                     "0x44A816", "0x8B0000",   "0x6495ED", "0xFF8C00", "0xA4E8B",  "0xDEB887", "0x9932CC",
+                     "0xAFC8",   "0x55FF0000", "0x30D40",  "0x708090", "0xBDB76B", "0xADD8E6");
+#############
+
     my $x = $self->get_x($spec);
     my $yn = $self->get_y($spec);
     my ($layer, $dataset);
@@ -531,7 +537,18 @@
                 }
                 $y = $stacked_y;
             }
-            $dataset = $layer->addDataSet($y, -1, $y_labels->[$i]);
+            #$dataset = $layer->addDataSet($y, -1, $y_labels->[$i]);
+################           
+            #we choose colors from @color_set
+            if($i <= 19) {   
+                $dataset = $layer->addDataSet($y, hex($color_set[$i]), $y_labels->[$i]);
+            }
+            else {
+                #if number of y_labels is greater than 20, colors will be repeated
+                #we have declared only 20 colors
+                $dataset = $layer->addDataSet($y, hex($color_set[($i-20)]), $y_labels->[$i]);
+            }
+###############            
             $dataset->setDataSymbol($self->sym($i, \@symbols)) if ($spec->{points});
         }
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.