[Jifty-commit] r3793 - in jifty/branches/virtual-models: .
lib/Jifty/Plugin/Chart lib/Jifty/Plugin/Chart/Renderer/GD
share/plugins/Jifty/Plugin/Chart/web/static/js
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sat Aug 4 18:32:26 EDT 2007
Author: sterling
Date: Sat Aug 4 18:32:26 2007
New Revision: 3793
Modified:
jifty/branches/virtual-models/ (props changed)
jifty/branches/virtual-models/Makefile.PL
jifty/branches/virtual-models/lib/Jifty/Plugin/Chart/Renderer/Chart.pm
jifty/branches/virtual-models/lib/Jifty/Plugin/Chart/Renderer/GD/Graph.pm
jifty/branches/virtual-models/lib/Jifty/Plugin/Chart/Renderer/PlotKit.pm
jifty/branches/virtual-models/lib/Jifty/Plugin/Chart/Web.pm
jifty/branches/virtual-models/share/plugins/Jifty/Plugin/Chart/web/static/js/chart_img_behaviour.js
Log:
r8352 at dynpc145: andrew | 2007-08-04 16:14:48 -0500
Merge down from trunk.
r8333 at dynpc145: andrew | 2007-08-03 16:30:37 -0500
Fix failing dependency test because Chart uses GD to fix testing.
r8334 at dynpc145: andrew | 2007-08-03 16:31:13 -0500
Updated the behaviour script used by IMG chart renderers to make it more URI aware.
r8351 at dynpc145: andrew | 2007-08-04 16:13:23 -0500
Standardizing the chart types across the three current renderers.
Modified: jifty/branches/virtual-models/Makefile.PL
==============================================================================
--- jifty/branches/virtual-models/Makefile.PL (original)
+++ jifty/branches/virtual-models/Makefile.PL Sat Aug 4 18:32:26 2007
@@ -153,6 +153,7 @@
'Chart Plugin (none of these must be installed for Charts to work)' => [
-default => 0,
recommends('Chart::Base'),
+ recommends('GD'), # for a testing hack
recommends('GD::Graph'),
recommends('Image::Info'), # for testing
],
Modified: jifty/branches/virtual-models/lib/Jifty/Plugin/Chart/Renderer/Chart.pm
==============================================================================
--- jifty/branches/virtual-models/lib/Jifty/Plugin/Chart/Renderer/Chart.pm (original)
+++ jifty/branches/virtual-models/lib/Jifty/Plugin/Chart/Renderer/Chart.pm Sat Aug 4 18:32:26 2007
@@ -36,8 +36,25 @@
my $self = shift;
my %args = @_;
- # Make sure the type is ready to be used as a class name
- $args{type} = ucfirst lc $args{type};
+ # Conversion from generic types to Chart types
+ my %types = (
+ 'bars' => 'Bars',
+ 'composite' => 'Composite', # non-standard
+ 'direction' => 'Direction', # non-standard
+ 'errorbars' => 'ErrorBars', # non-standard
+ 'horizontalbars' => 'HorizontalBars',
+ 'lines' => 'Lines',
+ 'linespoints' => 'LinesPoints',
+ 'mountain' => 'Mountain', # non-standard
+ 'pareto' => 'Pareto', # non-standard
+ 'pie' => 'Pie',
+ 'points' => 'Points',
+ 'split' => 'Split', # non-standard
+ 'stackedbars' => 'StackedBars',
+ );
+
+ # Make sure the type is ready to be used as a Chart class name
+ $args{type} = $types{ $args{type} } || undef;
# Save the data for retrieval from the session later
my $chart_id = Jifty->web->serial;
Modified: jifty/branches/virtual-models/lib/Jifty/Plugin/Chart/Renderer/GD/Graph.pm
==============================================================================
--- jifty/branches/virtual-models/lib/Jifty/Plugin/Chart/Renderer/GD/Graph.pm (original)
+++ jifty/branches/virtual-models/lib/Jifty/Plugin/Chart/Renderer/GD/Graph.pm Sat Aug 4 18:32:26 2007
@@ -42,8 +42,20 @@
my $self = shift;
my %args = @_;
- # Convert the type to lowercase
- $args{type} = lc $args{type};
+ # GD::Graph types from generic types
+ my %types = (
+ lines => 'lines',
+ bars => 'bars',
+ horizontalbars => 'hbars',
+ points => 'points',
+ linespoints => 'linespoints', # non-standart
+ area => 'area',
+ pie => 'pie',
+ mixed => 'mixed', # non-standard
+ );
+
+ # Convert the generic type to a GD::Graph type
+ $args{type} = $types{ $args{type} } || undef;
# Save the data for retrieval from the session later
my $chart_id = Jifty->web->serial;
Modified: jifty/branches/virtual-models/lib/Jifty/Plugin/Chart/Renderer/PlotKit.pm
==============================================================================
--- jifty/branches/virtual-models/lib/Jifty/Plugin/Chart/Renderer/PlotKit.pm (original)
+++ jifty/branches/virtual-models/lib/Jifty/Plugin/Chart/Renderer/PlotKit.pm Sat Aug 4 18:32:26 2007
@@ -49,13 +49,16 @@
}
my %types = (
- Lines => 'line',
- Bars => 'bar',
- Pie => 'pie',
+ lines => { type => 'line' },
+ bars => { type => 'bar', orientation => 'vertical' },
+ pie => { type => 'pie' },
+ horizontalbars => { type => 'bar', orientation => 'horizontal' },
);
# Make sure the type is ready to be used
- $args{type} = $types{ ucfirst lc $args{type} } || undef;
+ my $options = $types{ $args{type} } || {};
+ $args{type} = delete $options{type};
+ $args{options}{$_} = $options{$_} foreach keys %$options;
if ( not defined $args{type} ) {
Jifty->log->warn("Unsupported chart type: $args{type}!");
Modified: jifty/branches/virtual-models/lib/Jifty/Plugin/Chart/Web.pm
==============================================================================
--- jifty/branches/virtual-models/lib/Jifty/Plugin/Chart/Web.pm (original)
+++ jifty/branches/virtual-models/lib/Jifty/Plugin/Chart/Web.pm Sat Aug 4 18:32:26 2007
@@ -25,34 +25,38 @@
=item type
-This will be one of the following scalar values indicating the kind of chart:
+This will be one of the following scalar values indicating the kind of chart. A given renderer may not support every type listed here. A renderer might support others in addition to these, but if it supports these it should use these names.
=over
-=item Points
+=item points
This is the default value. A scatter plot with each dataset represented using differnet dot styles.
-=item Lines
+=item lines
A line plot with each dataset presented as separate line.
-=item Bars
+=item bars
A bar chart with each dataset set side-by-side.
-=item StackedBars
+=item stackedbars
A bar chart with each dataset stacked on top of each other.
-=item Pie
+=item pie
A pie chart with a single dataset representing the values for different pieces of the pie.
-=item HorizontalBars
+=item horizontalbars
A bar chart turned sideways.
+=item area
+
+An area chart uses lines to represent each dataset, but the lines are stacked on top of each other with filled areas underneath.
+
=back
=item width
@@ -81,6 +85,10 @@
This allows you to use a different renderer than the one configured in F<config.yml>. Give the renderer as a class name, which will be initialized for you.
+=item options
+
+This is a hash containing additional options to pass to the renderer and are renderer specific. This may include anything that is not otherwise set by one of the other options above.
+
=back
Here's an example:
@@ -125,6 +133,9 @@
$args{width} .= 'px' if looks_like_number($args{width});
$args{height} .= 'px' if looks_like_number($args{height});
+ # canonicalize the type argument (always lowercase)
+ $args{type} = lc $args{type};
+
# canonicalize the class argument
if (not ref $args{class}) {
$args{class} = defined $args{class} ? [ $args{class} ] : [];
Modified: jifty/branches/virtual-models/share/plugins/Jifty/Plugin/Chart/web/static/js/chart_img_behaviour.js
==============================================================================
--- jifty/branches/virtual-models/share/plugins/Jifty/Plugin/Chart/web/static/js/chart_img_behaviour.js (original)
+++ jifty/branches/virtual-models/share/plugins/Jifty/Plugin/Chart/web/static/js/chart_img_behaviour.js Sat Aug 4 18:32:26 2007
@@ -8,9 +8,26 @@
'img.chart': function(e) {
var dim = Element.getDimensions(e);
var url = e.src;
- url += url.indexOf('?') >= 0 ? '&' : '?';
- url += 'width=' + dim.width + 'px';
- url += '&height=' + dim.height + 'px';
+
+ var path = url;
+ var query = $H();
+
+ if (url.indexOf('?') >= 0) {
+ var path_and_query = url.split('?');
+ path = path_and_query[0];
+
+ var query_params = path_and_query[1].split('&');
+ for (var query_param in query_params) {
+ var key_and_value = query_param.split('=');
+ query[ key_and_value[0] ] = key_and_value[1];
+ }
+ }
+
+ query['width'] = dim.width + 'px';
+ query['height'] = dim.height + 'px';
+
+ url = path + '?' + query.toQueryString();
+
e.src = url;
},
});
More information about the Jifty-commit
mailing list