我正在尝试使用oracle制作图表,但是与此相关的一些问题:
https://www.amcharts.com/demos/stacked-column-chart/
我的查询给出以下结果:
{
"number_status": "20",
"status": "IN PROGRESS",
"child_creator": "pasternok"
}, {
"number_status": "2",
"status": "DELAYED",
"child_creator": "kropep"
}, {
"number_status": "1",
"status": "SOLVED",
"child_creator": "kropep"
}, {
"number_status": "13",
"status": "IN PROGRESS",
"child_creator": "Kaess"
}, {
"number_status": "3",
"status": "ON HOLD",
"child_creator": "hutapeap"
}, {
"number_status": "1",
"status": "REJECTED",
"child_creator": "dmeury"
}, {
"number_status": "10",
"status": "IN PROGRESS",
"child_creator": "Lins"
}, {
"number_status": "1",
"status": "ON HOLD",
"child_creator": "zuerni"
}, {
我想像教程中那样将child_creator放在底部
并且在右侧应该是所有状态。
最佳答案
至少必须格式化数据以使其看起来像这样:
[{
"IN PROGRESS": 20,
"child_creator": "pasternok"
}, {
"SOLVED": 1,
"DELAYED": 2,
"child_creator": "kropep"
}, {
"IN PROGRESS": 13,
"child_creator": "Kaess"
}, {
"ON HOLD": 3,
"child_creator": "hutapeap"
}, {
"REJECTED": 1,
"child_creator": "dmeury"
}, {
"IN PROGRESS": 10,
"child_creator": "Lins"
}, {
"ON HOLD": 1,
"IN PROGRESS": 3,
"child_creator": "zuerni"
}]
然后尝试这个http://jsfiddle.net/tamvo/ne6u0zhu/
var chart = AmCharts.makeChart("chartdiv", {
"type": "serial",
"theme": "light",
"legend": {
"horizontalGap": 10,
"maxColumns": 1,
"position": "right",
"useGraphSettings": true,
"markerSize": 10
},
"dataProvider": [{
"IN PROGRESS": 20,
"child_creator": "pasternok"
}, {
"SOLVED": 1,
"DELAYED": 2,
"child_creator": "kropep"
}, {
"IN PROGRESS": 13,
"child_creator": "Kaess"
}, {
"ON HOLD": 3,
"child_creator": "hutapeap"
}, {
"REJECTED": 1,
"child_creator": "dmeury"
}, {
"IN PROGRESS": 10,
"child_creator": "Lins"
}, {
"ON HOLD": 1,
"IN PROGRESS": 3,
"child_creator": "zuerni"
}],
"valueAxes": [{
"stackType": "regular",
"axisAlpha": 0.3,
"gridAlpha": 0
}],
"graphs": [{
"balloonText": "<b>[[title]]</b><span style='font-size:14px'>: <b>[[value]]</b></span>",
"fillAlphas": 0.8,
"labelText": "[[value]]",
"lineAlpha": 0.3,
"title": "IN PROGRESS",
"type": "column",
"color": "#000000",
"valueField": "IN PROGRESS"
}, {
"balloonText": "<b>[[title]]</b><span style='font-size:14px'>: <b>[[value]]</b></span>",
"fillAlphas": 0.8,
"labelText": "[[value]]",
"lineAlpha": 0.3,
"title": "SOLVED",
"type": "column",
"color": "#000000",
"valueField": "SOLVED"
}, {
"balloonText": "<b>[[title]]</b><span style='font-size:14px'>: <b>[[value]]</b></span>",
"fillAlphas": 0.8,
"labelText": "[[value]]",
"lineAlpha": 0.3,
"title": "DELAYED",
"type": "column",
"color": "#000000",
"valueField": "DELAYED"
}, {
"balloonText": "<b>[[title]]</b><span style='font-size:14px'>: <b>[[value]]</b></span>",
"fillAlphas": 0.8,
"labelText": "[[value]]",
"lineAlpha": 0.3,
"title": "ON HOLD",
"type": "column",
"color": "#000000",
"valueField": "ON HOLD"
}, {
"balloonText": "<b>[[title]]</b><span style='font-size:14px'>: <b>[[value]]</b></span>",
"fillAlphas": 0.8,
"labelText": "[[value]]",
"lineAlpha": 0.3,
"title": "REJECTED",
"type": "column",
"color": "#000000",
"valueField": "REJECTED"
}],
"categoryField": "child_creator",
"categoryAxis": {
"gridPosition": "start",
"axisAlpha": 0,
"gridAlpha": 0,
"position": "left"
},
"export": {
"enabled": true
}
});