2015-11-24 59 views
0

我完全不熟悉javascript圖表,並試圖瞭解如何將此圖表的兩個軸設置爲0左下方沒有負值。amCharts氣泡圖軸問題

我試着玩隨機值,可以改變許多設置,但我只是不能弄清楚設置圖表x和y的測量結果只是積極的。

HTML

<script src="http://www.amcharts.com/lib/3/amcharts.js"></script> 
<script src="http://www.amcharts.com/lib/3/xy.js"></script> 
<script src="http://www.amcharts.com/lib/3/themes/none.js"></script> 
<div id="chartdiv"></div> 

JS

var chart = AmCharts.makeChart("chartdiv", { 
    "type": "xy", 
    "theme": "none", 
    "balloon":{ 
    "fixedPosition":true, 
    }, 
    "dataProvider": [ { 
    "y": 10, 
    "x": 14, 
    "value": 59, 
    "y2": -5, 
    "x2": -3, 
    "value2": 44 
    }, { 
    "y": 5, 
    "x": 3, 
    "value": 50, 
    "y2": -15, 
    "x2": -8, 
    "value2": 12 
    }, { 
    "y": -10, 
    "x": 8, 
    "value": 19, 
    "y2": -4, 
    "x2": 6, 
    "value2": 35 
    }, { 
    "y": -6, 
    "x": 5, 
    "value": 65, 
    "y2": -5, 
    "x2": -6, 
    "value2": 168 
    }, { 
    "y": 15, 
    "x": -4, 
    "value": 92, 
    "y2": -10, 
    "x2": -8, 
    "value2": 102 
    }, { 
    "y": 13, 
    "x": 1, 
    "value": 8, 
    "y2": -2, 
    "x2": 0, 
    "value2": 41 
    }, { 
    "y": 1, 
    "x": 6, 
    "value": 35, 
    "y2": 0, 
    "x2": -3, 
    "value2": 16 
    } ], 
    "valueAxes": [ { 
    "position": "bottom", 
    "axisAlpha": 0 
    }, { 
    "minMaxMultiplier": 1.2, 
    "axisAlpha": 0, 
    "position": "left" 
    } ], 
    "startDuration": 0, 
    "graphs": [ { 
    "balloonText": "x:<b>[[x]]</b> y:<b>[[y]]</b><br>value:<b>[[value]]</b>", 
    "bullet": "circle", 
    "bulletBorderAlpha": 0.2, 
    "bulletAlpha": 0.6, 
    "lineAlpha": 0, 
    "fillAlphas": 0, 
    "valueField": "value", 
    "xField": "x", 
    "yField": "y", 
    "maxBulletSize": 100 
    }, { 
    "balloonText": "x:<b>[[x]]</b> y:<b>[[y]]</b><br>value:<b>[[value]]</b>", 
    "bullet": "diamond", 
    "bulletBorderAlpha": 0.2, 
    "bulletAlpha": 0.6, 
    "lineAlpha": 0, 
    "fillAlphas": 0, 
    "valueField": "value2", 
    "xField": "x2", 
    "yField": "y2", 
    "maxBulletSize": 100 
    } ], 
    "marginLeft": 46, 
    "marginBottom": 35, 
    "export": { 
    "enabled": true 
    } 
}); 

CSS

#chartdiv { 
    width : 100%; 
    height : 500px; 
} 

回答

0

要強制你一個數軸,開始在特定的值使用其minimum設置。

所以你的情況你的代碼應該是這樣的:

"valueAxes": [ { 
    "position": "bottom", 
    "axisAlpha": 0, 
    "minimum": 0 
}, { 
    "minMaxMultiplier": 1.2, 
    "axisAlpha": 0, 
    "position": "left", 
    "minimum": 0 
} ],