[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [GT] Patch for Histogram coloring bug



Gregory Margo wrote:
Revision 553 removed the set_foreground_color() method
from GT/Graphics/Object/Histogram.pm.

I believe this was an error because the parent class'
method will not set the 'color_ds' variable.

I'm passing this parameter to Scripts/graphic.pl:
--option=Graphic::Volume::Color=Indicators::Generic::If {Signals:Generic:Below {I:Prices OPEN} {I:Prices CLOSE}} green red
which will not work otherwise.


Index: GT/Graphics/Object/Histogram.pm
===================================================================
--- GT/Graphics/Object/Histogram.pm     (revision 642)
+++ GT/Graphics/Object/Histogram.pm     (working copy)
@@ -201,4 +201,15 @@
      }
  }

+sub set_foreground_color {
+    my ($self, $color) = @_;
+    if ( $self->{'calc'} ne "" && $color =~ /^\s*(Indicators|I:)/) {
+      $self->{'fg_color'} = $color;
+ $self->{'color_ds'} = GT::Graphics::DataSource::GenericIndicatorResults->new($self->{'calc'}, $color );
+    }
+    else {
+      $self->{'fg_color'} = get_color($color);
+    }
+}
+
  1;




gt users and ooperlers

wouldn't the general capability to set the foreground color
based on an arbitrarily complex indicator be of great benefit
to more than just the histogram graphic object?

i can image changing the fgc of a curve depending on it's value
relative to one or more threshold levels would be very useful.

to implement this capability graphic object wide, changes to the
parent class new method to support the 'color_ds' attribute
and additional methods dealing it (set_color_datasource, etc)
would be required but the basis is all set and working in the
histogram object. the risk to implement this capability as
a class wide feature should be rather low.

just something to put on the list of to-do ...

ras