Cumulative Flow Diagram

Post about your customizations to share with others.

Moderators: Developer, Contributor

Post Reply
spidgorny
Posts: 1
Joined: 12 Jun 2013, 12:37

Cumulative Flow Diagram

Post by spidgorny »

Hi,

I've implemented a cumulative flow diagram for myself, but I don't know (and don't want to know) how to create an official plugin. Here's the core of the source code attached. Charting is done with https://github.com/flot/flot. Depends on https://bitbucket.org/spidgorny/nadlib/. Hope it's useful for somebody.

Code: Select all

	function show_cfd($t_project_id, $t_version) {
		error_reporting(E_ERROR);
		$t_bug_table	= db_get_table( 'mantis_bug_table' );
		$t_history_table = db_get_table( 'mantis_bug_history_table' );
		$query = "SELECT sbt.*, $t_history_table.date_modified AS fixed
			FROM $t_bug_table AS sbt
			LEFT OUTER JOIN $t_history_table ON (
				(sbt.id=$t_history_table.bug_id
				 AND field_name = 'status'
				 AND new_value = 80
				) OR sbt.id IS NULL
			)
			WHERE sbt.project_id=" . db_param() . " AND sbt.target_version=" . db_param() . "
			ORDER BY sbt.status ASC, sbt.last_updated DESC";

		$t_result = db_query_bound( $query, Array( $t_project_id, $t_version ) );
		//debug($t_result);
		$db = new MySQL();
		$bugs = $db->fetchAll($t_result->_queryID);

		$timeline = array();
		foreach ($bugs as $bug) {
			$time = round($bug['date_submitted']/100)*100;
			$timeline[$time]['add']++;
			$timeline[$time]['fix']+=0;
			if ($bug['fixed']) {
				$time = round($bug['fixed']/100)*100;
				$timeline[$time]['add']+=0;
				$timeline[$time]['fix']++;
			}
		}
		//debug($timeline);
		//debug($bug);
		//debug(sizeof($bugs));
		//$f = new Flot($bugs, 'project_id', 'fixed', '');
		//$f->data = $timeline;
		//echo $f->render();
		$fa = new FlotArea($timeline, array('add', 'fix'));
		$fa->setFlot('vendor/flot/flot');
		echo $fa->render();
	}
Attachments
Cumulative Flow Diagram
Cumulative Flow Diagram
Roadmap - MantisBT_2013-06-12_14-40-27.png (27.74 KiB) Viewed 17913 times
Post Reply