實現獲取以前的值時出現問題。例如:amCharts顯示翻轉氣球中的值更改
[ {
"date": "2009-09-1",
"test": 100,
"test2": 900
}, {
"date": "2009-09-2",
"test": 200,
"test2": 800
}, {
"date": "2009-09-3",
"test": 300,
"test2": 700
}, {
"date": "2009-09-4",
"test": 400,
"test2": 600
}, {
"date": "2009-09-5",
"test": 500,
"test2": 500
} ]
我需要一些數據來獲取前一個值的每個點的值,從當前值中減去或增加。例如,在'測試'2009-09-2建議我應該顯示「test:200(+100)」和「test2'2009-09-4」test2:600(-100)「
In現場的例子沒有找到解決方案。
http://jsfiddle.net/Ltv1yLn3/2/
var chartData = [{"date":"2009-09-1","test":100, "test2": 900}, {"date":"2009-09-2","test":200, "test2": 800}, {"date":"2009-09-3","test":300, "test2": 700}, {"date":"2009-09-4","test":400, "test2": 600}, {"date":"2009-09-5","test":500, "test2": 500}];
var chart = AmCharts.makeChart("chartdiv", {
"type": "serial",
"theme": "light",
"dataDateFormat": "YYYY-MM-DD",
"legend": {
"useGraphSettings": true,
"align": "center",
"valueAlign": "left",
"valueText": "[[value]] ([[percents]]%)"
},
"dataProvider": chartData,
"graphs": [
{
"lineColor": "#000000",
"bullet": "round",
"bulletBorderAlpha": 1,
"bulletColor": "#FFFFFF",
"bulletSize": 3,
"hideBulletsCount": 50,
"lineThickness": 2,
"useLineColorForBulletBorder": true,
"title": "Test 1",
"valueField": "test",
"balloonText": "[[title]]: [[value]] (-+100)"
},
{
"lineColor": "#111111",
"bullet": "round",
"bulletBorderAlpha": 1,
"bulletColor": "#FFFFFF",
"bulletSize": 3,
"hideBulletsCount": 50,
"lineThickness": 2,
"useLineColorForBulletBorder": true,
"title": "Test 2",
"valueField": "test2","balloonText": "[[title]]: [[value]] (-+100)"
},
],
"chartCursor": {
"valueLineEnabled": true,
"valueLineBalloonEnabled": true,
"valueLineAlpha": 0.5,
"fullWidth": true,
"cursorAlpha": 0.05
},
"categoryField": "date",
});
感謝您的想法 – Tom910