pie 2d drawing corrections
This commit is contained in:
@@ -6,6 +6,7 @@ var ViewDashboardHelper = function () {
|
|||||||
ViewDashboardHelper.prototype.userDashboards = function(userId, callBack) {
|
ViewDashboardHelper.prototype.userDashboards = function(userId, callBack) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//TODO refactor to a good name...
|
||||||
ViewDashboardHelper.prototype.stringIfNull = function (val){
|
ViewDashboardHelper.prototype.stringIfNull = function (val){
|
||||||
if(val === null || val == undefined || val == "?"){
|
if(val === null || val == undefined || val == "?"){
|
||||||
val = "?";
|
val = "?";
|
||||||
@@ -15,6 +16,15 @@ ViewDashboardHelper.prototype.stringIfNull = function (val){
|
|||||||
return val;
|
return val;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ViewDashboardHelper.prototype.labelIfEmpty = function (val){
|
||||||
|
if(val === null || val == undefined || val == ""){
|
||||||
|
val = "(No Name)";
|
||||||
|
} else {
|
||||||
|
val = val
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
};
|
||||||
|
|
||||||
ViewDashboardHelper.prototype.assert = function (condition, message) {
|
ViewDashboardHelper.prototype.assert = function (condition, message) {
|
||||||
if (!condition) {
|
if (!condition) {
|
||||||
message = message || "Assertion failed";
|
message = message || "Assertion failed";
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ ViewDashboardPresenter.prototype.getDashboardIndicators = function (dashboardId,
|
|||||||
};
|
};
|
||||||
|
|
||||||
ViewDashboardPresenter.prototype.dashboardIndicatorsViewModel = function(data) {
|
ViewDashboardPresenter.prototype.dashboardIndicatorsViewModel = function(data) {
|
||||||
|
if (data == null) {return null;}
|
||||||
var that = this;
|
var that = this;
|
||||||
var returnList = [];
|
var returnList = [];
|
||||||
var i = 1;
|
var i = 1;
|
||||||
@@ -154,9 +155,11 @@ ViewDashboardPresenter.prototype.getIndicatorData = function (indicatorId, indic
|
|||||||
};
|
};
|
||||||
|
|
||||||
ViewDashboardPresenter.prototype.peiViewModel = function(data) {
|
ViewDashboardPresenter.prototype.peiViewModel = function(data) {
|
||||||
|
if (data == null) {return null;}
|
||||||
var that = this;
|
var that = this;
|
||||||
var graphData = [];
|
var graphData = [];
|
||||||
$.each(data.data, function(index, originalObject) {
|
$.each(data.data, function(index, originalObject) {
|
||||||
|
originalObject.name = that.helper.labelIfEmpty(originalObject.name);
|
||||||
var map = {
|
var map = {
|
||||||
"name" : "datalabel",
|
"name" : "datalabel",
|
||||||
"inefficiencyCost" : "value"
|
"inefficiencyCost" : "value"
|
||||||
@@ -178,10 +181,22 @@ ViewDashboardPresenter.prototype.peiViewModel = function(data) {
|
|||||||
retval = data;
|
retval = data;
|
||||||
graphData.sort(function(a,b) {
|
graphData.sort(function(a,b) {
|
||||||
var retval = 0;
|
var retval = 0;
|
||||||
retval = ((a.value*1.0 <= b.value*1.0) ? 1 : -1);
|
retval = ((a.value*1.0 <= b.value*1.0) ? -1 : 1);
|
||||||
return retval;
|
return retval;
|
||||||
})
|
})
|
||||||
retval.dataToDraw = graphData.splice(0,7);
|
retval.dataToDraw = graphData.splice(0,7);
|
||||||
|
|
||||||
|
//use positive values for drawing;
|
||||||
|
$.each(retval.dataToDraw, function(index, item) {
|
||||||
|
if (item.value > 0) {
|
||||||
|
item.value = 0;
|
||||||
|
}
|
||||||
|
if (item.value < 0) {
|
||||||
|
item.value = Math.abs(item.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
//TODO aumentar el símbolo de moneda $
|
//TODO aumentar el símbolo de moneda $
|
||||||
retval.inefficiencyCostToShow = "$ " +Math.round(retval.inefficiencyCost);
|
retval.inefficiencyCostToShow = "$ " +Math.round(retval.inefficiencyCost);
|
||||||
retval.efficiencyIndexToShow = Math.round(retval.efficiencyIndex * 100) / 100;
|
retval.efficiencyIndexToShow = Math.round(retval.efficiencyIndex * 100) / 100;
|
||||||
@@ -189,9 +204,11 @@ ViewDashboardPresenter.prototype.peiViewModel = function(data) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ViewDashboardPresenter.prototype.ueiViewModel = function(data) {
|
ViewDashboardPresenter.prototype.ueiViewModel = function(data) {
|
||||||
|
if (data == null) {return null;}
|
||||||
var that = this;
|
var that = this;
|
||||||
var graphData = [];
|
var graphData = [];
|
||||||
$.each(data.data, function(index, originalObject) {
|
$.each(data.data, function(index, originalObject) {
|
||||||
|
originalObject.name = that.helper.labelIfEmpty(originalObject.name);
|
||||||
var map = {
|
var map = {
|
||||||
"name" : "datalabel",
|
"name" : "datalabel",
|
||||||
"inefficiencyCost" : "value",
|
"inefficiencyCost" : "value",
|
||||||
@@ -214,10 +231,22 @@ ViewDashboardPresenter.prototype.ueiViewModel = function(data) {
|
|||||||
retval = data;
|
retval = data;
|
||||||
graphData.sort(function(a,b) {
|
graphData.sort(function(a,b) {
|
||||||
var retval = 0;
|
var retval = 0;
|
||||||
retval = ((a.value*1.0 <= b.value*1.0) ? 1 : -1);
|
retval = ((a.value*1.0 <= b.value*1.0) ? -1 : 1);
|
||||||
return retval;
|
return retval;
|
||||||
})
|
})
|
||||||
retval.dataToDraw = graphData.splice(0,7);
|
retval.dataToDraw = graphData.splice(0,7);
|
||||||
|
|
||||||
|
//use positive values for drawing;
|
||||||
|
$.each(retval.dataToDraw, function(index, item) {
|
||||||
|
if (item.value > 0) {
|
||||||
|
item.value = 0;
|
||||||
|
}
|
||||||
|
if (item.value < 0) {
|
||||||
|
item.value = Math.abs(item.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
//TODO aumentar el símbolo de moneda $
|
//TODO aumentar el símbolo de moneda $
|
||||||
retval.inefficiencyCostToShow = "$ " + Math.round(retval.inefficiencyCost);
|
retval.inefficiencyCostToShow = "$ " + Math.round(retval.inefficiencyCost);
|
||||||
retval.efficiencyIndexToShow = Math.round(retval.efficiencyIndex * 100) / 100;
|
retval.efficiencyIndexToShow = Math.round(retval.efficiencyIndex * 100) / 100;
|
||||||
@@ -225,45 +254,60 @@ ViewDashboardPresenter.prototype.ueiViewModel = function(data) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ViewDashboardPresenter.prototype.statusViewModel = function(indicatorId, data) {
|
ViewDashboardPresenter.prototype.statusViewModel = function(indicatorId, data) {
|
||||||
|
if (data == null) {return null;}
|
||||||
var that = this;
|
var that = this;
|
||||||
data.id = indicatorId;
|
data.id = indicatorId;
|
||||||
var graph1Data = [];
|
var graph1Data = [];
|
||||||
var graph2Data = [];
|
var graph2Data = [];
|
||||||
var graph3Data = [];
|
var graph3Data = [];
|
||||||
$.each(data.dataList, function(index, originalObject) {
|
$.each(data.dataList, function(index, originalObject) {
|
||||||
var title = (originalObject.taskTitle == null)
|
|
||||||
? ""
|
originalObject.taskTitle = that.helper.labelIfEmpty(originalObject.taskTitle);
|
||||||
: originalObject.taskTitle.substring(0,15);
|
//TODO use more that 10 chars when the label and color problem in pie 2D is solved.
|
||||||
|
var title = originalObject.taskTitle.substring(0,10);
|
||||||
|
|
||||||
|
//TODO Do not use the str. replace when color and lable in pie 2D is solved.
|
||||||
var newObject1 = {
|
var newObject1 = {
|
||||||
datalabel : title,
|
datalabel : title.trim().replace(" ", "_"),
|
||||||
value : originalObject.percentageTotalOverdue
|
value : originalObject.percentageTotalOverdue
|
||||||
};
|
};
|
||||||
var newObject2 = {
|
var newObject2 = {
|
||||||
datalabel : title,
|
datalabel : title.trim().replace(" ", "_"),
|
||||||
value : originalObject.percentageTotalAtRisk
|
value : originalObject.percentageTotalAtRisk
|
||||||
};
|
};
|
||||||
var newObject3 = {
|
var newObject3 = {
|
||||||
datalabel : title,
|
datalabel : title.trim().replace(" ", "_"),
|
||||||
value : originalObject.percentageTotalOnTime
|
value : originalObject.percentageTotalOnTime
|
||||||
};
|
};
|
||||||
|
|
||||||
graph1Data.push(newObject1);
|
if (newObject1.value > 0) {
|
||||||
graph2Data.push(newObject2);
|
graph1Data.push(newObject1);
|
||||||
graph3Data.push(newObject3);
|
}
|
||||||
|
if (newObject2.value > 0) {
|
||||||
|
graph2Data.push(newObject2);
|
||||||
|
}
|
||||||
|
if (newObject3.value > 0) {
|
||||||
|
graph3Data.push(newObject3);
|
||||||
|
}
|
||||||
//we add the indicator id for reference
|
//we add the indicator id for reference
|
||||||
originalObject.indicatorId = indicatorId;
|
originalObject.indicatorId = indicatorId;
|
||||||
});
|
});
|
||||||
|
|
||||||
var retval = data;
|
var retval = data;
|
||||||
//TODO selecte de 7 worst cases no the first 7
|
//TODO selecte de 7 worst cases no the first 7
|
||||||
retval.graph1Data = graph1Data.splice(0,7)
|
retval.graph1Data = this.orderGraphData(graph1Data, "down").splice(0,7)
|
||||||
retval.graph2Data = graph2Data.splice(0,7)
|
retval.graph2Data = this.orderGraphData(graph2Data, "down").splice(0,7)
|
||||||
retval.graph3Data = graph3Data.splice(0,7)
|
retval.graph3Data = this.orderGraphData(graph3Data, "down").splice(0,7)
|
||||||
|
//TODO correct 2D Pie so we don't depend on label name
|
||||||
|
|
||||||
|
$.each(retval.graph1Data, function(index, item) { item.datalabel = (index + 1) + "." + item.datalabel; });
|
||||||
|
$.each(retval.graph2Data, function(index, item) { item.datalabel = (index + 1) + "." + item.datalabel; });
|
||||||
|
$.each(retval.graph3Data, function(index, item) { item.datalabel = (index + 1) + "." + item.datalabel; });
|
||||||
return retval;
|
return retval;
|
||||||
};
|
};
|
||||||
|
|
||||||
ViewDashboardPresenter.prototype.indicatorViewModel = function(data) {
|
ViewDashboardPresenter.prototype.indicatorViewModel = function(data) {
|
||||||
|
if (data == null) {return null;}
|
||||||
var that = this;
|
var that = this;
|
||||||
$.each(data.graph1Data, function(index, originalObject) {
|
$.each(data.graph1Data, function(index, originalObject) {
|
||||||
var label = (('YEAR' in originalObject) ? originalObject.YEAR : "") ;
|
var label = (('YEAR' in originalObject) ? originalObject.YEAR : "") ;
|
||||||
@@ -313,6 +357,7 @@ ViewDashboardPresenter.prototype.getSpecialIndicatorSecondLevel = function (enti
|
|||||||
};
|
};
|
||||||
|
|
||||||
ViewDashboardPresenter.prototype.returnIndicatorSecondLevelPei = function(modelData) {
|
ViewDashboardPresenter.prototype.returnIndicatorSecondLevelPei = function(modelData) {
|
||||||
|
if (modelData == null) {return null;}
|
||||||
//modelData arrives in format [{users/tasks}]
|
//modelData arrives in format [{users/tasks}]
|
||||||
//returns object {dataToDraw[], entityData[] //user/tasks data}
|
//returns object {dataToDraw[], entityData[] //user/tasks data}
|
||||||
var that = this;
|
var that = this;
|
||||||
@@ -337,6 +382,7 @@ ViewDashboardPresenter.prototype.returnIndicatorSecondLevelPei = function(modelD
|
|||||||
};
|
};
|
||||||
|
|
||||||
ViewDashboardPresenter.prototype.returnIndicatorSecondLevelUei = function(modelData) {
|
ViewDashboardPresenter.prototype.returnIndicatorSecondLevelUei = function(modelData) {
|
||||||
|
if (modelData == null) {return null;}
|
||||||
//modelData arrives in format [{users/tasks}]
|
//modelData arrives in format [{users/tasks}]
|
||||||
//returns object {dataToDraw[], entityData[] //user/tasks data}
|
//returns object {dataToDraw[], entityData[] //user/tasks data}
|
||||||
var that = this;
|
var that = this;
|
||||||
@@ -362,6 +408,7 @@ ViewDashboardPresenter.prototype.returnIndicatorSecondLevelUei = function(modelD
|
|||||||
/*-------SECOND LEVEL INDICATOR DATA*/
|
/*-------SECOND LEVEL INDICATOR DATA*/
|
||||||
|
|
||||||
ViewDashboardPresenter.prototype.orderDataList = function(listData, orderDirection, orderFunction) {
|
ViewDashboardPresenter.prototype.orderDataList = function(listData, orderDirection, orderFunction) {
|
||||||
|
if (listData == null) {return null;}
|
||||||
//orderDirection is passed in case no order FUnction is passed (to use in the default ordering)
|
//orderDirection is passed in case no order FUnction is passed (to use in the default ordering)
|
||||||
var orderToUse = orderFunction;
|
var orderToUse = orderFunction;
|
||||||
if (orderFunction == undefined) {
|
if (orderFunction == undefined) {
|
||||||
@@ -379,3 +426,23 @@ ViewDashboardPresenter.prototype.orderDataList = function(listData, orderDirecti
|
|||||||
}
|
}
|
||||||
return listData.sort(orderToUse);
|
return listData.sort(orderToUse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ViewDashboardPresenter.prototype.orderGraphData = function(listData, orderDirection, orderFunction) {
|
||||||
|
if (listData == null) {return null;}
|
||||||
|
//orderDirection is passed in case no order FUnction is passed (to use in the default ordering)
|
||||||
|
var orderToUse = orderFunction;
|
||||||
|
if (orderFunction == undefined) {
|
||||||
|
orderToUse = function (a ,b) {
|
||||||
|
var retval = 0;
|
||||||
|
if (orderDirection == "down") {
|
||||||
|
retval = ((a.value*1.0 <= b.value*1.0) ? 1 : -1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//the 1,-1 are flipped
|
||||||
|
retval = ((a.value*1.0 <= b.value*1.0) ? -1 : 1);
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return listData.sort(orderToUse);
|
||||||
|
}
|
||||||
|
|||||||
@@ -379,6 +379,7 @@ var initialDraw = function () {
|
|||||||
presenter.getUserDashboards(pageUserId)
|
presenter.getUserDashboards(pageUserId)
|
||||||
.then(function(dashboardsVM) {
|
.then(function(dashboardsVM) {
|
||||||
fillDashboardsList(dashboardsVM);
|
fillDashboardsList(dashboardsVM);
|
||||||
|
if (window.currentDashboardId == null) {return;}
|
||||||
/**** window initialization with favorite dashboard*****/
|
/**** window initialization with favorite dashboard*****/
|
||||||
presenter.getDashboardIndicators(window.currentDashboardId, defaultInitDate(), defaultEndDate())
|
presenter.getDashboardIndicators(window.currentDashboardId, defaultInitDate(), defaultEndDate())
|
||||||
.done(function(indicatorsVM) {
|
.done(function(indicatorsVM) {
|
||||||
@@ -389,6 +390,7 @@ var initialDraw = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var loadIndicator = function (indicatorId, initDate, endDate) {
|
var loadIndicator = function (indicatorId, initDate, endDate) {
|
||||||
|
if (indicatorId == null || indicatorId === undefined) {return;}
|
||||||
var builder = new WidgetBuilder();
|
var builder = new WidgetBuilder();
|
||||||
window.currentIndicator = builder.getIndicatorLoadedById(indicatorId);
|
window.currentIndicator = builder.getIndicatorLoadedById(indicatorId);
|
||||||
presenter.getIndicatorData(indicatorId, window.currentIndicator.type, initDate, endDate)
|
presenter.getIndicatorData(indicatorId, window.currentIndicator.type, initDate, endDate)
|
||||||
@@ -467,6 +469,7 @@ var fillDashboardsList = function (presenterData) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var fillIndicatorWidgets = function (presenterData) {
|
var fillIndicatorWidgets = function (presenterData) {
|
||||||
|
if (presenterData == null || presenterData === undefined) {return;}
|
||||||
var widgetBuilder = new WidgetBuilder();
|
var widgetBuilder = new WidgetBuilder();
|
||||||
var grid = $('#indicatorsGridStack').data('gridstack');
|
var grid = $('#indicatorsGridStack').data('gridstack');
|
||||||
grid.remove_all();
|
grid.remove_all();
|
||||||
@@ -502,21 +505,17 @@ var fillStatusIndicatorFirstView = function (presenterData) {
|
|||||||
stretch:true
|
stretch:true
|
||||||
},
|
},
|
||||||
graph: {
|
graph: {
|
||||||
allowDrillDown:false,
|
|
||||||
|
allowDrillDown:true,
|
||||||
allowTransition:true,
|
allowTransition:true,
|
||||||
showTip: true,
|
showTip: true,
|
||||||
allowZoom: false,
|
allowZoom: false,
|
||||||
gapWidth:0.2,
|
showLabels: true
|
||||||
useShadows: true,
|
|
||||||
thickness: 30,
|
|
||||||
showLabels: true,
|
|
||||||
colorPalette: ['#5486bf','#bf8d54','#acb30c','#7a0c0c','#bc0000','#906090','#007efb','#62284a','#0c7a7a']
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var graph1 = new PieChart(presenterData.graph1Data, graphParams1, null, null);
|
var graph1 = new PieChart(presenterData.graph1Data, graphParams1, null, null);
|
||||||
graph1.drawChart();
|
graph1.drawChart();
|
||||||
|
|
||||||
var graphParams2 = graphParams1;
|
var graphParams2 = graphParams1;
|
||||||
graphParams2.canvas.containerId = "graph2";
|
graphParams2.canvas.containerId = "graph2";
|
||||||
var graph2 = new PieChart(presenterData.graph2Data, graphParams2, null, null);
|
var graph2 = new PieChart(presenterData.graph2Data, graphParams2, null, null);
|
||||||
@@ -528,6 +527,7 @@ var fillStatusIndicatorFirstView = function (presenterData) {
|
|||||||
|
|
||||||
var indicatorPrincipalData = widgetBuilder.getIndicatorLoadedById(presenterData.id)
|
var indicatorPrincipalData = widgetBuilder.getIndicatorLoadedById(presenterData.id)
|
||||||
setIndicatorActiveMarker();
|
setIndicatorActiveMarker();
|
||||||
|
$('#relatedLabel').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
var fillStatusIndicatorFirstViewDetail = function(presenterData) {
|
var fillStatusIndicatorFirstViewDetail = function(presenterData) {
|
||||||
@@ -551,6 +551,7 @@ var fillStatusIndicatorFirstViewDetail = function(presenterData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fillSpecialIndicatorFirstView = function(presenterData) {
|
var fillSpecialIndicatorFirstView = function(presenterData) {
|
||||||
|
$('#relatedLabel').show();
|
||||||
var widgetBuilder = new WidgetBuilder();
|
var widgetBuilder = new WidgetBuilder();
|
||||||
var panel = $('#indicatorsDataGridStack').data('gridstack');
|
var panel = $('#indicatorsDataGridStack').data('gridstack');
|
||||||
panel.remove_all();
|
panel.remove_all();
|
||||||
@@ -573,8 +574,7 @@ var fillSpecialIndicatorFirstView = function(presenterData) {
|
|||||||
gapWidth:0.3,
|
gapWidth:0.3,
|
||||||
useShadows: true,
|
useShadows: true,
|
||||||
thickness: 30,
|
thickness: 30,
|
||||||
showLabels: true,
|
showLabels: true
|
||||||
colorPalette: ['#5486bf','#bf8d54','#acb30c','#7a0c0c','#bc0000','#906090','#007efb','#62284a','#0c7a7a']
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -595,8 +595,7 @@ var fillSpecialIndicatorFirstView = function(presenterData) {
|
|||||||
showTip: true,
|
showTip: true,
|
||||||
allowZoom: false,
|
allowZoom: false,
|
||||||
useShadows: true,
|
useShadows: true,
|
||||||
paddingTop: 50,
|
paddingTop: 50
|
||||||
colorPalette: ['#5486bf','#bf8d54','#acb30c','#7a0c0c','#bc0000','#906090','#007efb','#62284a','#0c7a7a','#74a9a9']
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -327,9 +327,6 @@
|
|||||||
<h5 class="pull-left">{translate label="ID_DASH_COMPARE_MONTH"}:</h5>
|
<h5 class="pull-left">{translate label="ID_DASH_COMPARE_MONTH"}:</h5>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="span4 pull-left">
|
|
||||||
<button type="button" class="btn btn-compare btn-success pull-right btn-date">{translate label="ID_DASH_COMPARE"}</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="span4 pull-left">
|
<div class="span4 pull-left">
|
||||||
<select id="year" class="form-control pull-right ">
|
<select id="year" class="form-control pull-right ">
|
||||||
@@ -360,6 +357,10 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="span4 pull-left">
|
||||||
|
<button type="button" class="btn btn-compare btn-success pull-right btn-date">{translate label="ID_DASH_COMPARE"}</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user