Project

General

Profile

Graphs plugin

Added by Brad Beattie almost 16 years ago

Hey folks, I'm working on a graphs plugin for Redmine that augments the exiting SVG use (like in repository statistics). Attached is the first instance I've implemented: a graph of issues over time for a given target version.

Is there anything else anyone wants? These things seem relatively easy to implement.


Replies (104)

RE: Graphs plugin - Added by John Morgan over 15 years ago

Tommy L. wrote:

Brad Beattie wrote:

Tommy L. wrote:

Yes, i also have the 'label' labels as seen for example here: http://redmine.chiparus.net/projects/rezplatform/issues (This is the latest 0.8-stable redmine and the Graphs plugin just pulled from git)

Also i might add that my roadmap graphs are working fine, but the other links give me the errors. (me also ruby/rails noob btw no clue yet)

The graphs plugin is not compatible with the stable branch, only the most recent trunk heading towards 0.9. If you want to make the necessary language changes, send me a pull request on github and I'll include them. Cool?

Ok, didn't know it wasn't backwards compatible. Thanks for your answer!

Works like a champ. Thanks for the tip Brad.

RE: Graphs plugin - Added by Uwe Koloska over 15 years ago

Brad Beattie wrote:

The graphs plugin is not compatible with the stable branch, only the most recent trunk heading towards 0.9. If you want to make the necessary language changes, send me a pull request on github and I'll include them. Cool?

This is too bad (and from my POV, has to be expressed on the plugin-page) - it's such a cool plugin. So I tried to make it run on 0.8-stable, but since I am just a rails noob, I was choked off at some point.

The i18n issue is very easy: just copy the language files to lang/ an delete the first line. But the features not present in 0.8 are more difficult to solve. Here is what I have found so far:
  • .descendants.active. is .active_children. in 0.8
  • .visible seems not to exist and I haven't found a substitute
  • the condition ["#{Project.table_name}.id IN (?)", ids] doesn't work inside a find (column projects.id not found) and I don't know the reason. Other condition like this one ["#{IssueStatus.table_name}.is_closed=?", false] work.
  • maybe the Gloc-plugin doesn't know about a :value parameter? This is used in app/views/graphs/old_issues.html.erb and since the word value is printed, this doesn't seem the correct behavior. It looks like Issues by valueUpdated

With the described changes the graphs from the issues page doesn't give errors but look the same for all projects (this may come from the missing condition).

So, if someone can help me to solve the two issues
  • find an equivalent for .visible.
  • make the condition work
    I can provide a git repository with a patched version of the graphs plugin working with 0.8-stable.
lang.tar.gz (757 Bytes) lang.tar.gz converted language files for 0.8
changes-0.8.diff (2.34 KB) changes-0.8.diff the 'git diff' with the changes to make it at least work on 0.8

RE: Graphs plugin - Added by Uwe Koloska over 15 years ago

One issue solved: The conditions don't work because they use a foreign table that is included by the visible named_scope, so the easy fix is to introduce the project table explicitly to the find procedure. But now I am not sure how to phrase visible (or: get only projects and issues that are visible to the current user) - is there no built in function to get this information?

Nevertheless, here comes the modified git diff. Now the two graphs look different for every project!

changes-0.8-b.diff (2.47 KB) changes-0.8-b.diff new diff with working conditions

RE: Graphs plugin - Added by Tommy L. over 15 years ago

Nice Uwe! Will definately give it a try.

RE: Graphs plugin - Added by Louis Caron over 15 years ago

Description of a possible enhancement.

In the open aging issues view, two columns are shown (Issues by Created / Issues by Updated) with 10 issues in each column. Logically, the issues are ordered starting with the oldest but it is not possible to view the next 10 oldest ones. Would it be possible to add a button to browse the issues separately for each column (or synchronized between the columns)?

Thanks.

RE: Graphs plugin - Added by Uwe Koloska over 15 years ago

It's me again. Finally I have created a github account and forked the graphs plugin. So you can clone a graphs plugin that works with 0.8 here:

http://github.com/kolewu/redmine-graphs-plugin/tree/master

It also incorporates the bugfix from Eric.

Thanks Brad and Eric for all your good work!

RE: Graphs plugin - Added by Tommy L. over 15 years ago

Just tried the 0.8 port! Very nice :)

Thank you guys!

RE: Graphs plugin - Added by Marios Timotheou over 15 years ago

Bob Roberts wrote:

In response to my own reply above, I've just read the related thread here that discusses this issue. Would happily attempt to fix if someone could point me in the right direction as to the best approach to setting the correct base URI in the same way other plugins do when using something like this in their index.html.erb:

<%= stylesheet_link_tag "stuff_to_do.css", :plugin => "stuff_to_do_plugin", :media => 'all' %>

I have the same issue with this. the graphs come up with black background
i am using the latest rev 2791 and just upated the plugin from git but no change.
is there a workaround this?

RE: Graphs plugin - Added by Nanda P over 15 years ago

Updated the plug-in from GitHub. I am getting the following error :(

A NoMethodError occurred in graphs#old_issues:

  undefined method `active_children' for #<Project:0x64e743c>
  C:/Program Files/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb

ruby script\about

About your application's environment
Ruby version              1.8.6 (i386-mswin32)
RubyGems version          1.3.1
Rails version             2.2.2
Active Record version     2.2.2
Action Pack version       2.2.2
Active Resource version   2.2.2
Action Mailer version     2.2.2
Active Support version    2.2.2
Application root          C:/Program Files/redmine/current
Environment               development
Database adapter          mysql
Database schema version   20090614091200

About your Redmine plugins
Stuff To Do Plugin                   0.3.0
Charts Plugin                        0.0.12
Bulk Time Entry                      0.3.0
Redmine Task Board plugin            1.0.0
Redmine Status Updates               0.1.1
Redmine Hudson plugin                0.1.0
Redmine Blogs plugin                 0.0.4
Redmine System Notification plugin   0.2.0
Redmine Exception Handler plugin     0.2.0
ezFAQ plugin                         0.3.3
Redmine Schedules plugin             0.4.2
Redmine Issues Group plugin          0.1.1
Timesheet Plugin                     0.5.0
Redmine Graphs plugin                0.1.0
Redmine Question plugin              0.3.0

RE: Graphs plugin - Added by Ammler _ over 15 years ago

Marios Timotheou wrote:

I have the same issue with this. the graphs come up with black background

I have this error, either. After pulling yesterday current development version. Example: https://dev.openttdcoop.org/versions/show/35

(Redmine is trunk 2778)

RE: Graphs plugin - Added by Marios Timotheou over 15 years ago

my solution for now is what Thomas M recommended about 1 month ago

"By the way commenting :no_css and :style_sheet in graph_controller.rb gives the graphs back."

I assume that gives a default style to the graphs but it's better than black background.

It seems the correct fix is to use the base url for those links which i am not sure how that is done yet.

RE: Graphs plugin - Added by Ammler _ over 15 years ago

Maybe you could show me a patch about your changes, I am not able to remove the background...

RE: Graphs plugin - Added by Marios Timotheou over 15 years ago

what I did was edit this file : graphs_controller.rb (which is in the controllers folder of the graphs plugin
find the lines about :no_css and :style_sheet and either remove or comment ( note they appear more than once, one for each graph type so you have to remove/comment all of them)
The correct way is to make the :style_sheet use the base_url so you can use those stylesheets.

RE: Graphs plugin - Added by gabriel scolan over 15 years ago

Hi there,

I've just try and install this plugin that promise to be a great one, but it doesn't work on my instance. I'm using the 0.8.1 version of redmine, and the following happens: while displaying the "versions/show" page, it seems the web-browser (both IE and Firefox) "thinks" before try and render the graph, but after some seconds, nothing is displayed : on Firefox, absolutely nothing; no IE, in the frame where the graph is supposed to be displayed, the text "download failed" shows up.
On Firefox, the frame "label_graphs_total_vs_closed_issues" is very small.
On IE, the frame "label_graphs_total_vs_closed_issues" has a height that seems to be the correct one.

Has someone any idea of the root cause of this ? May be something is wrongly configured on my browsers ?
thanks for help

gabriel

RE: Graphs plugin - Added by Mark P over 15 years ago

Hello all,

Attempted to install this plugin as follows:
git clone git://github.com/kolewu/redmine-graphs-plugin.git vendor/plugins/redmine_graphs_plugin (for 0.8.3 compatibility)
rake db:migrate_plugins RAILS_ENV=development (not sure if this plugin requires db migration or not)
Restart my mongrel cluster.
Navigate to Issues Tab
I see Graphs in sidebar with two options: Open aging issues and Total issues over time. So far, so good I think.

Clicking either of the two links displays the following errors:
ArgumentError in GraphsController#old_issues
A copy of ApplicationController has been removed from the module tree but is still active!
RAILS_ROOT: /var/www/redmine/redmine-0.8.3
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:250:in `load_missing_constant'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:484:in `const_missing'
app/controllers/application.rb:40:in `user_setup'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/callbacks.rb:173:in `send'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/callbacks.rb:173:in `evaluate_method'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/callbacks.rb:161:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/filters.rb:191:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/filters.rb:591:in `run_before_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/filters.rb:577:in `call_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/filters.rb:572:in `perform_action_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/rescue.rb:201:in `perform_action_without_caching'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/query_cache.rb:8:in `cache'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/base.rb:529:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/base.rb:529:in `process_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/filters.rb:568:in `process_without_session_management_support'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/session_management.rb:130:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/base.rb:389:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/dispatcher.rb:149:in `handle_request'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/dispatcher.rb:107:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/dispatcher.rb:104:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/dispatcher.rb:104:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/dispatcher.rb:120:in `dispatch_cgi'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/dispatcher.rb:35:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/usr/bin/mongrel_rails:19:in `load'
/usr/bin/mongrel_rails:19

I appreciate your help and dedication to this development effort.

RE: Graphs plugin - Added by Uwe Koloska over 15 years ago

I don't know what's going on there, but maybe this is due to an incompatible change in a minor release. I use the latest stable version that now is at 0.8.4.stable.2815. My Rails version is the exact same as yours (and fixed at this in config/environment.rb).

This plugin doesn't need the ake db:migrate_plugins step -- there are no migrations in db/ (there is no such directory in the plugin).

RE: Graphs plugin - Added by Eric Davis over 15 years ago

Mark P wrote:

A copy of ApplicationController has been removed from the module tree but is still active!

This looks like a bug in the plugin that occurs only in development mode. If unloadable is added to GraphsController, it should work.

Eric Davis

RE: Graphs plugin - Added by Mark P over 15 years ago

You are correct that the error only occurs in dev mode. I put the plugin into production and it worked after I commented the css and style sheet references as other have stated (black background showed up first).

Is the overall graph for the top 6 projects in a Redmine instance available in this fork? I am not seeing that, nor am I seeing the old issues graph mentioned previously in this forum post.

This is really great stuff. Thanks for your hard work and quick replies.

Mark

RE: Graphs plugin - Added by Mark P over 15 years ago

Scratch that. I found the top 6 projects when looking at all issues. Still not seeing the old issues graph anywhere.

RE: Graphs plugin - Added by ciaran jessup about 15 years ago

I've put a proof-of-concept fork up at http://github.com/ciaranj/redmine-graphs-plugin/tree/master for 95% browser coverage (including IE6,7 etc. ) using google's svgweb toolkit (http://code.google.com/p/svgweb/). This also has the 'unloadable' change in this commit log.

I've only done the 'my pages' block to demonstrate how it works (surprisingly well as it happens) as I've temporarily lost my reference code for creating view-helpers in plugins (which I want to do to simplify the complexities of creating the IE-safe object tags). But intend to finish off the other graphs too. The other issue I have is, that the fork I took (Uwe Koloska's) appears not to be compatible with Eric Davis' branches (undefined method `active_children' for #<Project:0x1075fb4c0> ? ) ... too tired to investigate right now.

Hope this is useful (finally graphs in IE!) ... expect similar fixes to follow around the repository statistics..

RE: Graphs plugin - Added by Eric Davis about 15 years ago

ciaran jessup wrote:

as I've temporarily lost my reference code for creating view-helpers in plugins (which I want to do to simplify the complexities of creating the IE-safe object tags).

  1. Create app/helpers/my_controller_helper.rb
  2. Add helper :my_controller to your controller

My Budget plugin on Github uses some.

The other issue I have is, that the fork I took (Uwe Koloska's) appears not to be compatible with Eric Davis' branches (undefined method `active_children' for #<Project:0x1075fb4c0> ? ) ... too tired to investigate right now.

Mine is meant for the upcoming Rails 2.3.4 support in trunk so it's probably the unlimited subproject nesting API change. I'm also too tired to investigate.

Eric Davis

RE: Graphs plugin - Added by ciaran jessup about 15 years ago

Eric Davis wrote:

ciaran jessup wrote:

as I've temporarily lost my reference code for creating view-helpers in plugins (which I want to do to simplify the complexities of creating the IE-safe object tags).

  1. Create app/helpers/my_controller_helper.rb
  2. Add helper :my_controller to your controller

My Budget plugin on Github uses some.

That works well for helpers within the views the graph controller serves directly, but the 'my pages blocks' can't see those helpers, any ideas on whether I should monkey-patch the application helpers or something ?

The other issue I have is, that the fork I took (Uwe Koloska's) appears not to be compatible with Eric Davis' branches (undefined method `active_children' for #<Project:0x1075fb4c0> ? ) ... too tired to investigate right now.

Mine is meant for the upcoming Rails 2.3.4 support in trunk so it's probably the unlimited subproject nesting API change. I'm also too tired to investigate.

It was this, if anyone else is interested in testing this (well worth it esp. with the shared version support, makes it very very powerful within product development teams), This git commit applies a 'fix' ( I think)
http://github.com/ciaranj/redmine-graphs-plugin/commit/3523afa0ec5985299e2e29c44482202f8fb59129

Eric Davis

RE: Graphs plugin - Added by Daniel Jones about 15 years ago

I've installed this plugin, into the trunk (revision 2886).

Everything is working, except I'm getting 'translation missing: en, ...' instead of the correct text that is store in the en.yml file.

the sidebar for example is:

translation missing: en, label_graphs
translation missing: en, label_graphs_old_issues
translation missing: en, label_graphs_issue_growth

Is there something I need to do to get the translations working correctly? Is there any other info I can give you to help out with resolving what I have done incorrectly?

RE: Graphs plugin - Added by The Anchialos about 15 years ago

Hi Brad!

You wrote a great plugin!

There is a sql problem in the graphs_controller's issue_growth_graph:

sql << " LIMIT 6" 

This works only with mysql databases, but not with oracle or mssql:

// mysql
select col from tbl limit 20;

// Oracle
select col from tbl where rownum<=20;

// Microsoft SQL
select top 20 col from tbl;

Can you fix this with the next release?
Thanks!

RE: Graphs plugin - Added by Peter Fern about 15 years ago

ciaran jessup wrote:

Eric Davis wrote:

ciaran jessup wrote:

The other issue I have is, that the fork I took (Uwe Koloska's) appears not to be compatible with Eric Davis' branches (undefined method `active_children' for #<Project:0x1075fb4c0> ? ) ... too tired to investigate right now.

Mine is meant for the upcoming Rails 2.3.4 support in trunk so it's probably the unlimited subproject nesting API change. I'm also too tired to investigate.

It was this, if anyone else is interested in testing this (well worth it esp. with the shared version support, makes it very very powerful within product development teams), This git commit applies a 'fix' ( I think)
http://github.com/ciaranj/redmine-graphs-plugin/commit/3523afa0ec5985299e2e29c44482202f8fb59129

Based on your fix, fix other instances too:

diff --git a/app/controllers/graphs_controller.rb b/app/controllers/graphs_controller.rb
index 2d0de20..93c1bd1 100644
--- a/app/controllers/graphs_controller.rb
+++ b/app/controllers/graphs_controller.rb
@@ -104,8 +104,7 @@ class GraphsController < ApplicationController
         sql << " WHERE (%s)" % Project.allowed_to_condition(User.current, :view_issues)
         unless @project.nil?
             sql << " AND (project_id = #{@project.id}" 
-            sql << "    OR project_id IN (%s)" % @project.active_children.collect { |p| p.id }.join(',') unless @project.active_children.empty?
-            sql << " )" 
+            sql << "    OR #{@project.project_condition(true)})" 
         end 
         sql << " GROUP BY project_id" 
         sql << " ORDER BY issue_count DESC" 
@@ -267,9 +266,7 @@ class GraphsController < ApplicationController
     def confirm_issues_exist
         find_optional_project
         if !@project.nil?
-            ids = [@project.id]
-            ids += @project.active_children.collect(&:id)
-            @issues = Issue.find(:first, :include => [:project], :conditions => ["#{Project.table_name}.id IN (?)", ids])
+            @issues = Issue.find(:first, :include => [:project], :conditions => ["#{@project.project_condition(true)}"])
         else
             @issues = Issue.find(:first)
         end
(51-75/104)