1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Copy the "line-chart" behavior to "line-chart-legacy" to keep "Maniphest > Reports" working

Summary:
Ref T13279. Charting changes alter how the "line-chart" behavior works, but the "Burnup Chart" still relies on the old behavior.

Although I'm intending to remove "Maniphest > Reports" once Facts is a minimally sufficient replacement, copy this behavior to keep it working until we're ready to pull the trigger.

Also fix a leftover typo from D20435.

Test Plan: Viewed a legacy Maniphest burnup rate report.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13279

Differential Revision: https://secure.phabricator.com/D20449
This commit is contained in:
epriestley 2019-04-18 06:38:49 -07:00
parent de74332639
commit e1076528ef
4 changed files with 136 additions and 2 deletions

View file

@ -398,6 +398,7 @@ return array(
'rsrc/js/application/herald/PathTypeahead.js' => 'ad486db3', 'rsrc/js/application/herald/PathTypeahead.js' => 'ad486db3',
'rsrc/js/application/herald/herald-rule-editor.js' => '0922e81d', 'rsrc/js/application/herald/herald-rule-editor.js' => '0922e81d',
'rsrc/js/application/maniphest/behavior-batch-selector.js' => '139ef688', 'rsrc/js/application/maniphest/behavior-batch-selector.js' => '139ef688',
'rsrc/js/application/maniphest/behavior-line-chart-legacy.js' => 'faf3ab6b',
'rsrc/js/application/maniphest/behavior-line-chart.js' => 'ad258e28', 'rsrc/js/application/maniphest/behavior-line-chart.js' => 'ad258e28',
'rsrc/js/application/maniphest/behavior-list-edit.js' => 'c687e867', 'rsrc/js/application/maniphest/behavior-list-edit.js' => 'c687e867',
'rsrc/js/application/owners/OwnersPathEditor.js' => '2a8b62d9', 'rsrc/js/application/owners/OwnersPathEditor.js' => '2a8b62d9',
@ -627,6 +628,7 @@ return array(
'javelin-behavior-launch-icon-composer' => 'a17b84f1', 'javelin-behavior-launch-icon-composer' => 'a17b84f1',
'javelin-behavior-lightbox-attachments' => 'c7e748bf', 'javelin-behavior-lightbox-attachments' => 'c7e748bf',
'javelin-behavior-line-chart' => 'ad258e28', 'javelin-behavior-line-chart' => 'ad258e28',
'javelin-behavior-line-chart-legacy' => 'faf3ab6b',
'javelin-behavior-linked-container' => '74446546', 'javelin-behavior-linked-container' => '74446546',
'javelin-behavior-maniphest-batch-selector' => '139ef688', 'javelin-behavior-maniphest-batch-selector' => '139ef688',
'javelin-behavior-maniphest-list-editor' => 'c687e867', 'javelin-behavior-maniphest-list-editor' => 'c687e867',
@ -2180,6 +2182,12 @@ return array(
'fa74cc35' => array( 'fa74cc35' => array(
'phui-oi-list-view-css', 'phui-oi-list-view-css',
), ),
'faf3ab6b' => array(
'javelin-behavior',
'javelin-dom',
'javelin-vector',
'phui-chart-css',
),
'fcb0c07d' => array( 'fcb0c07d' => array(
'phui-chart-css', 'phui-chart-css',
'd3', 'd3',

View file

@ -382,7 +382,7 @@ final class ManiphestReportController extends ManiphestController {
require_celerity_resource('d3'); require_celerity_resource('d3');
require_celerity_resource('phui-chart-css'); require_celerity_resource('phui-chart-css');
Javelin::initBehavior('line-chart', array( Javelin::initBehavior('line-chart-legacy', array(
'hardpoint' => $id, 'hardpoint' => $id,
'x' => array( 'x' => array(
$burn_x, $burn_x,

View file

@ -436,7 +436,7 @@ final class PhabricatorRepositoryPullEngine
// We can tell the client what it should check out by making "HEAD" // We can tell the client what it should check out by making "HEAD"
// point somewhere. However: // point somewhere. However:
// //
// (1) If we don't set "receive.denyDelteCurrent" to "ignore" and a user // (1) If we don't set "receive.denyDeleteCurrent" to "ignore" and a user
// tries to delete the default branch, Git raises an error and refuses. // tries to delete the default branch, Git raises an error and refuses.
// We want to allow this; we already have sufficient protections around // We want to allow this; we already have sufficient protections around
// dangerous changes and do not need to special case the default branch. // dangerous changes and do not need to special case the default branch.

View file

@ -0,0 +1,126 @@
/**
* @provides javelin-behavior-line-chart-legacy
* @requires javelin-behavior
* javelin-dom
* javelin-vector
* phui-chart-css
*/
JX.behavior('line-chart-legacy', function(config) {
function fn(n) {
return n + '(' + JX.$A(arguments).slice(1).join(', ') + ')';
}
var h = JX.$(config.hardpoint);
var d = JX.Vector.getDim(h);
var padding = {
top: 24,
left: 48,
bottom: 48,
right: 32
};
var size = {
frameWidth: d.x,
frameHeight: d.y,
};
size.width = size.frameWidth - padding.left - padding.right;
size.height = size.frameHeight - padding.top - padding.bottom;
var x = d3.time.scale()
.range([0, size.width]);
var y = d3.scale.linear()
.range([size.height, 0]);
var xAxis = d3.svg.axis()
.scale(x)
.orient('bottom');
var yAxis = d3.svg.axis()
.scale(y)
.orient('left');
var svg = d3.select('#' + config.hardpoint).append('svg')
.attr('width', size.frameWidth)
.attr('height', size.frameHeight)
.attr('class', 'chart');
var g = svg.append('g')
.attr('transform', fn('translate', padding.left, padding.top));
g.append('rect')
.attr('class', 'inner')
.attr('width', size.width)
.attr('height', size.height);
var line = d3.svg.line()
.x(function(d) { return x(d.date); })
.y(function(d) { return y(d.count); });
var data = [];
for (var ii = 0; ii < config.x[0].length; ii++) {
data.push(
{
date: new Date(config.x[0][ii] * 1000),
count: +config.y[0][ii]
});
}
x.domain(d3.extent(data, function(d) { return d.date; }));
var yex = d3.extent(data, function(d) { return d.count; });
yex[0] = 0;
yex[1] = yex[1] * 1.05;
y.domain(yex);
g.append('path')
.datum(data)
.attr('class', 'line')
.attr('d', line);
g.append('g')
.attr('class', 'x axis')
.attr('transform', fn('translate', 0, size.height))
.call(xAxis);
g.append('g')
.attr('class', 'y axis')
.attr('transform', fn('translate', 0, 0))
.call(yAxis);
var div = d3.select('body')
.append('div')
.attr('class', 'chart-tooltip')
.style('opacity', 0);
g.selectAll('dot')
.data(data)
.enter()
.append('circle')
.attr('class', 'point')
.attr('r', 3)
.attr('cx', function(d) { return x(d.date); })
.attr('cy', function(d) { return y(d.count); })
.on('mouseover', function(d) {
var d_y = d.date.getFullYear();
// NOTE: Javascript months are zero-based. See PHI1017.
var d_m = d.date.getMonth() + 1;
var d_d = d.date.getDate();
div
.html(d_y + '-' + d_m + '-' + d_d + ': ' + d.count)
.style('opacity', 0.9)
.style('left', (d3.event.pageX - 60) + 'px')
.style('top', (d3.event.pageY - 38) + 'px');
})
.on('mouseout', function() {
div.style('opacity', 0);
});
});