Javascript 向图表中添加数据
查看Api 2.0p5和图表 我正在寻找一个变种的吞吐量图表,基本上有Javascript 向图表中添加数据,javascript,rally,Javascript,Rally,查看Api 2.0p5和图表 我正在寻找一个变种的吞吐量图表,基本上有 过去12个月的底部 图表左侧的总计数 层数和缺陷计数的堆叠柱 脊椎线穿过故事点,次y轴穿过故事点 到目前为止,我的rally应用程序中都有这些功能,除了我所有的号码目前都是硬编码的。如何将这些信息正确地输入图表 我看到了一个使用商店的例子,但看起来很奇怪,老实说,我不知道我在哪里看到它尝试和复制 代码如下,如果有人有想法或想法,我将不胜感激: <!DOCTYPE html> <html&
- 过去12个月的底部
- 图表左侧的总计数
- 层数和缺陷计数的堆叠柱
- 脊椎线穿过故事点,次y轴穿过故事点
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="240" />
<title>Throughput Chart</title>
<script type="text/javascript" src="https://rally1.rallydev.com/apps/2.0p5/sdk.js?debug=true"></script>
<script type="text/javascript">
Rally.onReady(function () {
Ext.create('Ext.Container', {
items: [
{
xtype: 'rallychart',
height: 400,
series: [{
name: 'Defect Count',
data: [2, 2, 3, 2, 1, 4, 2, 3, 5, 3, 5, 4]
}, {
name: 'Story Count',
data: [3, 4, 4, 2, 5, 3, 4, 5, 6, 3, 4, 8]
}, {
name: 'Story Points',
color: '#89A54E',
type: 'spline',
yAxis: 1,
data: [55, 34, 50, 31, 44, 61, 55, 22, 50, 48, 34, 44]
}],
chartConfig: {
chart: {
type: 'column'
},
title: {
text: 'Kanban State Counts',
align: 'center'
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: [{
title: {
text: 'Count'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
}
}
},
{
opposite: true,
title: {
text: 'Story Points'
}
}],
}
}
],
renderTo: Ext.getBody().dom
});
});
</script>
<style type="text/css">
</style>
</head>
<body>
</body>
</html>
吞吐量图
Rally.onReady(函数(){
Ext.create('Ext.Container'{
项目:[
{
xtype:“rallychart”,
身高:400,
系列:[{
名称:'缺陷计数',
数据:[2,2,3,2,1,4,2,3,5,3,5,4]
}, {
名称:'故事计数',
数据:[3,4,4,2,5,3,4,5,6,3,4,8]
}, {
名称:'故事点',
颜色:“#89A54E”,
类型:“样条线”,
亚克西斯:1,,
数据:[55,34,50,31,44,61,55,22,50,48,34,44]
}],
图表配置:{
图表:{
类型:“列”
},
标题:{
文本:“看板状态计数”,
对齐:“居中”
},
xAxis:{
类别:[一月、二月、三月、四月、五月、六月、七月、八月、九月、十月、十一月、十二月]
},
亚克斯:[{
标题:{
文本:“计数”
},
堆叠标签:{
启用:对,
风格:{
fontWeight:'粗体',
}
}
},
{
相反:是的,
标题:{
文字:“故事要点”
}
}],
}
}
],
renderTo:Ext.getBody().dom
});
});
下面是一个在WSAPI数据存储中使用用户故事数据的基本示例。代码只是按ScheduleState汇总故事,并将计数添加到Ext.data.store。然后,应用程序使用Rally.ui.chart.ChartView组件在条形图中按计划状态显示故事数
<!DOCTYPE html>
<html>
<head>
<title>ChartExample</title>
<script type="text/javascript" src="https://rally1.rallydev.com/apps/2.0p5/sdk.js"></script>
<script type="text/javascript">
Rally.onReady(function() {
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
Ext.create('Rally.data.WsapiDataStore', {
model: 'UserStory',
autoLoad: true,
listeners: {
load: this._onDataLoaded,
scope: this
}
});
},
_onDataLoaded: function(store, data) {
var records = [];
var scheduleStateGroups = ["Defined","In-Progress","Completed","Accepted"]
// State count variables
var definedCount = 0;
var inProgressCount = 0;
var completedCount = 0;
var acceptedCount = 0;
// Loop through returned data and group/count by ScheduleState
Ext.Array.each(data, function(record) {
//Perform custom actions with the data here
//Calculations, etc.
scheduleState = record.get('ScheduleState');
switch(scheduleState)
{
case "Defined":
definedCount++;
break;
case "In-Progress":
inProgressCount++;
break;
case "Completed":
completedCount++;
break;
case "Accepted":
acceptedCount++;
}
});
//Create a store containing the chart data
var scheduleStateStore = Ext.create('Ext.data.Store', {
fields: ['KanbanState', 'ObjectID_Count'],
data: {
rows: [
{ScheduleState: 'Defined', ObjectCount: definedCount},
{ScheduleState: 'InProgress', ObjectCount: inProgressCount},
{ScheduleState: 'Completed', ObjectCount: completedCount},
{ScheduleState: 'Accepted', ObjectCount: acceptedCount}
]
},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'rows'
}
}
});
// Configure and Add the chart
this.add(
{
xtype: 'rallychart',
height: 400,
series: [
{
type: 'column',
dataIndex: 'ObjectCount',
name: 'Count',
visible: true
}
],
store: scheduleStateStore,
chartConfig: {
chart: {
},
title: {
text: 'User Story Schedule State Counts',
align: 'center'
},
xField : 'ScheduleState',
xAxis: [
{
categories: scheduleStateGroups,
title: {
text: 'ScheduleState'
}
}
],
yAxis: {
title: {
text: 'Count'
}
},
plotOptions : {
column: {
color: '#F00'
},
series : {
animation : {
duration : 2000,
easing : 'swing'
}
}
}
}
}
);
}
});
Rally.launchApp('CustomApp', {
name: 'ChartExample'
});
});
</script>
<style type="text/css">
.app {
/* Add app styles here */
}
</style>
</head>
<body></body>
</html>
图表示例
onReady(函数(){
Ext.define('CustomApp'{
扩展:“Rally.app.app”,
组件CLS:“应用程序”,
启动:函数(){
Ext.create('Rally.data.WsapiDataStore'{
模型:“用户故事”,
自动加载:对,
听众:{
加载:这个。加载后,
范围:本
}
});
},
_onDataLoaded:函数(存储、数据){
var记录=[];
var scheduleStateGroups=[“已定义”、“正在进行”、“已完成”、“已接受”]
//状态计数变量
var definedCount=0;
变量inProgressCount=0;
var completedCount=0;
var acceptedCount=0;
//按ScheduleState循环返回的数据和组/计数
Ext.Array.each(数据、函数(记录){
//使用此处的数据执行自定义操作
//计算等。
scheduleState=record.get('scheduleState');
交换机(调度状态)
{
案例“已定义”:
definedCount++;
打破
案件“进行中”:
inProgressCount++;
打破
案件“已完成”:
completedCount++;
打破
“受理”案件:
acceptedCount++;
}
});
//创建包含图表数据的存储
var scheduleStateStore=Ext.create('Ext.data.Store'{
字段:['KanbanState','ObjectID\u Count'],
数据:{
行:[
{ScheduleState:'Defined',ObjectCount:definedCount},
{ScheduleState:'InProgress',ObjectCount:inProgressCount},
{ScheduleState:'Completed',ObjectCount:completedCount},
{ScheduleState:'Accepted',ObjectCount:acceptedCount}
]
},
代理:{
键入:“内存”,
读者:{
键入:“json”,