我创建了吞吐量堆积条形图 从此图表中可以获得最小值,最大值和平均值。并希望它显示在标签上。但无法弄清楚如何做到这一点。请对此提出任何帮助
var chart = Ext.getCmp('mychart'); // chart object
field = Ext.getCmp('myFieldId2'); // Labelfield Id
field.text = chart.chartConfig.yField.maximum;
这是我试图实现的一些代码。
答案 0 :(得分:0)
我想出了如何获取值,
this.globalVar = Ext.Array.flatten(tempSeries);
globalVar具有图表的系列和类别值
然后调用showStats(图表)函数
showStats: function(chart) {
var project_oid = this.getContext().getProject().ObjectID;
//var chart = this.down('#display_box').add(this.getChartConfig(project_oid));
this.timePeriod = Rally.util.DateTime.getDifference(this._endDate, this._startDate,'month');
if (this.timePeriod == 0){
this.timePeriod = 1;
};
var average = Ext.Array.mean(chart.calculator.globalVar);
average = Ext.Number.toFixed(average, 2);
var stdDev = this.standardDeviation(average, chart.calculator.globalVar);
stdDev = Ext.Number.toFixed(stdDev, 2);
this.down('#averageId').setText("Average" + " " + average);
this.down('#countId').setText("Count"+ Ext.Array.sum(chart.calculator.globalVar));
this.down('#minId').setText("Minimum"+ Ext.Array.min(chart.calculator.globalVar));
this.down('#maxId').setText("Maximum"+ Ext.Array.max(chart.calculator.globalVar));
this.down('#stdDevId').setText("Standard Deviation"+ stdDev);
this.down('#myFieldId').setText("Summary Metrics" + "(Last"+ this.timePeriod + months"+ ")");
},
standardDeviation: function(average, values){
var squareDiffs = values.map(function(value){
var diff = value - average;
var sqrDiff = diff * diff;
return sqrDiff;
});
var avgSquareDiff = Ext.Array.mean(squareDiffs);
var stdDev = Math.sqrt(avgSquareDiff);
return stdDev;
},