Author: spadkins
Date: Thu Nov 9 09:41:47 2006
New Revision: 8031
Modified:
p5ee/trunk/App-Widget/lib/App/Widget/Graph.pm
Log:
allow graphs with {objects} supplied rather than an {object_set}
Modified: p5ee/trunk/App-Widget/lib/App/Widget/Graph.pm
==============================================================================
--- p5ee/trunk/App-Widget/lib/App/Widget/Graph.pm (original)
+++ p5ee/trunk/App-Widget/lib/App/Widget/Graph.pm Thu Nov 9 09:41:47 2006
@@ -144,21 +144,32 @@
&App::sub_entry if ($App::trace);
my ($self, $spec) = @_;
+ my $context = $self->{context};
+
# the following four fields need to be set to bind
my $columns = $spec->{columns};
$columns = [ split(/,/, $columns) ] if (!ref($columns));
die "no columns in graph" if ($#$columns == -1);
- my $context = $self->{context};
- my $object_set = $self->get_object_set($spec);
- if (!$object_set) {
- die "No known way to get data";
+
+ my ($objects, $keys, $column_defs, $object_set);
+ if ($self->{objects}) {
+ $keys = $self->{keys};
+ $objects = $self->{objects};
+ $column_defs = $self->{column_defs};
}
+ else {
+ $object_set = $self->get_object_set($spec);
+ if (!$object_set) {
+ die "No known way to get data";
+ }
- # make sure that the columns we need for the graph are in the
- # list of columns in the dataset
- $object_set->include_columns($columns);
+ # make sure that the columns we need for the graph are in the
+ # list of columns in the dataset
+ $object_set->include_columns($columns);
- my $keys = $object_set->get_key_columns(); # get the columns that are keys
+ $keys = $object_set->get_key_columns(); # get the columns that are keys
+ $column_defs = $object_set->get_column_defs();
+ }
my $column_dims = (($#$columns > 0) ? 1 : 0);
my $data_dims = ($#$keys + 1) + $column_dims;
@@ -166,27 +177,32 @@
if ($graph_dims > $data_dims) {
$graph_dims = $data_dims;
}
- my ($objects);
- if ($graph_dims < $data_dims) {
- $graph_dims = $data_dims;
- my $max_key_idx = $data_dims - $graph_dims;
- my (@index_keys);
- my $index = $object_set->get_index(\@index_keys);
- my $key = $spec->{key};
- if (!$key) {
- my @keys = (sort keys %$index);
- $key = $keys[0];
+
+ if ($self->{objects}) {
+ if ($graph_dims < $data_dims) {
+ $graph_dims = $data_dims;
}
- $objects = $index->{$key};
}
else {
- $graph_dims = $data_dims;
- $objects = $object_set->get_objects();
+ if ($graph_dims < $data_dims) {
+ $graph_dims = $data_dims;
+ my (@index_keys);
+ my $index = $object_set->get_index(\@index_keys);
+ my $key = $spec->{key};
+ if (!$key) {
+ my @keys = (sort keys %$index);
+ $key = $keys[0];
+ }
+ $objects = $index->{$key};
+ }
+ else {
+ $graph_dims = $data_dims;
+ $objects = $object_set->get_objects();
+ }
}
my (@x, @yn, $object, $column);
my ($label);
- my $column_defs = $object_set->get_column_defs();
if ($#$columns > 0 || $graph_dims < 2) {
for (my $i = 0; $i <= $#$objects; $i++) {
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.