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

[email protected]
Newsgroups perl.cvs.p5ee
Message-ID <[email protected]>
Author: spadkins
Date: Thu Aug 30 11:43:50 2007
New Revision: 9899

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

Log:
Added ability to have two addMarks

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	Thu Aug 30 11:43:50 2007
@@ -384,15 +384,35 @@
     $c->yAxis()->setLabelStyle("arial.ttf", 10, hex($y_labelcolor));
     $c->xAxis()->setLabelStyle("arial.ttf", 10, hex($x_labelcolor));
 
-    if ($spec->{add_mark} ne "") {
-        my $value = $spec->{add_mark};
-        my $color = $spec->{add_mark_color};
-        $color =~ s/^#//;
-        $color = "000000" if (!$color || $color eq "none");
-        
-        if ($value =~ /(?:^-)?\d+(?:\.)?(?:\d+)?$/ && length($color) == 6) {
-            $color = hex($color); 
-            $c->yAxis()->addMark($value, $c->dashLineColor($color, $perlchartdir::DashLine));
+    if ($spec->{add_mark} ne "" || $spec->{add_mark2} ne "") {
+        my $value  = $spec->{add_mark};
+        my $value2 = $spec->{add_mark2};
+        my $color  = $spec->{add_mark_color};
+        my $color2 = $spec->{add_mark_color2};
+
+        $color  =~ s/^#//;
+        $color  = "000000" if (!$color  || $color  eq "none");
+        $color2 =~ s/^#//;
+        $color2 = "000000" if (!$color2 || $color2 eq "none");
+
+        my ($add_mark_vals);
+        foreach my $data ([$value, $color], [$value2, $color2]) {
+           my $hash = {};
+           if (defined $data->[0]) {
+               $hash->{value} = $data->[0];
+               $hash->{color} = $data->[1];
+               push (@$add_mark_vals, $hash);
+           }
+        }
+
+        foreach my $add_mark_val (@$add_mark_vals) {
+            my $amk_value = $add_mark_val->{value};
+            my $amk_color = $add_mark_val->{color};
+
+            if ($amk_value =~ /(?:^-)?\d+(?:\.)?(?:\d+)?$/ && length($amk_color) == 6) {
+                my $hex_color = hex($amk_color); 
+                $c->yAxis()->addMark($amk_value, $c->dashLineColor($hex_color, $perlchartdir::DashLine));
+            }
         }
     }
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.